/* =========================================================================
   Fruit Selling Management — "The Greengrocer's Ledger"
   Design system: honeydew paper + orchard green, with the oval PLU produce
   sticker as the signature motif. Display: Bricolage Grotesque · Body: Inter
   · Data/figures: Spline Sans Mono. All fonts degrade to system fallbacks.
   ========================================================================= */

/* ----------------------------------------------------------------- Tokens */
:root {
  --bg:          #F4F7F0;   /* honeydew paper */
  --surface:     #FFFFFF;   /* white crate */
  --surface-2:   #FBFCF8;   /* faint panel tint */
  --ink:         #1C2B23;   /* deep forest near-black */
  --ink-soft:    #5B6B61;   /* muted sage for secondary text */
  --ink-faint:   #8B988F;   /* tertiary / placeholders */
  --line:        #E3E9DD;   /* hairline borders */

  --brand:       #2C7A43;   /* orchard green */
  --brand-deep:  #1E5630;   /* sidebar / pressed */
  --brand-tint:  #E7F1E7;   /* green wash backgrounds */
  --accent:      #F26419;   /* tangerine — CTAs, POS, energy */
  --accent-deep: #D2530E;
  --accent-tint: #FDEADF;
  --mango:       #E8A317;   /* low-stock warn */
  --mango-tint:  #FBF0D6;
  --berry:       #B5256E;   /* accents / variety */
  --danger:      #C0392B;
  --danger-tint: #F8E3E0;

  --radius:      14px;
  --radius-sm:   9px;
  --radius-lg:   22px;
  --shadow-sm:   0 1px 2px rgba(28, 43, 35, .06);
  --shadow:      0 6px 20px -8px rgba(28, 43, 35, .18);
  --shadow-lg:   0 18px 48px -16px rgba(28, 43, 35, .28);

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --font-display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --font-body:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "Spline Sans Mono", "SFMono-Regular", ui-monospace, Menlo, monospace;

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  /* faint produce-tissue texture */
  background-image:
    radial-gradient(circle at 12% 18%, rgba(44, 122, 67, .04) 0, transparent 38%),
    radial-gradient(circle at 88% 82%, rgba(242, 100, 25, .04) 0, transparent 40%);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.12; margin: 0; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

/* ------------------------------------------------------ Signature sticker */
/* The oval PLU produce sticker — logo, eyebrows and section markers. */
.sticker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px / 70px;       /* oval, like a real fruit sticker */
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35), var(--shadow-sm);
  transform: rotate(-3deg);
}
.sticker.is-green { background: var(--brand); }
.sticker.is-berry { background: var(--berry); }

/* --------------------------------------------------------------- App shell */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* The mobile nav scrim is hidden on desktop (only a grid child on small screens). */
.scrim { display: none; }

