:root {
  --ink: #211914;
  --muted: #6f635b;
  --faint: #94877d;
  --cream: #eee8de;
  --paper: #fbf8f1;
  --paper-strong: #fffdf8;
  --line: rgba(58, 40, 29, .16);
  --line-strong: rgba(58, 40, 29, .28);
  --roast: #6f3d27;
  --roast-dark: #2b1c16;
  --roast-soft: #9d6849;
  --leaf: #66704b;
  --leaf-soft: #e5e8dc;
  --gold: #ad7d45;
  --danger: #963d32;
  --danger-soft: #f3e4df;
  --shadow: 0 12px 28px rgba(50, 33, 23, .07);
  --shadow-soft: 0 5px 14px rgba(50, 33, 23, .045);
  font-family: "Segoe UI Variable Text", Aptos, "Segoe UI", system-ui, -apple-system, sans-serif;
}

html { background: var(--cream); }
body {
  font-family: "Segoe UI Variable Text", Aptos, "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    linear-gradient(rgba(255,255,255,.18), rgba(255,255,255,.18)),
    repeating-linear-gradient(0deg, rgba(73,50,35,.024) 0, rgba(73,50,35,.024) 1px, transparent 1px, transparent 30px),
    var(--cream);
}

.app-shell { width: min(1180px, calc(100% - 24px)); }
.topbar {
  min-height: 64px;
  margin-top: 10px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px 14px 5px 5px;
  color: #fffaf3;
  background: #231914;
}
.brand { color: #fffaf3; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  color: #2b1c16;
  background: #d5a467;
  box-shadow: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
}
.brand-copy strong { font-size: 15px; font-weight: 760; letter-spacing: -.02em; }
.brand-copy small { color: rgba(255,250,243,.65); font-size: 10px; }
.quiet-link { color: rgba(255,250,243,.72); }
.quiet-link:hover { color: #fff; }
.identity strong { font-size: 12px; }
.identity small { color: rgba(255,250,243,.58); }
.signout-button {
  min-height: 38px;
  padding: 0 11px;
  border-color: rgba(255,255,255,.16);
  border-radius: 9px;
  color: #fffaf3;
  background: rgba(255,255,255,.08);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.page { padding: 34px 0 86px; }
.site-footer { font-size: 11px; }

.eyebrow, .kicker {
  color: var(--roast);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: .08em;
}
h1, h2, p { font-family: inherit; }
h1 {
  margin-bottom: 12px;
  font-family: inherit;
  font-size: clamp(32px, 7vw, 44px);
  line-height: 1.05;
  font-weight: 730;
  letter-spacing: -.035em;
}
h1 em { color: var(--roast); font-style: normal; font-weight: 730; }
h2 {
  margin-bottom: 7px;
  font-family: inherit;
  font-size: 21px;
  line-height: 1.15;
  font-weight: 720;
  letter-spacing: -.025em;
}
p { font-size: 14px; line-height: 1.55; }

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(251,248,241,.94);
  box-shadow: var(--shadow-soft);
  backdrop-filter: none;
}
.auth-panel, .form-panel { padding: 20px; }
.panel-head { margin-bottom: 20px; }
.status-orb { display: none; }
.step-badge, .section-number {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  border-radius: 7px;
  color: #fff9f2;
  background: var(--roast);
  font-size: 10px;
}

label { gap: 7px; margin-bottom: 14px; font-size: 13px; font-weight: 650; }
input, select {
  min-height: 52px;
  padding: 0 13px;
  border-radius: 9px;
  background: var(--paper-strong);
  font-size: 16px;
  font-weight: 560;
}
input:focus, select:focus { box-shadow: 0 0 0 3px rgba(111,61,39,.09); }

.primary-button, .secondary-button, .danger-button {
  min-height: 50px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 720;
}
.primary-button {
  color: #fffaf3;
  background: var(--roast-dark);
  box-shadow: none;
}
.secondary-button { background: rgba(255,253,248,.82); }
.primary-button:hover, .secondary-button:hover, .danger-button:hover { transform: none; }

.auth-wrap { gap: 22px; min-height: auto; padding: 18px 0; }
.auth-intro { padding-top: 0; }
.auth-intro h1 { max-width: 580px; margin-top: 9px; font-size: clamp(32px, 7vw, 44px); }
.auth-intro p { font-size: 14px; }

.hero { padding: 14px 0 20px; }
.compact-hero h1 { max-width: 760px; margin-top: 8px; }
.hero-copy { font-size: 14px; }
.action-grid { gap: 9px; margin-top: 4px; }
.action-card {
  min-height: 108px;
  gap: 13px;
  padding: 17px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: 8px;
  background: rgba(251,248,241,.94);
  box-shadow: none;
}
.action-card:nth-child(2) { border-left-color: var(--leaf); }
.action-card:nth-child(3) { border-left-color: var(--roast); }
.action-card:nth-child(4) { border-left-color: #3d322b; }
.action-card h2 { font-size: 19px; }
.action-card p { font-size: 13px; }
.action-index { margin-top: 3px; color: var(--muted); font-family: inherit; font-size: 10px; font-weight: 800; }
.action-arrow { font-size: 17px; }
.active-card { box-shadow: none; }
.active-card:hover { transform: none; box-shadow: none; background: #fffaf3; }

.page-heading { gap: 14px; margin-bottom: 20px; }
.page-heading h1 { margin: 7px 0 6px; font-size: clamp(32px, 7vw, 44px); }
.page-heading p { font-size: 14px; }
.back-link { margin-bottom: 12px; font-size: 13px; }

.dispatch-panel, .movement-card, .receive-panel {
  border-radius: 10px;
  border-left: 4px solid var(--roast);
  box-shadow: none;
}
.dispatch-section-head, .receive-intro { margin-bottom: 16px; }
.locked-field {
  min-height: 66px;
  border-radius: 9px;
  background: #f2ece2;
}
.quality-row {
  border-radius: 9px;
  background: #fffdf8;
}
.live-total strong, .movement-total strong, .movement-item strong, .ledger-number strong,
.ledger-summary strong, .metric-card strong, .receipt-summary strong, .closed-summary strong {
  font-family: inherit;
}
.live-total strong { font-size: 22px; }
.dispatch-submit { padding-top: 10px; }

.movement-total {
  border-radius: 9px;
  background: var(--roast-dark);
  box-shadow: none;
}
.movement-hero h1, .receive-header h1 { font-size: clamp(30px, 7vw, 42px); }

.arrival-card {
  border-radius: 9px;
  border-left: 4px solid var(--gold);
  box-shadow: none;
}
.empty-arrivals { border-radius: 9px; }

.receipt-summary {
  border-radius: 9px;
  box-shadow: none;
}
.receive-row { border-radius: 8px; }

.ledger-filters, .ledger-summary article, .ledger-row, .ledger-empty {
  border-radius: 9px;
  box-shadow: none;
}
.ledger-summary article { background: #fbf8f1; }
.ledger-summary strong { font-size: 19px; }
.ledger-row { background: #fbf8f1; }

.admin-grid { gap: 8px; }
.metric-card {
  min-height: 108px;
  padding: 16px;
  border-radius: 8px;
  border-top: 3px solid var(--roast);
  box-shadow: none;
}
.metric-card strong { font-size: 30px; font-weight: 720; }
.metric-card span { font-size: 10px; }
.metric-card small { font-size: 11px; }
.data-panel { border-radius: 9px; box-shadow: none; }

.mobile-nav {
  position: fixed;
  z-index: 50;
  left: 10px;
  right: 10px;
  bottom: max(8px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 5px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 12px;
  background: #231914;
  box-shadow: 0 10px 28px rgba(36,24,18,.25);
}
.mobile-nav.analyst-nav { grid-template-columns: repeat(3, 1fr); }
.mobile-nav a {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: rgba(255,250,243,.62);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
}
.mobile-nav a.is-active {
  color: #231914;
  background: #d7a66a;
}

@media (max-width: 619px) {
  .app-shell { width: min(100% - 16px, 520px); }
  .topbar { position: sticky; top: 6px; z-index: 40; }
  .top-actions { gap: 6px; }
  .manage-link { display: none; }
  .signout-button { min-width: 70px; padding: 0 9px; font-size: 11px; }
  .site-footer { display: none; }
  .page-heading .secondary-button, .ledger-heading .primary-button { width: 100%; }
  .action-card { min-height: 94px; }
  .dispatch-panel, .movement-card, .receive-panel { padding: 16px; }
  .quality-row { padding: 13px 42px 0 13px; }
  .dispatch-submit { position: sticky; bottom: 74px; z-index: 20; margin: 0 -2px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(238,232,222,.96); backdrop-filter: blur(8px); }
  .dispatch-submit > div { display: none; }
  .dispatch-submit .primary-button { width: 100%; }
  .receive-table-head { display: none; }
  .receipt-summary { grid-template-columns: 1fr 1fr; }
  .receipt-summary > div:last-child { grid-column: 1 / -1; }
}

@media (min-width: 620px) {
  .app-shell { width: min(1180px, calc(100% - 42px)); }
  .topbar { min-height: 68px; padding: 0 18px; }
  .page { padding-top: 42px; }
  .auth-wrap { grid-template-columns: .9fr minmax(360px, .7fr); align-items: center; min-height: calc(100vh - 190px); }
  .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-nav { display: none; }
}

@media (min-width: 900px) {
  .page { padding-top: 46px; padding-bottom: 60px; }
  .auth-intro h1 { font-size: 44px; }
  .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-card { min-height: 112px; }
  .admin-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .metric-card { min-height: 120px; }
}
