/* ==========================================================================
   FRESH ROOTS — Order Dashboard
   Same design system as the website: warm paper · deep forest green · sage ·
   refined gold. Type: Fraunces (display) · Inter (UI). Tokens copied from
   website/css/styles.css so the two always feel like one product.
   ========================================================================== */

:root {
  color-scheme: light;
  /* Neutrals / paper */
  --paper:      #F7F4EC;
  --paper-2:    #F1EBDD;
  --card:       #FFFFFF;
  --line:       #E4DECE;
  --line-soft:  #EEE9DC;

  /* Greens */
  --ink:        #15281C;
  --ink-soft:   #4B5A4B;
  --ink-faint:  #646E58;
  --forest-900: #0E2216;
  --forest-800: #143020;
  --forest-700: #1C3A28;
  --green-600:  #2E5238;
  --green-500:  #3F6B49;
  --sage-500:   #7FA06A;
  --sage-200:   #C4D5B2;
  --sage-100:   #E7EDDB;
  --sage-50:    #F0F3E8;

  /* Gold */
  --gold-700:   #7E6519;
  --gold-600:   #C2982F;
  --gold-500:   #CBA341;
  --gold-200:   #E7D6A0;
  --gold-50:    #FBF5E2;

  /* Workflow states — always shown with a text label, never colour alone */
  --st-new:       #A87708;   /* gold — needs attention  */
  --st-progress:  #2a78d6;   /* blue — being packed     */
  --st-delivered: #147d59;   /* green — done            */
  --st-cancelled: #BC3F3E;

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --radius:    20px;
  --radius-sm: 13px;
  --radius-xs: 9px;
  --sh-sm: 0 2px 8px rgba(21, 40, 28, .05);
  --sh:    0 22px 50px -28px rgba(21, 40, 28, .35);
  --ease: cubic-bezier(.21, 1, .31, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper:      #0E2216;
    --paper-2:    #10271A;
    --card:       #143020;
    --line:       #26452F;
    --line-soft:  #1D3A27;
    --ink:        #F4F0E4;
    --ink-soft:   #C4D5B2;
    --ink-faint:  #8FA98F;
    --sage-50:    #1C3A28;
    --sage-100:   #24452F;
    --sage-200:   #35573C;
    --gold-50:    #2A2410;
    --gold-200:   #57470F;
    --st-new:       #D9A93C;
    --st-progress:  #62a2e8;
    --st-delivered: #3FBC8D;
    --st-cancelled: #E27C7B;
    --sh-sm: 0 2px 8px rgba(0,0,0,.35);
    --sh:    0 22px 50px -28px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0E2216; --paper-2: #10271A; --card: #143020;
  --line: #26452F; --line-soft: #1D3A27;
  --ink: #F4F0E4; --ink-soft: #C4D5B2; --ink-faint: #8FA98F;
  --sage-50: #1C3A28; --sage-100: #24452F; --sage-200: #35573C;
  --gold-50: #2A2410; --gold-200: #57470F;
  --st-new: #D9A93C; --st-progress: #62a2e8;
  --st-delivered: #3FBC8D; --st-cancelled: #E27C7B;
  --sh-sm: 0 2px 8px rgba(0,0,0,.35);
  --sh: 0 22px 50px -28px rgba(0,0,0,.6);
}

/* ------------------------------- Base ------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--sage-200); color: var(--forest-900); }
.muted { color: var(--ink-faint); }
.wrap { max-width: 1420px; margin: 0 auto; padding: 22px 26px 70px; }

/* ------------------------------- Header ---------------------------------- */
.top {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(150%) blur(16px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--sh-sm);
}
.top__inner {
  max-width: 1420px; margin: 0 auto; height: 88px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 26px;
}
.brand { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; text-decoration: none; color: inherit; }
.brand__logo { height: 50px; width: auto; }
.brand__logo--light { display: none; }
:root[data-theme="dark"] .brand__logo--dark { display: none; }
:root[data-theme="dark"] .brand__logo--light { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand__logo--dark { display: none; }
  :root:not([data-theme="light"]) .brand__logo--light { display: block; }
}
.brand__tag {
  font-size: .56rem; font-weight: 600; letter-spacing: .3em; text-transform: uppercase;
  color: var(--gold-600);
}
.top__right { display: flex; align-items: center; gap: 10px; }

.clock { text-align: center; line-height: 1.25; font-variant-numeric: tabular-nums; }
.clock strong { display: block; font-family: var(--display); font-size: 1.3rem; font-weight: 600; letter-spacing: .01em; }
.clock span { display: block; font-size: .72rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }

@media (max-width: 860px) {
  .top__inner { height: auto; flex-wrap: wrap; padding: 10px 16px; row-gap: 8px; justify-content: space-between; }
  .brand__logo { height: 38px; }
  .clock { order: 2; min-width: 0; }
  .clock strong { font-size: 1.05rem; }
  .top__right { order: 3; width: 100%; justify-content: flex-end; }
  .wrap { padding: 14px 14px 60px; }
}
@media (max-width: 560px) {
  /* brand + buttons on the first row; the clock gets its own centred line */
  .top__right { order: 2; width: auto; }
  .clock { order: 3; width: 100%; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; justify-content: center; min-width: 0; }
  .clock strong { display: inline; font-size: 1.02rem; }
  .clock span { display: inline; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brand__tag { display: none; }
}

/* ------------------------------- Buttons ---------------------------------- */
.btn {
  --bg: var(--forest-800); --fg: #fff; --bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 100px;
  background: var(--bg); color: var(--fg); border: 1.5px solid var(--bd);
  font-weight: 600; font-size: .92rem; white-space: nowrap;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), background .25s, color .25s, border-color .25s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--primary { --bg: var(--green-600); box-shadow: 0 14px 30px -14px rgba(46,82,56,.85); }
.btn--primary:hover { --bg: var(--forest-700); }
.btn--gold { --bg: var(--gold-600); --fg: #21180A; box-shadow: 0 14px 30px -14px rgba(194,152,47,.8); }
.btn--gold:hover { --bg: var(--gold-500); }
.btn--outline { --bg: transparent; --fg: var(--ink); --bd: var(--line); }
.btn--outline:hover { --bd: var(--green-500); --bg: var(--sage-50); }
.btn--danger { --bg: transparent; --fg: var(--st-cancelled); --bd: var(--line); }
.btn--danger:hover { --bd: var(--st-cancelled); --bg: transparent; }
.btn--sm { padding: 9px 16px; font-size: .86rem; }
.btn--icon { padding: 9px 13px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .78rem; font-weight: 600; padding: 6px 13px; border-radius: 100px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  white-space: nowrap;
}
.pill--status { background: var(--sage-50); border-color: var(--sage-200); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: currentColor; }

/* ------------------------------- Stage tabs -------------------------------- */
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 22px 0 16px; }
.tab {
  --tab-color: var(--ink-faint);
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 18px 12px; border-radius: var(--radius-sm);
  background: var(--card); border: 1.5px solid var(--line);
  font-size: 1.06rem; font-weight: 600; color: var(--ink-soft);
  transition: transform .25s var(--ease), border-color .2s, background .2s;
  border-bottom: 4px solid var(--tab-color);
}
.tab:hover { transform: translateY(-1px); border-color: var(--tab-color); }
.tab[aria-pressed="true"] {
  background: var(--forest-800); color: #F4F0E4; border-color: var(--forest-800);
  border-bottom-color: var(--tab-color);
}
.tab__icon { font-size: 1.3rem; }
.tab__n {
  min-width: 34px; text-align: center; font-variant-numeric: tabular-nums;
  background: var(--paper-2); color: var(--ink); border-radius: 100px;
  padding: 3px 10px; font-size: 1rem; font-weight: 700;
}
.tab[aria-pressed="true"] .tab__n { background: rgba(244,240,228,.2); color: #F4F0E4; }
@keyframes tabPulse { 0%, 100% { box-shadow: none; } 50% { box-shadow: 0 0 0 5px var(--gold-200); } }
.tab--pulse:not([aria-pressed="true"]) { animation: tabPulse 2s ease-in-out infinite; }
@media (max-width: 640px) {
  .tabs { gap: 8px; }
  .tab { flex-direction: column; gap: 4px; padding: 10px 4px; font-size: .85rem; min-width: 0; }
  .tab__label { white-space: normal; line-height: 1.15; text-align: center; }
  .tab__icon { font-size: 1.15rem; }
  .tab__n { min-width: 26px; padding: 2px 8px; font-size: .88rem; }
}

/* -------------------------------- Toolbar ---------------------------------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.search { flex: 1; max-width: 420px; border-radius: 100px !important; padding: 11px 18px !important; }
.addmini > summary { list-style: none; cursor: pointer; }
.addmini > summary::-webkit-details-marker { display: none; }
.summary { font-size: .85rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
@media (max-width: 900px) { .summary { display: none; } }

/* ------------------------------- Add an order ------------------------------ */
.paste {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 16px; box-shadow: var(--sh-sm); padding: 18px 20px;
}
.paste__cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .paste__cols { grid-template-columns: 1fr; } }
.paste__actions { display: flex; gap: 10px; margin-top: 14px; }
.fld { display: flex; flex-direction: column; gap: 7px; }
.fld > span, .fld__label {
  display: block;
  font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint); margin-top: 4px;
}
textarea, input[type="search"], input[type="text"], input[type="number"] {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 10px 13px; width: 100%;
  transition: border-color .2s;
}
textarea:hover, input:hover { border-color: var(--sage-500); }
textarea { resize: vertical; font-size: .92rem; line-height: 1.6; }
.preview {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-xs);
  padding: 12px 14px; min-height: 150px; font-size: .9rem;
}
.preview table { width: 100%; border-collapse: collapse; }
.preview td { padding: 4px 0; vertical-align: top; }
.preview td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.preview .tot { border-top: 1.5px solid var(--line); font-weight: 700; }

