:root {
  --teal-950: #173942;
  --teal-900: #203f49;
  --teal-800: #294e59;
  --cream-50: #fffaf3;
  --cream-100: #f7eddf;
  --cream-200: #ead9c5;
  --cream-300: #dcc6ae;
  --brown-500: #9d6242;
  --brown-600: #815036;
  --gold-300: #eadb8b;
  --ink: #283438;
  --muted: #69777a;
  --white: #ffffff;
  --danger: #a63b35;
  --success: #27705b;
  --shadow: 0 18px 55px rgba(31, 55, 62, .12);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(234, 219, 139, .2), transparent 28rem),
    var(--cream-50);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 .45rem;
  color: var(--brown-500);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .23em;
  text-transform: uppercase;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(23,57,66,.92), rgba(23,57,66,.96)),
    url("../assets/brand/cover-hero.jpg") center / cover no-repeat;
}
.login-card {
  width: min(100%, 460px);
  padding: clamp(1.5rem, 5vw, 2.5rem);
  border: 1px solid rgba(234,219,139,.22);
  border-radius: 26px;
  color: var(--cream-100);
  background: rgba(25, 60, 70, .92);
  box-shadow: 0 24px 80px rgba(5, 24, 30, .35);
  backdrop-filter: blur(18px);
}
.login-card > img {
  width: 82px;
  height: 78px;
  margin-bottom: 1.25rem;
  object-fit: cover;
  border: 1px solid rgba(234,219,139,.38);
  border-radius: 18px;
}
.login-card .eyebrow { color: var(--gold-300); }
.login-card h1 {
  margin: 0;
  color: #fff3b5;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 7vw, 3.2rem);
  font-weight: 500;
  line-height: 1.05;
}
.login-copy { margin: .85rem 0 1.4rem; color: rgba(255,255,255,.72); }
.login-card label { display: block; margin-bottom: .45rem; font-size: .84rem; font-weight: 800; }
.pin-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .7rem; }
.pin-row input {
  width: 100%;
  min-height: 52px;
  padding: .7rem 1rem;
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 14px;
  outline: 0;
  color: var(--white);
  background: rgba(255,255,255,.08);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: .45em;
  text-align: center;
}
.pin-row input:focus { border-color: var(--gold-300); box-shadow: 0 0 0 4px rgba(234,219,139,.12); }
.pin-row button {
  min-height: 52px;
  padding: 0 1.2rem;
  border: 0;
  border-radius: 14px;
  color: var(--teal-950);
  background: var(--gold-300);
  font-weight: 850;
}
.back-link { display: inline-block; margin-top: 1.35rem; color: rgba(255,255,255,.72); font-size: .9rem; }
.form-error { margin: .7rem 0 0; color: #ffd6d3; font-size: .88rem; font-weight: 700; }

.admin-view { min-height: 100vh; }
.admin-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(234,219,139,.2);
  color: var(--cream-100);
  background: rgba(29,65,75,.97);
  box-shadow: 0 7px 28px rgba(10,31,37,.17);
  backdrop-filter: blur(14px);
}
.admin-header-inner {
  width: min(1440px, calc(100% - 28px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  text-decoration: none;
}
.admin-brand img { width: 52px; height: 50px; object-fit: cover; border-radius: 13px; }
.admin-brand span { display: grid; }
.admin-brand strong { color: #fff0ad; letter-spacing: .14em; }
.admin-brand small { color: rgba(255,255,255,.68); font-size: .74rem; }
.admin-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: .55rem; }
.save-status { margin-right: .35rem; color: rgba(255,255,255,.68); font-size: .79rem; white-space: nowrap; }
.save-status.has-draft { color: #fff0ad; }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .65rem 1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 820;
  line-height: 1.15;
}
.button.primary { color: var(--white); background: var(--brown-500); }
.button.primary:hover { background: var(--brown-600); }
.button.secondary { color: var(--teal-950); border-color: var(--cream-300); background: var(--cream-100); }
.button.ghost { color: inherit; border-color: rgba(129,80,54,.2); background: transparent; }
.admin-header .button.ghost { border-color: rgba(255,255,255,.26); color: var(--cream-100); }
.button.danger-outline { color: var(--danger); border-color: rgba(166,59,53,.3); background: transparent; }
.button.full { width: 100%; }
.button:focus-visible, .icon-button:focus-visible { outline: 3px solid rgba(157,98,66,.26); outline-offset: 2px; }

.admin-main {
  width: min(1440px, calc(100% - 28px));
  margin: 24px auto 60px;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.admin-sidebar {
  position: sticky;
  top: 94px;
  display: grid;
  gap: 14px;
}
.sidebar-card {
  padding: 18px;
  border: 1px solid rgba(129,80,54,.13);
  border-radius: 18px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 10px 32px rgba(31,55,62,.06);
}
.sidebar-card h2 { margin: 0 0 1rem; color: var(--teal-900); font-size: 1.06rem; }
.publish-card p:not(.eyebrow) { margin: -.35rem 0 1rem; color: var(--muted); font-size: .86rem; }
.sidebar-card .button + .button { margin-top: .65rem; }
.sidebar-note {
  padding: 15px 17px;
  border: 1px dashed rgba(157,98,66,.32);
  border-radius: 16px;
  color: #6c5648;
  background: #fff5df;
  font-size: .82rem;
}
.sidebar-note strong { color: var(--teal-900); }
.sidebar-note p { margin: .35rem 0 0; }
.field-label { display: block; margin: .8rem 0 .35rem; color: #536164; font-size: .79rem; font-weight: 800; }

.control {
  width: 100%;
  min-height: 44px;
  padding: .68rem .8rem;
  border: 1px solid var(--cream-300);
  border-radius: 11px;
  outline: 0;
  color: var(--ink);
  background: var(--white);
}
textarea.control { resize: vertical; }
.control:focus { border-color: var(--brown-500); box-shadow: 0 0 0 4px rgba(157,98,66,.1); }

.admin-content { min-width: 0; }
.content-heading {
  min-height: 70px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 14px;
}
.content-heading h1 { margin: 0; color: var(--teal-950); font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1; }
.inventory-count {
  display: grid;
  grid-template-columns: auto auto auto auto;
  align-items: baseline;
  gap: .25rem .45rem;
  color: var(--muted);
  font-size: .82rem;
}
.inventory-count strong { color: var(--teal-900); font-size: 1.2rem; }

.product-list { display: grid; gap: 10px; }
.product-row {
  display: grid;
  grid-template-columns: 68px minmax(180px, 1.35fr) minmax(135px, .8fr) minmax(145px, .75fr) auto;
  align-items: center;
  gap: 13px;
  padding: 10px 12px;
  border: 1px solid rgba(129,80,54,.12);
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 8px 24px rgba(31,55,62,.045);
}
.product-thumb {
  width: 68px;
  height: 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 11px;
  color: rgba(32,63,73,.45);
  background: var(--cream-100);
  font-size: .68rem;
  text-align: center;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-main { min-width: 0; }
.product-main strong { display: block; overflow: hidden; color: var(--teal-950); text-overflow: ellipsis; white-space: nowrap; }
.product-main small, .product-meta { color: var(--muted); font-size: .79rem; }
.product-category { min-width: 0; color: #5c6769; font-size: .85rem; }
.product-price { color: var(--brown-600); font-weight: 850; }
.product-row-actions { display: flex; gap: .4rem; }
.row-button {
  min-width: 39px;
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  padding: .35rem .6rem;
  border: 1px solid rgba(129,80,54,.18);
  border-radius: 10px;
  color: var(--teal-900);
  background: var(--white);
  font-weight: 800;
}
.row-button:hover { border-color: var(--brown-500); background: var(--cream-100); }
.admin-empty { padding: 60px 20px; border: 1px dashed var(--cream-300); border-radius: 20px; text-align: center; color: var(--muted); }
.admin-empty strong { color: var(--teal-900); font-size: 1.1rem; }
.admin-empty p { margin: .35rem 0 0; }

.product-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: calc(100vh - 28px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--cream-50);
  box-shadow: 0 28px 100px rgba(11,35,42,.35);
}
.product-dialog::backdrop { background: rgba(12,38,45,.68); backdrop-filter: blur(5px); }
.product-dialog form { padding: 22px; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding-bottom: 16px; border-bottom: 1px solid var(--cream-200); }
.dialog-header h2 { margin: 0; color: var(--teal-950); font-size: 1.65rem; }
.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--cream-300);
  border-radius: 50%;
  color: var(--brown-600);
  background: var(--white);
  font-size: 1.5rem;
  line-height: 1;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px 0; }
.form-field { display: grid; gap: .38rem; align-content: start; }
.form-field.wide, .image-preview-wrap.wide { grid-column: 1 / -1; }
.form-field > span { color: #536164; font-size: .79rem; font-weight: 820; }
.form-field small { color: var(--muted); font-size: .75rem; }
.check-field { align-self: end; min-height: 44px; display: flex; align-items: center; gap: .55rem; color: #536164; font-size: .84rem; font-weight: 750; }
.check-field input { width: 18px; height: 18px; accent-color: var(--brown-500); }
.image-preview-wrap { height: 175px; overflow: hidden; border: 1px solid var(--cream-300); border-radius: 14px; background: var(--cream-100); }
.image-preview-wrap img { width: 100%; height: 100%; object-fit: contain; }
.product-dialog .form-error { color: var(--danger); }
.dialog-actions { display: flex; align-items: center; gap: .6rem; padding-top: 16px; border-top: 1px solid var(--cream-200); }
.dialog-spacer { flex: 1; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: min(380px, calc(100% - 36px));
  padding: .85rem 1rem;
  border-radius: 13px;
  color: var(--white);
  background: var(--teal-900);
  box-shadow: 0 14px 50px rgba(10,31,37,.25);
  font-weight: 750;
}

@media (max-width: 1050px) {
  .admin-main { grid-template-columns: 260px minmax(0, 1fr); }
  .product-row { grid-template-columns: 58px minmax(150px, 1fr) minmax(120px, .7fr) auto; }
  .product-thumb { width: 58px; height: 54px; }
  .product-price { grid-column: 2 / 3; }
  .product-row-actions { grid-column: 4; grid-row: 1 / span 2; }
}

@media (max-width: 780px) {
  .admin-header { position: static; }
  .admin-header-inner { align-items: flex-start; padding: 10px 0; }
  .admin-header-actions { flex-wrap: wrap; }
  .save-status { width: 100%; text-align: right; }
  .admin-main { display: block; margin-top: 16px; }
  .admin-sidebar { position: static; grid-template-columns: 1fr 1fr; margin-bottom: 24px; }
  .sidebar-note { grid-column: 1 / -1; }
  .content-heading { min-height: 0; }
  .product-row { grid-template-columns: 62px minmax(0, 1fr) auto; align-items: start; }
  .product-thumb { width: 62px; height: 60px; grid-row: 1 / span 3; }
  .product-category, .product-price { grid-column: 2; }
  .product-row-actions { grid-column: 3; grid-row: 1 / span 3; flex-direction: column; }
}

@media (max-width: 560px) {
  .login-view { padding: 14px; }
  .pin-row { grid-template-columns: 1fr; }
  .admin-header-inner { width: min(100% - 20px, 1440px); display: block; }
  .admin-header-actions { margin-top: 10px; justify-content: flex-start; }
  .save-status { text-align: left; }
  .admin-main { width: min(100% - 20px, 1440px); }
  .admin-sidebar { grid-template-columns: 1fr; }
  .sidebar-note { grid-column: auto; }
  .content-heading { align-items: start; }
  .inventory-count { grid-template-columns: auto auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.wide, .image-preview-wrap.wide { grid-column: auto; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-spacer { display: none; }
  .dialog-actions .button { flex: 1 1 44%; }
  #delete-product { flex-basis: 100%; order: 3; }
}
