/* Croco dashboard. One stylesheet, no build step. Light and dark follow the device setting. */

:root {
  color-scheme: light;
  --page: #f6f5f1;
  --surface: #fcfcfb;
  --ink: #171715;
  --ink-2: #52514e;
  --muted: #7d7b75;
  --line: rgba(11, 11, 11, 0.10);
  --line-strong: rgba(11, 11, 11, 0.18);
  --accent: #1d6b52;
  --accent-ink: #ffffff;
  --accent-soft: #e4f1ec;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --ok-soft: #e4f1ec;
  --warn-soft: #fbf0d6;
  --warn-ink: #6b4a00;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05);
  /* charts */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-7: #4a3aa7;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0f0f0e;
    --surface: #1a1a19;
    --ink: #f4f3ef;
    --ink-2: #c3c2b7;
    --muted: #96948d;
    --line: rgba(255, 255, 255, 0.10);
    --line-strong: rgba(255, 255, 255, 0.20);
    --accent: #45a585;
    --accent-ink: #0b1f18;
    --accent-soft: #16332a;
    --danger: #ef8b84;
    --danger-soft: #3a1c1a;
    --ok-soft: #16332a;
    --warn-soft: #3a2f12;
    --warn-ink: #f0d58a;
    --shadow: none;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-7: #9085e9;
    --grid: #2c2c2a;
    --axis: #383835;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; margin: 0 0 14px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
h2.section { margin: 28px 0 10px; font-size: 16px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --- top bar ---------------------------------------------------------------------------- */

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; color: var(--ink); white-space: nowrap; padding: 12px 0; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 14px 11px 12px; color: var(--ink-2); white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.count {
  display: inline-block; min-width: 19px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 650; text-align: center;
}
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }

.page { max-width: 1200px; margin: 0 auto; padding: 22px 20px 60px; }

/* --- buttons and fields ----------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; min-height: 38px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
button.link:hover, a.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 8px 10px; min-height: 38px; max-width: 100%;
}
textarea { width: 100%; resize: vertical; }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
input.qty { width: 76px; }
label { font-size: 13px; color: var(--ink-2); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* --- messages --------------------------------------------------------------------------- */

.flash {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin: 0 0 14px; border-radius: 10px;
  border: 1px solid var(--line);
}
.flash.ok { background: var(--ok-soft); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* --- filters ---------------------------------------------------------------------------- */

.tabs { display: flex; gap: 4px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 7px 12px; border-radius: 8px; color: var(--ink-2); white-space: nowrap;
}
.tabs a:hover { background: var(--line); text-decoration: none; }
.tabs a[aria-selected] { background: var(--ink); color: var(--page); }
.tabs a[aria-selected] .muted { color: inherit; opacity: 0.7; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.filters input[type="search"] { flex: 1 1 240px; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a { padding: 8px 12px; color: var(--ink-2); white-space: nowrap; border-right: 1px solid var(--line); }
.seg a:last-child { border-right: 0; }
.seg a:hover { text-decoration: none; background: var(--line); }
.seg a[aria-current] { background: var(--ink); color: var(--page); }
.summary { margin: 0 0 12px; font-size: 13px; }

/* --- stock grid ------------------------------------------------------------------------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow);
}
.card:hover { border-color: var(--line-strong); text-decoration: none; }
.thumb {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; background: color-mix(in srgb, var(--ink) 6%, var(--surface)); overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.big { border-radius: 12px; border: 1px solid var(--line); }
.nophoto { color: var(--muted); font-size: 13px; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sku { font: 600 13px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.02em; }
h1 .sku { font-size: 22px; }
.desc {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.9em;
}
.price { font-weight: 650; margin-top: 2px; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line);
}
.badge.in { background: var(--ok-soft); color: var(--accent); border-color: transparent; }
.badge.out { color: var(--muted); }
.badge.wait { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; }
.badge.gone { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
@media (prefers-color-scheme: dark) { .badge.in { color: #8fd3b9; } }

/* --- panels, item page ------------------------------------------------------------------ */

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.crumbs { margin: 0 0 12px; font-size: 13px; }
.item { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 24px; align-items: start; }
.item-photo { position: sticky; top: 70px; }
.item-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.item-head h1 { margin: 0; }
.desc-full { margin: 8px 0 4px; font-size: 16px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 18px; margin: 12px 0; }
.facts.wide { margin: 16px 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }

.form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.form label { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.form-row.three { grid-template-columns: repeat(3, 1fr); }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sell { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.sell label { display: flex; align-items: center; gap: 8px; }

.approve { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.approve fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.approve legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 4px; }
.approve label { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--ink); flex-wrap: wrap; }

.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.history li:first-child { border-top: 0; padding-top: 0; }
.history .when { color: var(--muted); font-size: 13px; min-width: 122px; font-variant-numeric: tabular-nums; }
.history li > span:nth-child(2) { flex: 1; }
.undone { opacity: 0.6; }
.danger-zone { margin-top: 20px; }

/* --- pending queue ---------------------------------------------------------------------- */

.queue { display: flex; flex-direction: column; gap: 14px; }
.queue-item { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 16px; align-items: start; margin: 0; }
.queue-item .thumb { border-radius: 10px; }
.queue-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 220px; }
.queue-actions .btn { width: 100%; }

/* --- tables ----------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.panel .table-wrap { border: 0; border-radius: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; white-space: nowrap; }
.table td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table.rows-form input:not([type="checkbox"]) { width: 100%; min-width: 90px; }
.table.rows-form td:first-child input { width: 52px; min-width: 0; text-transform: uppercase; }
.table tr.new td { background: color-mix(in srgb, var(--ink) 3%, transparent); }

/* --- stat tiles ------------------------------------------------------------------------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.tile-label { font-size: 13px; color: var(--ink-2); }
.tile-value { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; }

/* --- charts ----------------------------------------------------------------------------- */

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart {
  margin: 0; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 0;
}
.chart.span2 { grid-column: span 2; }
.chart figcaption { font-weight: 650; margin-bottom: 8px; }
.chart figcaption .muted { font-weight: 400; font-size: 13px; margin-left: 6px; }
/* On a phone the plot keeps a readable size and scrolls sideways inside its card. */
.plot-wrap { overflow-x: auto; }
.plot { width: 100%; min-width: 560px; height: auto; display: block; overflow: visible; }
.plot .grid { stroke: var(--grid); stroke-width: 1; }
.plot .axis { stroke: var(--axis); stroke-width: 1; }
.plot .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.plot .value { fill: var(--ink); font-size: 12px; font-weight: 600; }
.plot .hit { fill: transparent; }
.plot .col { outline: none; cursor: default; }
.plot .col:hover .hit, .plot .col:focus-visible .hit { fill: color-mix(in srgb, var(--ink) 5%, transparent); }
.plot .col:hover path, .plot .col:focus-visible path { filter: brightness(1.12); }
.plot path.s1, .swatch.s1, .bar.s1, .share-part.s1, .tip-key.s1 { fill: var(--series-1); background: var(--series-1); }
.plot path.s2, .swatch.s2, .share-part.s2, .tip-key.s2 { fill: var(--series-2); background: var(--series-2); }
.plot path.s3, .swatch.s3, .share-part.s3, .tip-key.s3 { fill: var(--series-3); background: var(--series-3); }
.plot path.s7, .swatch.s7, .tip-key.s7 { fill: var(--series-7); background: var(--series-7); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 6px; padding: 0; font-size: 13px; color: var(--ink-2); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: baseline; }

.table-view { margin-top: 10px; font-size: 13px; }
.table-view summary { cursor: pointer; color: var(--muted); }
.table-view .table { margin-top: 8px; }

.share { display: flex; gap: 2px; height: 16px; margin: 6px 0 12px; }
.share-part { min-width: 3px; }
.share-part:first-child { border-radius: 4px 0 0 4px; }
.share-part:last-child { border-radius: 0 4px 4px 0; }
.share-part:only-child { border-radius: 4px; }
.share-part:hover, .share-part:focus-visible { filter: brightness(1.12); }

.bars { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.bar-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 10px; outline: none; }
.bar-label { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar { height: 14px; min-width: 2px; border-radius: 0 4px 4px 0; flex: 0 1 auto; }
.bar-row:hover .bar, .bar-row:focus-visible .bar { filter: brightness(1.12); }
.bar-value { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--ink); color: var(--page);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; max-width: 260px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.tip-title { opacity: 0.75; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip-row span:last-child { opacity: 0.8; }
.tip-key { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }

/* --- login ------------------------------------------------------------------------------ */

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 28px 26px; text-align: center;
}
.login-logo { font-size: 40px; line-height: 1; }
.login-card h1 { margin: 8px 0 18px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.login-card input { width: 100%; font-size: 17px; }
.login-card input[name="code"] { letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }
.who-list { gap: 8px; }

/* --- small screens ---------------------------------------------------------------------- */

@media (max-width: 860px) {
  .item { grid-template-columns: 1fr; }
  .item-photo { position: static; max-width: 420px; }
  .charts { grid-template-columns: 1fr; }
  .chart.span2 { grid-column: auto; }
  .queue-item { grid-template-columns: 110px minmax(0, 1fr); }
  .queue-actions { grid-column: 1 / -1; min-width: 0; }
}
@media (max-width: 620px) {
  .top { flex-wrap: wrap; gap: 0 14px; padding: 0 14px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -6px; }
  .who { margin-left: auto; }
  .page { padding: 16px 14px 50px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .tile-value { font-size: 22px; }
  .seg a { padding: 8px 9px; font-size: 13px; }
}