/* ------------------------------- Order cards ------------------------------- */
.list { display: flex; flex-direction: column; gap: 14px; max-width: 860px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--line);
  border-radius: var(--radius-sm); padding: 18px 22px;
  box-shadow: var(--sh-sm);
}
.card--cancelled { opacity: .62; }

/* New-order glow — breathes until somebody taps the card. */
@keyframes cardGlow {
  0%, 100% { background: var(--card); box-shadow: var(--sh-sm); }
  50% {
    background: color-mix(in srgb, var(--gold-200) 65%, var(--gold-600) 35%);
    border-color: var(--gold-700);
    box-shadow: 0 0 0 5px var(--gold-200), 0 10px 34px -6px rgba(126, 101, 25, .55);
  }
}
.card--flash { animation: cardGlow 2s ease-in-out infinite; border-left-color: var(--gold-600) !important; }
@media (prefers-reduced-motion: reduce) {
  .card--flash { animation: none; background: var(--gold-200); border-color: var(--gold-600); }
}

.card__head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.card__ref { font-family: var(--display); font-weight: 600; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.card__name { font-size: 1.08rem; font-weight: 700; }
.card__time { margin-left: auto; font-size: .82rem; color: var(--ink-faint); white-space: nowrap; }

.card__warn {
  background: var(--gold-50); border: 1px solid var(--gold-200); border-radius: var(--radius-xs);
  padding: 9px 13px; font-size: .9rem; font-weight: 600; color: var(--gold-700); margin: 8px 0;
}
:root[data-theme="dark"] .card__warn { color: var(--gold-500); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card__warn { color: var(--gold-500); } }

.card__items { list-style: none; margin: 10px 0 0; padding: 0; }
.item {
  display: flex; align-items: baseline; gap: 14px;
  padding: 9px 2px; border-bottom: 1px dashed var(--line-soft);
  font-size: 1.04rem;
}
.item__qty { flex: none; min-width: 74px; font-weight: 700; font-variant-numeric: tabular-nums; }
.item__name { flex: 1; }
.item__amt { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.item--oos .item__name { color: var(--st-cancelled); text-decoration: underline dotted; }

.card__total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 2px 4px; font-size: 1.02rem; font-weight: 600;
}
.card__total strong { font-family: var(--display); font-size: 1.5rem; }

.card__meta { font-size: .92rem; color: var(--ink-soft); margin: 6px 0 4px; line-height: 1.7; }
.card__meta a { color: var(--green-600); font-weight: 700; text-decoration: none; }
:root[data-theme="dark"] .card__meta a { color: var(--ink-soft); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card__meta a { color: var(--ink-soft); } }
.card__meta .sep { margin: 0 8px; color: var(--ink-faint); }

/* THE one big button */
.bigbtn {
  display: block; width: 100%; margin-top: 12px;
  padding: 16px 20px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font: inherit; font-size: 1.12rem; font-weight: 700; color: #fff; letter-spacing: .01em;
  transition: transform .2s var(--ease), filter .2s;
}
.bigbtn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.bigbtn:active { transform: translateY(0); }
.bigbtn:disabled { opacity: .5; cursor: wait; }
.bigbtn--confirm { background: var(--green-600); box-shadow: 0 14px 30px -14px rgba(46,82,56,.85); }
.bigbtn--deliver { background: var(--st-delivered); box-shadow: 0 14px 30px -14px rgba(20,125,89,.8); }

.linkbtn {
  background: none; border: none; padding: 0; font: inherit; font-size: .85rem;
  color: var(--ink-faint); text-decoration: underline; cursor: pointer;
}
.linkbtn:hover { color: var(--ink); }
.card__morebtn { display: block; margin: 10px auto 0; }

/* Expanded details (progressive disclosure) */
.card__extra { border-top: 1px solid var(--line-soft); margin-top: 14px; padding-top: 4px; }
.lines { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 6px 0 4px; }
.lines td { padding: 7px 4px 7px 0; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.lines td:nth-child(4) { text-align: right; font-variant-numeric: tabular-nums; }
.lines input { width: 70px; padding: 6px 8px; font-size: .9rem; text-align: right; border-radius: 7px; }
.lines .rm { border: none; background: none; color: var(--ink-faint); cursor: pointer; font-size: 1.1rem; padding: 0 4px; }
.lines .rm:hover { color: var(--st-cancelled); }
.raw {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-xs);
  padding: 11px 13px; font-size: .84rem; white-space: pre-wrap; word-break: break-word;
  max-height: 170px; overflow-y: auto; margin: 4px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-soft);
}
.card__extra-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.tag {
  white-space: nowrap; font-size: .74rem; font-weight: 600; padding: 3px 9px;
  border-radius: 100px; background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-soft);
}
.tag--warn { background: var(--gold-50); border-color: var(--gold-200); color: var(--gold-700); }
.tag--cancel { background: transparent; border-color: var(--st-cancelled); color: var(--st-cancelled); }

