/* BeanRelay final visual pass. Loaded last on purpose. */
:root {
  --espresso: #1f1511;
  --espresso-2: #2b1c16;
  --roast: #613922;
  --roast-2: #855438;
  --crema: #d7a15f;
  --brass: #b88343;
  --parchment: #f6f0e6;
  --paper: #fcf8f1;
  --paper-2: #fffdf8;
  --olive: #596248;
  --olive-soft: #e8eadf;
  --ink: #241a15;
  --muted: #74675f;
  --line: rgba(54, 37, 28, .15);
  --line-strong: rgba(54, 37, 28, .27);
  --danger: #9a4136;
  --danger-soft: #f4e4df;
  --exact: #4e684d;
  --exact-soft: #e8eee4;
  --gold-wash: #f2e2c9;
  --focus: 0 0 0 3px rgba(184, 131, 67, .20);
  --lift: 0 14px 34px rgba(45, 29, 20, .08);
  --lift-tight: 0 6px 18px rgba(45, 29, 20, .06);
}

html { background: #e9dfd1; }
body {
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(215,161,95,.14), transparent 24rem),
    radial-gradient(circle at 92% 18%, rgba(97,57,34,.07), transparent 28rem),
    linear-gradient(rgba(255,255,255,.28), rgba(255,255,255,.12)),
    var(--parchment);
}
body::before {
  content: "";
  position: fixed;
  z-index: -1;
  right: -86px;
  top: 160px;
  width: 170px;
  height: 260px;
  border: 22px solid rgba(75,45,29,.035);
  border-radius: 52% 48% 52% 48% / 42% 58% 42% 58%;
  transform: rotate(34deg);
  pointer-events: none;
}