.sidebar {
  background: linear-gradient(180deg, var(--brand-deep) 0%, #194A29 100%);
  color: #E9F2E6;
  padding: var(--sp-5) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 4px;
}
.brand .sticker { align-self: flex-start; transform: rotate(-4deg); }
.brand-name { font-family: var(--font-display); font-size: 21px; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.brand-tag  { font-size: 11.5px; color: #A9C6A6; letter-spacing: .04em; }

.nav { display: flex; flex-direction: column; gap: var(--sp-5); overflow-y: auto; }
.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em;
  color: #7FA47C; padding: 0 10px var(--sp-2);
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: #D5E6D1; font-weight: 500; font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.nav-link .ico { font-size: 16px; width: 20px; text-align: center; filter: saturate(1.1); }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.nav-link.active .ico { filter: none; }

.sidebar-foot { margin-top: auto; font-size: 11px; color: #88A985; padding: 0 10px; }

/* ------------------------------------------------------------------- Main */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6) var(--sp-4);
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(244,247,240,0));
}
.topbar-titles { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.topbar h1 { font-size: 26px; }
.topbar .eyebrow { font-size: 12px; color: var(--ink-soft); letter-spacing: .02em; }
.topbar-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }

.menu-toggle {
  display: none; border: 1px solid var(--line); background: var(--surface);
  width: 42px; height: 42px; border-radius: var(--radius-sm); font-size: 18px; cursor: pointer;
}

.content { padding: 0 var(--sp-6) var(--sp-7); flex: 1; }
.view { animation: rise .32s cubic-bezier(.2,.7,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------------- Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-5);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h3 { font-size: 17px; }
.card-sub { color: var(--ink-soft); font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.span-2 { grid-column: 1 / -1; }

/* ------------------------------------------------------------------ KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--sp-5); box-shadow: var(--shadow-sm);
}
.kpi::after { /* a peeling produce-sticker corner */
  content: ""; position: absolute; top: -26px; right: -26px;
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--brand-tint);
}
.kpi-eyebrow { position: relative; z-index: 1; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.kpi-value { position: relative; z-index: 1; font-family: var(--font-mono); font-size: 30px; font-weight: 600; margin-top: 8px; letter-spacing: -.02em; }
.kpi-foot { position: relative; z-index: 1; font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.kpi.accent::after { background: var(--accent-tint); }
.kpi.mango::after  { background: var(--mango-tint); }
.kpi.berry::after  { background: #F6DEEB; }

/* --------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-accent:hover { background: var(--accent-deep); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-tint); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--brand-tint); color: var(--brand-deep);
}
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok      { background: var(--brand-tint); color: var(--brand-deep); }
.badge.low     { background: var(--mango-tint); color: #8A6206; }
.badge.out     { background: var(--danger-tint); color: var(--danger); }
.badge.pending   { background: var(--mango-tint); color: #8A6206; }
.badge.completed { background: var(--brand-tint); color: var(--brand-deep); }
.badge.cancelled { background: #ECEFEA; color: var(--ink-soft); }

/* ----------------------------------------------------------------- Forms */
.form { display: flex; flex-direction: column; gap: var(--sp-4); max-width: 560px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--ink-faint); }
.field .err { font-size: 12px; color: var(--danger); min-height: 0; }
.input, .select, textarea {
  font-family: inherit; font-size: 14px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); width: 100%; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint); background: var(--surface);
}
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-tint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-2); }

/* ---------------------------------------------------------------- Toolbar */
.toolbar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.search { position: relative; flex: 1; min-width: 220px; }
.search input { padding-left: 38px; }
.search::before { content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .6; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-soft);
  transition: all .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------------------------------------------------------- Catalog grid */
.fruit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--sp-4); }
.fruit-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--sp-4); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s;
}
.fruit-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #D2E0CC; }
.fruit-emoji { font-size: 44px; line-height: 1; filter: drop-shadow(0 4px 6px rgba(28,43,35,.12)); }
.fruit-top { display: flex; align-items: flex-start; justify-content: space-between; }
.fruit-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.fruit-cat { font-size: 12px; color: var(--ink-soft); }
.fruit-price { font-family: var(--font-mono); font-weight: 600; font-size: 18px; }
.fruit-price small { color: var(--ink-soft); font-weight: 500; font-size: 12px; }
.fruit-actions { display: flex; gap: 7px; margin-top: 2px; }
.out-veil { opacity: .55; }