.empty {
  text-align: center; padding: 52px 22px; color: var(--ink-faint);
  border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--card);
  max-width: 860px;
}
.empty strong { font-family: var(--display); font-size: 1.15rem; color: var(--ink-soft); }

.dayline { max-width: 860px; text-align: center; font-size: .85rem; color: var(--ink-faint); margin: 16px 0 0; }

/* ------------------------------ Phone / tablet ----------------------------- */
@media (max-width: 720px) {
  .toolbar { flex-wrap: wrap; }
  .search { max-width: none; min-width: 0; flex: 1 1 200px; }
  /* iOS zooms into any focused input under 16px — keep them at 16px. */
  textarea, input[type="search"], input[type="text"], input[type="number"] { font-size: 16px; }
  .card { padding: 15px 16px; }
  .item { font-size: 1rem; gap: 10px; }
  .item__qty { min-width: 58px; }
  .card__total strong { font-size: 1.35rem; }
  .bigbtn { padding: 15px 16px; font-size: 1.05rem; }
  .card__morebtn { padding: 8px; }             /* bigger tap target */
  .linkbtn { font-size: .9rem; }
  .lines input { width: 62px; }
  .summary { display: none; }
}
@media (max-width: 400px) {
  .card__head { gap: 8px; }
  .card__ref { font-size: 1.02rem; }
  .card__name { font-size: .98rem; }
}