.icon-sprite { position: absolute; overflow: hidden; }
.icon {
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.app-shell { width: min(1240px, calc(100% - 28px)); }
.topbar {
  min-height: 72px;
  margin-top: 10px;
  padding: 0 15px;
  border-radius: 16px 16px 6px 6px;
  border: 1px solid rgba(255,255,255,.06);
  border-bottom-color: rgba(215,161,95,.40);
  background:
    linear-gradient(110deg, rgba(255,255,255,.025), transparent 32%),
    var(--espresso);
  box-shadow: 0 13px 30px rgba(31,21,17,.16);
}
.brand { gap: 10px; }
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50% 44% 50% 44%;
  color: #271811;
  background: linear-gradient(145deg, #e2b678, #c88d4f);
  transform: rotate(-8deg);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.30);
}
.brand-mark .icon { width: 25px; height: 25px; stroke-width: 1.55; }
.brand-copy strong { color: #fffaf2; font-size: 15px; letter-spacing: -.025em; }
.brand-copy small { color: rgba(255,250,242,.57); font-size: 9.5px; letter-spacing: .075em; text-transform: uppercase; }

.desktop-nav {
  display: none;
  align-items: stretch;
  align-self: stretch;
  gap: 2px;
  margin-left: 16px;
}
.desktop-nav a {
  position: relative;
  min-width: 62px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  color: rgba(255,250,242,.60);
  text-decoration: none;
  font-size: 10px;
  font-weight: 720;
  transition: color .16s ease, background .16s ease;
}
.desktop-nav a .icon { width: 17px; height: 17px; }
.desktop-nav a:hover { color: #fffaf2; background: rgba(255,255,255,.035); }
.desktop-nav a.is-active { color: #f0c88f; }
.desktop-nav a.is-active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--crema);
}
.top-actions { margin-left: auto; }
.manage-link { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; }
.identity { padding-left: 12px; border-left: 1px solid rgba(255,255,255,.10); }
.identity strong { color: #fffaf2; }
.identity small { text-transform: capitalize; }
.signout-button { background: rgba(255,255,255,.055); }
.signout-button:hover { border-color: rgba(215,161,95,.45); background: rgba(215,161,95,.10); }
.local-pill { color: #f4c88f; border-color: rgba(215,161,95,.28); background: rgba(215,161,95,.08); }

.page { position: relative; padding-top: 38px; }
.page::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 0;
  width: 42px;
  height: 4px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--crema), transparent);
}
.site-footer {
  padding: 18px 2px 24px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.footer-seal { display: inline-flex; align-items: center; gap: 6px; color: var(--roast); font-weight: 760; }
.footer-seal .icon { width: 14px; height: 14px; }

h1 { color: #211712; font-weight: 760; }
h1 em { color: var(--roast); }
h2 { color: #2a1c16; }
.eyebrow, .kicker { color: var(--roast); letter-spacing: .105em; }
.back-link { color: var(--muted); }
.back-link:hover { color: var(--roast); }

.panel {
  border-color: var(--line);
  background: rgba(252,248,241,.96);
  box-shadow: var(--lift-tight);
}
.panel:hover { border-color: var(--line-strong); }
.notice.error { border-left: 4px solid var(--danger); background: var(--danger-soft); }

input, select {
  border-color: rgba(57,39,29,.18);
  background: var(--paper-2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
input:hover, select:hover { border-color: rgba(97,57,34,.35); }
input:focus, select:focus, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
label > small, .bags-field small { color: #9a7558; font-weight: 650; }
.unit-label { color: var(--roast); }

.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 9px;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.primary-button { background: linear-gradient(145deg, #362219, var(--espresso)); border-color: #24150f; }
.primary-button:hover { background: #382319; box-shadow: 0 7px 16px rgba(42,27,19,.14); transform: translateY(-1px); }
.secondary-button:hover { border-color: rgba(97,57,34,.35); background: #fffaf3; }

.auth-wrap { position: relative; }
.auth-wrap::before {
  content: "";
  position: absolute;
  left: 5%;
  top: 18%;
  width: 108px;
  height: 154px;
  border: 16px solid rgba(97,57,34,.055);
  border-radius: 55% 45% 55% 45% / 42% 58% 42% 58%;
  transform: rotate(37deg);
  pointer-events: none;
}
.auth-intro { position: relative; z-index: 1; }
.auth-intro h1 { max-width: 610px; }
.auth-panel { border-top: 4px solid var(--crema); box-shadow: var(--lift); }
.auth-panel .primary-button { width: 100%; }

.hero { position: relative; }
.hero::after {
  content: "";
  position: absolute;
  right: 2%;
  top: 0;
  width: 72px;
  height: 100px;
  opacity: .07;
  border: 10px solid var(--roast);
  border-radius: 55% 45% 55% 45% / 42% 58% 42% 58%;
  transform: rotate(32deg);
}
.action-grid { gap: 11px; }
.action-card {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  grid-template-columns: 42px 1fr auto;
  border-left: 1px solid var(--line);
  border-top: 3px solid var(--crema);
  background: linear-gradient(145deg, rgba(255,253,248,.98), rgba(248,241,231,.96));
  box-shadow: var(--lift-tight);
}
.action-card::after {
  content: "";
  position: absolute;
  width: 60px;
  height: 82px;
  right: -29px;
  bottom: -32px;
  border: 8px solid rgba(97,57,34,.04);
  border-radius: 50% 44% 50% 44%;
  transform: rotate(27deg);
}
.action-card:nth-child(2) { border-top-color: var(--olive); }
.action-card:nth-child(3) { border-top-color: var(--roast); }
.action-card:nth-child(4) { border-top-color: #46352c; }
.action-card:hover { background: #fffaf3; border-color: rgba(97,57,34,.28); transform: translateY(-1px); box-shadow: var(--lift); }
.action-index { display: none; }
.action-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--roast);
  background: var(--gold-wash);
}
.action-card:nth-child(2) .action-icon { color: var(--olive); background: var(--olive-soft); }
.action-card:nth-child(3) .action-icon { color: #fff8ee; background: var(--roast); }
.action-icon .icon { width: 21px; height: 21px; }
.action-arrow { color: var(--roast); }
.pending-count { color: #7a321f; background: #f5ddd2; border: 1px solid rgba(154,65,54,.16); }

.page-heading, .receive-header, .movement-hero { align-items: flex-end; }
.page-heading > div:first-child, .receive-header > div:first-child, .movement-hero > div:first-child { max-width: 760px; }

.dispatch-panel, .receive-panel, .movement-card {
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--line);
  border-top: 3px solid rgba(184,131,67,.70);
  background: var(--paper);
  box-shadow: var(--lift-tight);
}
.dispatch-section-head, .receive-intro { align-items: flex-start; }
.section-number {
  color: var(--espresso);
  background: #e3b87c;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.32);
}
.route-grid { position: relative; }
.quality-row {
  border: 1px solid rgba(64,43,31,.12);
  border-left: 3px solid rgba(184,131,67,.55);
  background: #fffdf8;
}
.quality-row:focus-within { border-left-color: var(--roast); box-shadow: 0 4px 13px rgba(53,35,25,.05); }
.remove-row { color: #93665a; background: transparent; }
.remove-row:hover { color: #fff; background: var(--danger); }
.quality-actions { border-top-color: rgba(64,43,31,.11); }
.live-total {
  padding: 8px 12px;
  border-left: 2px solid var(--crema);
  background: rgba(215,161,95,.08);
}
.live-total span { color: var(--muted); }
.live-total strong { color: var(--espresso); }
.dispatch-submit {
  border-top: 1px solid var(--line);
}

.movement-total {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #352119, var(--espresso));
}
.movement-total::after {
  content: "";
  position: absolute;
  right: -25px;
  top: -25px;
  width: 70px;
  height: 100px;
  border: 10px solid rgba(215,161,95,.10);
  border-radius: 50% 42% 50% 42%;
  transform: rotate(35deg);
}
.movement-composition-block { border-top-color: var(--line); }
.received-composition { background: rgba(232,234,223,.48); }
.closed-summary { border-top: 1px solid var(--line); }
.closed-summary > div { min-height: 94px; }
.received-foot { display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); }
.custody-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f4ede3;
}
.custody-person { display: grid; gap: 2px; }
.custody-person:last-child { text-align: right; }
.custody-person span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 750; }
.custody-person strong { font-size: 13px; }
.custody-arrow { color: var(--brass); }

.arrival-stack { gap: 10px; }
.arrival-card {
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--line);
  border-top: 3px solid var(--crema);
  background: linear-gradient(150deg, #fffdf8, #f8f1e7);
  box-shadow: var(--lift-tight);
}
.arrival-card:hover { transform: translateY(-1px); box-shadow: var(--lift); border-color: rgba(97,57,34,.25); }
.arrival-ref { color: var(--roast); }
.arrival-open { color: var(--roast); font-weight: 760; }
.status { letter-spacing: .04em; text-transform: uppercase; }
.status.transit { color: #744518; background: #f3e3c8; border-color: rgba(184,131,67,.25); }
.status.active { color: #43563e; background: var(--exact-soft); border-color: rgba(78,104,77,.22); }

.receipt-summary {
  border: 1px solid var(--line);
  border-top: 4px solid var(--espresso);
  background: #fffdf8;
  box-shadow: var(--lift-tight);
}
.difference-summary.exact, .closed-summary .exact, .ledger-summary .exact, .ledger-row .exact { color: var(--exact); background: var(--exact-soft); }
.loss { color: var(--danger) !important; }
.gain { color: #536238 !important; }

.ledger-filters { border-top: 3px solid rgba(184,131,67,.65); }
.ledger-filters summary { cursor: pointer; }
.ledger-summary { gap: 7px; }
.ledger-summary article {
  border: 1px solid var(--line);
  border-top: 2px solid rgba(184,131,67,.58);
  background: rgba(252,248,241,.96);
  box-shadow: none;
}
.ledger-summary article:nth-child(4) { border-top-color: var(--roast); }
.ledger-list { gap: 7px; }
.ledger-row {
  border-left: 3px solid transparent;
  background: rgba(252,248,241,.96);
}
.ledger-row:hover { border-left-color: var(--crema); background: #fffaf3; box-shadow: var(--lift-tight); }
.ledger-reference strong { color: var(--roast); }
.ledger-route em { color: var(--brass); }

/* Analytics: hierarchy is meaning first, density second. */
.analytics-heading { margin-bottom: 18px; }
.analytics-heading h1 { margin-bottom: 5px; }
.analytics-range, .breakdown-nav, .bucket-nav {
  border: 1px solid var(--line);
  background: rgba(255,253,248,.70);
  box-shadow: none;
}
.analytics-range a.active, .breakdown-nav a.active, .bucket-nav a.active { color: #fff9f1; background: var(--espresso); }
.analytics-filters { box-shadow: none; }
.analytics-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.analytics-story {
  display: grid;
  gap: 10px;
}
.analytics-story-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.analytics-story-title .story-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--roast);
  background: var(--gold-wash);
}
.analytics-story-title .story-icon .icon { width: 21px; height: 21px; }
.analytics-question { margin: 0; color: var(--muted); font-size: 12px; }
.analytics-primary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 8px;
}
.analytics-metric {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 3px solid rgba(184,131,67,.65);
  border-radius: 10px;
  background: #fffdf8;
}
.analytics-metric > span { display: block; color: var(--muted); font-size: 10px; font-weight: 780; letter-spacing: .06em; text-transform: uppercase; }
.analytics-metric strong { display: block; margin: 5px 0 2px; color: var(--espresso); font-size: clamp(23px, 3vw, 31px); line-height: 1; letter-spacing: -.035em; }
.analytics-metric strong small { font-size: .42em; font-weight: 720; letter-spacing: 0; }
.analytics-metric > small { display: block; min-height: 30px; color: var(--muted); font-size: 10.5px; line-height: 1.35; }
.analytics-metric.metric-warn { border-top-color: var(--danger); }
.analytics-metric.metric-gain { border-top-color: var(--olive); }
.analytics-metric.metric-exact { border-top-color: var(--exact); background: linear-gradient(150deg, #fffdf8, #eef2e9); }
.metric-state {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  min-height: 22px !important;
  color: var(--muted);
}
.metric-state .icon { width: 14px; height: 14px; }
.reconcile-banner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 13px 15px;
  border: 1px solid rgba(78,104,77,.20);
  border-radius: 10px;
  background: var(--exact-soft);
}
.reconcile-banner.is-variance { border-color: rgba(154,65,54,.20); background: #f6ebe6; }
.reconcile-banner .icon { width: 24px; height: 24px; color: var(--exact); }
.reconcile-banner.is-variance .icon { color: var(--danger); }
.reconcile-banner strong { display: block; font-size: 13px; }
.reconcile-banner small { color: var(--muted); font-size: 11px; }
.analytics-support-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--line);
}
.analytics-support-strip > div { padding: 11px 13px; background: #f8f2e8; }
.analytics-support-strip span { display:block; color: var(--muted); font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 740; }
.analytics-support-strip strong { font-size: 14px; }
.breakdown-row {
  border-left: 3px solid transparent;
  background: #fffdf8;
  box-shadow: none;
}
.breakdown-row:hover { border-left-color: var(--crema); }
.breakdown-name strong { color: var(--espresso); }
.breakdown-name a { color: var(--roast); font-weight: 740; }
.breakdown-metrics strong { color: var(--espresso); }
.analytics-detail-row:hover { background: #fffaf3; }

.admin-grid .metric-card {
  border-top-color: var(--crema);
  background: linear-gradient(150deg, #fffdf8, #f7efe4);
}
.admin-grid .metric-card:hover { border-color: rgba(97,57,34,.25); box-shadow: var(--lift-tight); }
.data-panel { border-top: 3px solid rgba(184,131,67,.55); }
.data-table th { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: 9.5px; }

.mobile-nav {
  padding: 5px;
  border-color: rgba(215,161,95,.16);
  background: rgba(31,21,17,.97);
  box-shadow: 0 12px 30px rgba(31,21,17,.28);
}
.mobile-nav a { gap: 2px; align-content: center; }
.mobile-nav a .icon { width: 19px; height: 19px; }
.mobile-nav a.is-active { color: var(--espresso); background: linear-gradient(145deg, #e4bb82, #ca914f); }

@media (max-width: 899px) {
  .identity { display: none; }
  .analytics-primary-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .analytics-support-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 619px) {
  .app-shell { width: min(100% - 14px, 520px); }
  .topbar { min-height: 62px; top: 5px; padding: 0 10px; border-radius: 13px 13px 5px 5px; }
  .brand-mark { width: 35px; height: 35px; }
  .brand-mark .icon { width: 22px; height: 22px; }
  .brand-copy small { display: none; }
  .top-actions { gap: 5px; }
  .page { padding-top: 32px; }
  .page::before { top: 8px; }
  .hero::after { width: 50px; height: 72px; right: 0; }
  .action-card { grid-template-columns: 38px 1fr auto; min-height: 92px; padding: 14px; }
  .action-icon { width: 34px; height: 34px; }
  .page-heading, .receive-header, .movement-hero { align-items: stretch; }
  .custody-strip { grid-template-columns: 1fr; }
  .custody-arrow { transform: rotate(90deg); }
  .custody-person:last-child { text-align: left; }
  .analytics-primary-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .analytics-metric { padding: 12px; }
  .analytics-metric strong { font-size: 23px; }
  .analytics-metric > small { min-height: 0; }
  .analytics-support-strip { grid-template-columns: 1fr 1fr; }
  .reconcile-banner { grid-template-columns: auto 1fr; }
}

@media (min-width: 620px) {
  .topbar { padding-inline: 18px; }
  .page { padding-top: 44px; }
}

@media (min-width: 900px) {
  .desktop-nav { display: flex; }
  .top-actions { gap: 10px; }
  .page { padding-top: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