/* ----------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
.data thead th {
  text-align: left; font-family: var(--font-display); font-size: 12px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-soft); padding: 13px var(--sp-4);
  border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.data tbody td { padding: 13px var(--sp-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.data tbody tr:last-child td { border-bottom: none; }
.data tbody tr { transition: background .12s; }
.data tbody tr:hover { background: var(--surface-2); }
.data tbody tr.row-link { cursor: pointer; }
.data .num { font-family: var(--font-mono); text-align: right; font-feature-settings: "tnum" 1; }
.data .emoji-cell { font-size: 22px; }
.row-fruit { display: flex; align-items: center; gap: 10px; }

.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper input { width: 64px; text-align: center; padding: 7px; }

/* -------------------------------------------------------------------- POS */
.pos-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--sp-5); align-items: start; }
.pos-pick .fruit-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pos-tile {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: var(--sp-3); cursor: pointer; text-align: center; transition: transform .12s, box-shadow .12s, border-color .12s;
  box-shadow: var(--shadow-sm);
}
.pos-tile:hover:not(.disabled) { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.pos-tile .fruit-emoji { font-size: 34px; }
.pos-tile .t-name { font-weight: 600; font-size: 13.5px; margin-top: 4px; }
.pos-tile .t-meta { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }
.pos-tile.disabled { opacity: .45; cursor: not-allowed; }

.cart { position: sticky; top: 96px; }
.cart-list { display: flex; flex-direction: column; gap: 2px; margin: var(--sp-3) 0; max-height: 46vh; overflow-y: auto; }
.cart-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px dashed var(--line); }
.cart-row .ci-name { font-weight: 600; font-size: 14px; }
.cart-row .ci-name small { display: block; color: var(--ink-soft); font-weight: 500; font-family: var(--font-mono); }
.cart-row .ci-total { font-family: var(--font-mono); font-weight: 600; }
.cart-x { border: none; background: none; color: var(--ink-faint); cursor: pointer; font-size: 17px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.cart-x:hover { color: var(--danger); background: var(--danger-tint); }
.cart-total { display: flex; align-items: baseline; justify-content: space-between; padding: var(--sp-4) 0; border-top: 2px solid var(--ink); margin-top: var(--sp-2); }
.cart-total .tlabel { font-family: var(--font-display); font-size: 15px; }
.cart-total .tval { font-family: var(--font-mono); font-size: 28px; font-weight: 600; }

/* --------------------------------------------------------- Reports / bars */
.bar-row { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: var(--sp-3); padding: 9px 0; }
.bar-row .bl { font-weight: 600; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.bar-track { background: var(--brand-tint); border-radius: 999px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), #4DA567); border-radius: 999px; transition: width .5s cubic-bezier(.2,.7,.3,1); }
.bar-row .bv { font-family: var(--font-mono); font-size: 13px; color: var(--ink-soft); }

/* -------------------------------------------------------- States / misc */
.empty-state { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--ink-soft); }
.empty-state .ee { font-size: 46px; }
.empty-state h3 { margin: var(--sp-3) 0 6px; color: var(--ink); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: var(--sp-7) auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--ink-soft); }
.stack { display: flex; flex-direction: column; gap: var(--sp-5); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.list-tight { display: flex; flex-direction: column; gap: 2px; }
.low-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.low-line:last-child { border-bottom: none; }
.low-line .ll-name { display: flex; align-items: center; gap: 9px; font-weight: 500; }

/* --------------------------------------------------------------- Toasts */
.toast-region {
  position: fixed; bottom: var(--sp-5); right: var(--sp-5); z-index: 100;
  display: flex; flex-direction: column; gap: var(--sp-2); max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--ink); color: #fff; padding: 12px 15px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 14px; animation: toastin .26s cubic-bezier(.2,.8,.3,1) both;
  border-left: 4px solid var(--brand);
}
.toast.error   { border-left-color: var(--danger); }
.toast.success { border-left-color: #57C46A; }
.toast .ticon { font-size: 16px; }
@keyframes toastin { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------- Responsive */
@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 60;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  .app-shell.nav-open .sidebar { transform: none; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(28,43,35,.4); z-index: 50; }
  .app-shell.nav-open .scrim { display: block; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .pos-layout { grid-template-columns: 1fr; }
  .cart { position: static; }
  .content { padding: 0 var(--sp-4) var(--sp-6); }
  .topbar { padding: var(--sp-4); }
}
@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 22px; }
}

/* ---------------------------------------------------- Accessibility floor */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