/* --------------------------------- Toast ----------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 14px);
  background: var(--forest-800); color: #F4F0E4; padding: 14px 26px; border-radius: 100px;
  font-size: 1rem; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease); z-index: 60;
  max-width: min(92vw, 620px); text-align: center; box-shadow: var(--sh);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------- Login page ------------------------------- */
  .login-wrap { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
  .login {
    width: min(400px, 100%); background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--sh-sm); padding: 34px 32px 30px; text-align: center;
  }
  .login .brand__logo { height: 58px; margin: 0 auto 4px; }
  .login h1 { font-family: var(--display); font-size: 1.25rem; font-weight: 600; margin: 10px 0 2px; }
  .login p.sub { font-size: .85rem; color: var(--ink-faint); margin: 0 0 22px; }
  .login label { display: block; text-align: left; margin-bottom: 14px; }
  .login label span {
    display: block; font-size: .68rem; font-weight: 600; letter-spacing: .14em;
    text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px;
  }
  .login input { font-size: 16px; }
  .login .bigbtn { margin-top: 6px; }
  .login .err {
    background: #FBEFEE; border: 1px solid var(--st-cancelled); color: var(--st-cancelled);
    border-radius: var(--radius-xs); padding: 10px 13px; font-size: .88rem; font-weight: 600;
    margin-bottom: 16px; display: none;
  }
