:root {
  --ink: #211e1b;
  --muted: #756d65;
  --paper: #f8f3eb;
  --surface: rgba(255, 253, 249, 0.94);
  --surface-solid: #fffdf9;
  --line: #e9dac9;
  --accent: #d8893c;
  --accent-dark: #ab6425;
  --danger: #b74343;
  --success: #2e7351;
  --shadow: 0 20px 55px rgba(48, 35, 24, 0.12);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 4%, rgba(232, 170, 98, 0.22), transparent 34rem),
    radial-gradient(circle at 92% 12%, rgba(116, 76, 43, 0.10), transparent 30rem),
    #f4ede3;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.admin-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 70px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 54px;
}

.brand-link, .back-link {
  color: inherit;
  text-decoration: none;
}

.brand-link { display: inline-flex; align-items: center; gap: 12px; }
.brand-link img {
  width: 54px; height: 54px; object-fit: contain; padding: 5px;
  background: rgba(255,255,255,.82); border: 1px solid rgba(255,255,255,.9);
  border-radius: 17px; box-shadow: 0 10px 28px rgba(48,35,24,.11);
}
.brand-link span { display: flex; flex-direction: column; gap: 2px; }
.brand-link strong { font-size: 18px; letter-spacing: -.2px; }
.brand-link small { color: var(--muted); font-weight: 650; }

.back-link {
  display: inline-flex; align-items: center; gap: 9px; padding: 11px 15px;
  border: 1px solid rgba(78,57,40,.12); border-radius: 999px;
  background: rgba(255,255,255,.5); font-size: 14px; font-weight: 750;
  transition: .2s ease;
}
.back-link:hover { transform: translateY(-1px); background: rgba(255,255,255,.8); }

.login-layout {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, .75fr);
  align-items: center; gap: clamp(42px, 8vw, 110px); min-height: 560px;
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; color: var(--accent-dark);
  text-transform: uppercase; letter-spacing: 1.6px; font-size: 12px; font-weight: 900;
}
.eyebrow::before { content: ""; width: 24px; height: 2px; border-radius: 99px; background: var(--accent); }

.login-copy h1, .dashboard-heading h1 {
  margin: 16px 0 18px; max-width: 720px; font-size: clamp(38px, 5.5vw, 68px);
  line-height: .98; letter-spacing: -2.4px;
}
.login-copy > p, .dashboard-heading p {
  margin: 0; max-width: 640px; color: var(--muted); font-size: 17px; line-height: 1.7;
}

.feature-list { display: grid; gap: 13px; margin-top: 34px; color: #4e4741; font-weight: 700; }
.feature-list span { display: flex; gap: 11px; align-items: center; }
.feature-list b {
  display: grid; place-items: center; width: 25px; height: 25px; color: var(--success);
  border-radius: 50%; background: rgba(46,115,81,.11); font-size: 13px;
}

.login-card {
  position: relative; padding: 42px 36px 36px; background: var(--surface);
  border: 1px solid rgba(255,255,255,.84); border-radius: 34px; box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.login-logo-wrap {
  width: 78px; height: 78px; display: grid; place-items: center; margin: -78px auto 25px;
  background: var(--surface-solid); border: 7px solid #f4ede3; border-radius: 26px;
  box-shadow: 0 13px 30px rgba(48,35,24,.12);
}
.login-logo { width: 58px; height: 58px; object-fit: contain; }
.login-card h2 { margin: 0 0 8px; text-align: center; font-size: 27px; }
.login-card > p { margin: 0 0 28px; color: var(--muted); text-align: center; line-height: 1.5; }

.field { display: grid; gap: 8px; }
.field + .field { margin-top: 17px; }
.field > span, .field > label { color: #554e48; font-size: 13px; font-weight: 800; }
.field input, .field textarea {
  width: 100%; min-width: 0; padding: 13px 14px; color: var(--ink); background: #fff;
  border: 1px solid #dfd1c2; border-radius: 13px; outline: 0; resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px rgba(216,137,60,.13);
}

.password-control {
  position: relative;
  display: block;
  color: inherit !important;
  font-size: inherit !important;
  font-weight: inherit !important;
}

.password-control input { padding-right: 104px; }

.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  display: inline-flex;
  min-width: 86px;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  color: #6d5a49;
  background: #faf4ec;
  border: 1px solid #ead9c8;
  border-radius: 10px;
  transform: translateY(-50%);
  transition: color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--accent-dark);
  background: #fff8ef;
  border-color: #dfa96f;
  box-shadow: 0 5px 14px rgba(171, 100, 37, .12);
  outline: 0;
}

.password-toggle .eye-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle .eye-slash { opacity: 0; }
.password-toggle[aria-pressed="true"] .eye-slash { opacity: 1; }
.password-toggle > span { font-size: 12px; font-weight: 850; }

.form-error {
  margin: 16px 0 0 !important; padding: 11px 13px; color: #8f2e2e !important;
  background: #fff0f0; border: 1px solid #f0cdcd; border-radius: 12px; font-size: 13px;
}

.primary-button, .secondary-button, .ghost-button {
  border: 0; border-radius: 14px; font-weight: 850; transition: .2s ease;
}
.primary-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; color: #fff;
  background: linear-gradient(145deg, #e29a4d, #c4742f); box-shadow: 0 10px 24px rgba(190,106,38,.25);
}
.login-card .primary-button { width: 100%; margin-top: 22px; }
.primary-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(190,106,38,.31); }
.primary-button:disabled { cursor: not-allowed; opacity: .52; box-shadow: none; }
.secondary-button {
  min-height: 44px; padding: 0 16px; color: var(--accent-dark); background: #fff8ef;
  border: 1px solid #ecd2b8;
}
.secondary-button:hover { background: #fff2e3; transform: translateY(-1px); }
.ghost-button { min-height: 44px; padding: 0 16px; color: #5d554e; background: transparent; border: 1px solid #ded1c4; }
.ghost-button:hover { background: rgba(255,255,255,.7); }

.dashboard {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 30px;
}
.dashboard-heading { grid-column: 1; grid-row: 1; display: block; min-width: 0; }
.dashboard-heading h1 { margin: 12px 0 10px; font-size: clamp(38px, 5vw, 58px); }
.dashboard-heading p { max-width: none; font-size: 15px; }
.dashboard-actions {
  grid-column: 2; grid-row: 1; align-self: end;
  display: flex; justify-content: flex-end; align-items: center; gap: 10px;
  margin: 0; padding: 0; border: 0;
}

.summary-grid { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: 1fr 1fr 1.35fr; gap: 14px; margin: 34px 0; }
.summary-grid article {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 20px 22px; border: 1px solid rgba(222,207,192,.85); border-radius: 19px;
  background: rgba(255,253,249,.74); box-shadow: 0 7px 25px rgba(48,35,24,.05);
}
.summary-grid span { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; }
.summary-grid strong { font-size: 25px; }
.save-state-card strong { color: var(--success); font-size: 16px; }
.save-state-card.is-dirty strong { color: var(--accent-dark); }

.editor-toolbar {
  grid-column: 1 / -1; grid-row: 3;
  display: flex; justify-content: space-between; align-items: end; gap: 24px;
  padding: 24px 2px 16px; border-top: 1px solid rgba(118,92,69,.14);
}
.editor-toolbar h2 { margin: 0 0 6px; font-size: 22px; }
.editor-toolbar p { margin: 0; color: var(--muted); font-size: 14px; }

.editor { grid-column: 1 / -1; grid-row: 4; display: grid; gap: 18px; }
.category-card {
  padding: 24px; background: var(--surface); border: 1px solid rgba(223,207,191,.9);
  border-radius: 24px; box-shadow: 0 12px 35px rgba(48,35,24,.065);
}
.category-card-header { display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.category-card-body { min-width: 0; }
.category-identity { display: flex; gap: 13px; align-items: center; min-width: 0; }
.category-number {
  flex: 0 0 auto; display: grid; place-items: center; width: 40px; height: 40px;
  color: #fff; background: #292522; border-radius: 13px; font-size: 13px; font-weight: 900;
}
.category-heading { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 19px; }
.category-product-count { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.icon-button, .mini-button, .text-button {
  border: 1px solid #e0d3c6; color: #58514b; background: #fff; font-weight: 850; transition: .18s ease;
}
.icon-button { width: 36px; height: 36px; border-radius: 11px; }
.category-toggle { display: none; }
.mini-button { min-width: 31px; height: 29px; padding: 0 8px; border-radius: 9px; font-size: 12px; }
.icon-button:hover, .mini-button:hover, .text-button:hover { background: #fff7ed; border-color: #e8c39e; }
.danger { color: var(--danger); }
button:disabled { opacity: .35; cursor: not-allowed; }

.category-fields { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin: 22px 0; }
.category-fields .field + .field, .item-fields .field + .field { margin: 0; }
.items-heading {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 13px 0; border-top: 1px solid #eadfd4; color: #5c554e; font-size: 13px; font-weight: 900;
  text-transform: uppercase; letter-spacing: .7px;
}
.text-button { padding: 8px 11px; border-radius: 10px; color: var(--accent-dark); text-transform: none; letter-spacing: 0; }
.items-list { display: grid; gap: 10px; }
.item-editor { padding: 16px; background: #faf6f0; border: 1px solid #ebdfd3; border-radius: 16px; }
.item-editor-topline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.item-number { color: var(--accent-dark); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .6px; }
.item-fields { display: grid; grid-template-columns: minmax(180px, 1.15fr) 130px minmax(230px, 1.7fr); gap: 12px; align-items: end; }
.item-fields input, .item-fields textarea { background: rgba(255,255,255,.9); }
.empty-products { padding: 24px; color: var(--muted); text-align: center; border: 1px dashed #dac9b8; border-radius: 15px; }

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: min(380px, calc(100% - 44px));
  padding: 14px 18px; color: #fff; background: #282421; border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.24); font-weight: 750;
}
.toast.error { background: #963b3b; }

@media (max-width: 850px) {
  .login-layout { grid-template-columns: 1fr; gap: 86px; padding: 35px 0; }
  .login-copy { text-align: center; }
  .login-copy > p { margin-inline: auto; }
  .feature-list { width: max-content; max-width: 100%; margin-inline: auto; text-align: left; }
  .login-card { width: min(470px, 100%); margin-inline: auto; }
  .dashboard { display: block; }
  .dashboard-actions {
    width: 100%; margin-top: 24px; padding-top: 20px;
    border-top: 1px solid rgba(118,92,69,.14);
  }
  .save-button { flex: 1; }
  .item-fields { grid-template-columns: 1fr 120px; }
  .description-field { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .admin-shell { width: min(100% - 16px, 1180px); padding: 8px 0 max(12px, env(safe-area-inset-bottom)); }
  .admin-header { gap: 10px; margin-bottom: 24px; }
  .brand-link { gap: 8px; }
  .brand-link img { width: 42px; height: 42px; border-radius: 13px; }
  .brand-link strong { font-size: 16px; }
  .brand-link small { display: none; }
  .back-link { gap: 6px; min-height: 40px; padding: 7px 11px; font-size: 12px; }
  .login-copy h1 { font-size: 40px; letter-spacing: -1.7px; }
  .login-card { padding: 39px 20px 23px; border-radius: 25px; }
  .dashboard-heading { width: 100%; }
  .dashboard-heading h1 { margin: 8px 0 8px; font-size: clamp(30px, 9vw, 36px); line-height: 1.03; letter-spacing: -1.5px; }
  .dashboard-heading p { width: 100%; max-width: none; font-size: 13px; line-height: 1.5; }
  .eyebrow { font-size: 10px; letter-spacing: 1.2px; }
  .eyebrow::before { width: 18px; }
  .dashboard-actions {
    position: static; display: grid; grid-template-columns: .65fr 1.35fr; gap: 8px;
    width: 100%; margin-top: 18px; padding: 14px 0 0; background: none; border-radius: 0;
    box-shadow: none; backdrop-filter: none;
  }
  .dashboard-actions .ghost-button, .dashboard-actions .primary-button { min-height: 48px; padding-inline: 10px; font-size: 13px; border-radius: 12px; }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 18px 0 22px; }
  .summary-grid article { align-items: flex-start; flex-direction: column; gap: 5px; min-width: 0; padding: 11px 10px; border-radius: 14px; }
  .summary-grid span { font-size: 9px; letter-spacing: .45px; }
  .summary-grid strong { font-size: 20px; line-height: 1; }
  .save-state-card { grid-column: auto; }
  .save-state-card strong { max-width: 100%; font-size: 11px; line-height: 1.15; overflow-wrap: anywhere; }
  .editor-toolbar { align-items: stretch; flex-direction: column; gap: 12px; padding: 17px 2px 12px; }
  .editor-toolbar h2 { margin-bottom: 4px; font-size: 19px; }
  .editor-toolbar p { font-size: 12px; line-height: 1.45; }
  .editor-toolbar .secondary-button { width: 100%; }
  .editor { gap: 10px; }
  .category-card { padding: 13px; border-radius: 17px; }
  .category-card-header { display: grid; grid-template-columns: 1fr; align-items: start; gap: 10px; }
  .category-identity { width: 100%; gap: 9px; align-items: flex-start; }
  .category-identity > div { min-width: 0; }
  .category-number { width: 34px; height: 34px; border-radius: 11px; }
  .category-heading { overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; font-size: 16px; line-height: 1.2; }
  .category-product-count { margin-top: 2px; font-size: 11px; }
  .category-card-header .row-actions { justify-self: end; gap: 4px; }
  .category-card-header .icon-button { width: 34px; height: 34px; border-radius: 10px; }
  .category-toggle { display: inline-grid; place-items: center; color: var(--accent-dark); background: #fff8ef; }
  .category-card.is-collapsed .category-card-body { display: none; }
  .category-fields { grid-template-columns: 1fr; gap: 10px; margin: 14px 0; }
  .field { gap: 6px; }
  .field > span, .field > label { font-size: 11px; }
  .field input, .field textarea { min-height: 42px; padding: 9px 11px; border-radius: 11px; font-size: 16px; }
  .items-heading { padding: 10px 0; font-size: 11px; }
  .items-list { gap: 8px; }
  .item-editor { padding: 11px; border-radius: 13px; }
  .item-editor-topline { margin-bottom: 8px; }
  .item-fields { grid-template-columns: minmax(0, 1fr) 88px; gap: 8px; }
  .description-field { grid-column: 1 / -1; }
  .price-field { width: 100%; }
  .mini-button { height: 32px; }
  .toast { right: 10px; bottom: 84px; max-width: calc(100% - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
