/* Galey & Co. inventory — design system.
   Brand colors/fonts can be overridden by public/brand/theme.css (loaded after this file). */

:root {
  --bg: #f6f4f0;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #6f675f;
  --line: #e9e4dc;
  --line-strong: #d8d0c5;
  --brand: #6b3f23;
  --brand-dark: #4e2d18;
  --accent: #c98a3a;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --sidebar: #1c1917;
  --sidebar-ink: #f5f0ea;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: var(--font);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, .05);
  --shadow: 0 1px 3px rgba(28, 25, 23, .06), 0 10px 30px -14px rgba(28, 25, 23, .16);
  --shadow-lg: 0 2px 6px rgba(28, 25, 23, .06), 0 24px 60px -24px rgba(28, 25, 23, .28);
  --ring: color-mix(in srgb, var(--brand) 22%, transparent);
  --brand-soft: color-mix(in srgb, var(--brand) 7%, #ffffff);
  --hover: color-mix(in srgb, var(--brand) 3%, #ffffff);
  --sidebar-w: 264px;
  --topbar-h: 56px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font: 14.5px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2 { font-family: var(--font-heading); letter-spacing: -.015em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 20px; font-weight: 700; }
h1 small { font-size: 16px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
h1 .status, h1 .tag { position: relative; top: -3px; margin-left: 4px; }
h2 { font-size: 20px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 15px; margin: 0 0 14px; font-weight: 650; color: var(--ink); letter-spacing: -.005em; }
h3 + h3, .table + h3, .table-wrap + h3, p + h3 { margin-top: 24px; }
p { margin: 0 0 10px; }
strong { font-weight: 650; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.pre { white-space: pre-wrap; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
.warn { color: var(--warn); }
svg.icon { width: 18px; height: 18px; flex: none; }

/* ---------- App layout ---------- */
body.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.content { padding: 32px 40px 72px; max-width: 1360px; width: 100%; min-width: 0; }

/* Sidebar */
.sidebar {
  background: var(--sidebar); color: var(--sidebar-ink);
  padding: 20px 14px 16px; display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent;
}
.sidebar a { color: var(--sidebar-ink); }
.sidebar a:hover { text-decoration: none; }
.sidebar .brand { padding: 2px 6px 6px; }
.sidebar .btn-primary { background: var(--sidebar-ink); border-color: var(--sidebar-ink); color: var(--sidebar); }
.sidebar .btn-primary:hover { background: #fff; border-color: #fff; }
.sidebar ul { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar li a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-ink); opacity: .72; font-weight: 500; font-size: 14px; transition: background .15s, opacity .15s;
}
.sidebar li a .icon { opacity: .85; }
.sidebar li a:hover { background: rgba(255,255,255,.07); opacity: 1; }
.sidebar li a.active { background: rgba(255,255,255,.12); opacity: 1; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar .nav-sep { margin: 16px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; opacity: .45; font-weight: 600; }
.sidebar-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 6px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 13.5px; }
.sidebar-footer .me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-footer .me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.14); color: var(--sidebar-ink); font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em;
}
.sidebar-footer form { margin: 0; }
.sidebar-footer button.link { display: inline-flex; align-items: center; gap: 6px; opacity: .7; padding: 6px; border-radius: 8px; }
.sidebar-footer button.link:hover { opacity: 1; background: rgba(255,255,255,.08); text-decoration: none; }

/* Brand mark */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--sidebar-ink); }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand img.logo { height: 40px; width: 40px; object-fit: contain; display: block; background: #fff; border-radius: 12px; padding: 3px; }
.brand.big { color: var(--ink); justify-content: center; font-size: 22px; margin-bottom: 18px; }
.brand.big img.logo { height: 72px; width: 72px; padding: 0; background: transparent; border-radius: 0; margin: 0 auto; }
.bean { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); position: relative; flex: none; }
.bean::after { content: ""; position: absolute; left: 10px; top: 4px; width: 4px; height: 16px; border-radius: 4px; background: var(--sidebar); transform: rotate(18deg); }
.brand.big .bean::after { background: var(--card); }

/* Mobile top bar + drawer (hidden on desktop) */
.topbar { display: none; }
.nav-backdrop { display: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn .icon { width: 20px; height: 20px; }

@media (max-width: 960px) {
  body.app { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 12px; height: var(--topbar-h); padding: 0 14px;
    background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
  }
  .topbar .brand { flex: 1; min-width: 0; color: var(--ink); font-size: 15px; }
  .topbar .brand img.logo { height: 34px; width: 34px; padding: 0; background: transparent; }
  .topbar .bean::after { background: var(--card); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(var(--sidebar-w), 86vw); height: 100vh; z-index: 50;
    transform: translateX(-104%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  .nav-backdrop { position: fixed; inset: 0; background: rgba(28,25,23,.45); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .nav-backdrop { display: block; opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .content { padding: 18px 16px 60px; }
  h1 { font-size: 24px; }
}
@media (max-width: 600px) {
  .card { padding: 16px 16px; }
  .page-head { align-items: flex-start; }
  .page-head .actions .btn { flex: 1; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin-bottom: 2px; }
.page-head > div > p.muted { margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-head .actions form { margin: 0; display: flex; gap: 6px; align-items: center; }
.crumbs { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 22px 24px; margin-bottom: 20px;
}
.card.narrow { max-width: 780px; }
.card > h3:first-child, .card > .card-head:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h3 { margin: 0; }
.card-head a { font-size: 13px; font-weight: 500; }
.card > p.muted:only-child {
  margin: 0; padding: 28px 16px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--muted);
}
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 > div > .card { margin-bottom: 20px; }
.grid-2 > div > .card:last-child { margin-bottom: 0; }
.grid-2.wide { grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); }
.grid-pos { display: grid; grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); gap: 20px; align-items: start; }
.grid-pos > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-pos + .card, .grid-2 + section, .stats + .card { margin-top: 20px; }
@media (max-width: 900px) {
  /* minmax(0, 1fr): a wide table inside must scroll in its wrapper, never widen the page. */
  .grid-pos { grid-template-columns: minmax(0, 1fr); }
  .grid-2, .grid-2.wide { grid-template-columns: minmax(0, 1fr); }
  .card, .stat { min-width: 0; }
}

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats.inner { margin-bottom: 18px; gap: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.stats.inner .stat { background: var(--bg); border-color: transparent; box-shadow: none; padding: 14px 16px; }
.stat .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stats.inner .stat .value { font-size: 22px; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.highlight { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
@media (max-width: 600px) {
  .stats, .stats.inner { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat, .stats.inner .stat { padding: 14px 14px; }
  .stat .value, .stats.inner .stat .value { font-size: 21px; }
  .stat .sub { font-size: 12px; }
}

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table thead th { border-bottom: 1px solid var(--line-strong); }
.table tbody tr:last-child td { border-bottom: none; }
.table tfoot th, .table tfoot td { border-bottom: none; border-top: 2px solid var(--line-strong); font-weight: 650; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 14px; }
.table tr.grand td, .table tr.grand th { font-size: 16px; }
.table.compact { font-size: 13.5px; }
.table.compact th, .table.compact td { padding: 8px 10px; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--hover); }
.table tr.low td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.table td small { display: inline-block; margin-top: 1px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table input.small { width: 96px; }
.table .btn-sm { vertical-align: middle; }
.table td.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* List tables as stacked cards on phones. app.js adds .responsive and data-label to eligible tables. */
@media (max-width: 700px) {
  .table.responsive, .table.responsive tbody, .table.responsive tfoot, .table.responsive tr, .table.responsive td { display: block; }
  .table.responsive thead { display: none; }
  .table.responsive tbody tr {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm);
    padding: 6px 14px; margin-bottom: 10px; transition: none;
  }
  .table.responsive tbody tr:hover { background: var(--card); }
  .table.responsive tbody tr:last-child { margin-bottom: 0; }
  .table.responsive tr.low { border-left: 3px solid var(--warn); }
  .table.responsive tr.low td:first-child { box-shadow: none; }
  .table.responsive td {
    display: flex; justify-content: flex-end; align-items: baseline; gap: 0 8px; flex-wrap: wrap;
    padding: 8px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: normal; font-size: 14px;
  }
  .table.responsive td:last-child, .table.responsive tbody tr:last-child td { border-bottom: none; }
  .table.responsive td::before {
    content: attr(data-label); flex: none; margin-right: auto; padding-right: 10px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--muted); font-weight: 600; padding-top: 2px;
  }
  .table.responsive td[data-label=""]::before { display: none; }
  .table.responsive td[data-label=""] { justify-content: flex-end; }
  .table.responsive td:first-child { display: block; text-align: left; font-size: 15.5px; padding: 10px 0 8px; }
  .table.responsive td:first-child::before { display: none; }
  .table.responsive td:first-child a { font-weight: 600; }
  .table.responsive td small { display: inline; }
  .table.responsive td.actions { justify-content: flex-end; }
  .table.responsive tfoot tr { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; padding: 10px 14px; margin-top: 10px; background: var(--bg); border-radius: 10px; }
  .table.responsive tfoot th, .table.responsive tfoot td { display: inline; border: none; padding: 0; font-size: 14px; }
  .table.responsive tfoot th:empty, .table.responsive tfoot td:empty { display: none; }
  /* A card that only wraps a list drops its own chrome so the rows don't sit in a box inside a box. */
  .card:has(> .table-wrap > .table.responsive), .card:has(> .table.responsive) { background: transparent; border: none; box-shadow: none; padding: 0; }
  .card:has(> .table-wrap > .table.responsive) > .card-head, .card:has(> .table.responsive) > .card-head,
  .card:has(> .table-wrap > .table.responsive) > h3, .card:has(> .table.responsive) > h3 { padding: 0 2px; }
  .card:has(> .table-wrap > .table.responsive) > p.muted { padding: 0 2px; }
  .table-wrap:has(> .table.responsive) { overflow: visible; }
}

/* ---------- Tags & statuses ---------- */
.tag {
  display: inline-block; font-size: 11px; line-height: 1.5; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600; vertical-align: middle; border: 1px solid var(--line);
}
.tag-low { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.tag-wholesale { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.tag-retail { background: #f5f5f4; color: #57534e; border-color: #e7e5e4; }
.tag-sale, .tag-roast { background: #fdeee0; color: var(--brand-dark); border-color: #f6d9bf; }
.tag-receive, .tag-package, .tag-cancel { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 1.5; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-weight: 600; text-transform: capitalize; vertical-align: middle;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.status-open { background: #fef3c7; color: #92400e; }
.status-paid { background: #dbeafe; color: #1e40af; }
.status-fulfilled { background: #dcfce7; color: #166534; }
.status-cancelled { background: #f1f1f0; color: #6b7280; text-decoration: line-through; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 14px; }
label small { font-weight: 400; color: var(--muted); }
label input, label select, label textarea { display: block; width: 100%; margin-top: 6px; font-weight: 400; color: var(--ink); }
input, select, textarea {
  font: inherit; font-size: 14.5px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); min-height: 40px; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line-strong) 40%, var(--muted)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input[readonly], input[disabled] { background: var(--bg); color: var(--muted); box-shadow: none; }
input[readonly]:focus { border-color: var(--line-strong); }
input[type=date] { min-width: 150px; }
input[type=number] { font-variant-numeric: tabular-nums; }
input[type=search] { -webkit-appearance: none; }
select:not([multiple]) {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236f675f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
textarea { width: 100%; resize: vertical; min-height: 44px; line-height: 1.5; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; min-height: 0; padding: 0; margin: 0; accent-color: var(--brand); cursor: pointer; }
input[type=checkbox]:focus, input[type=radio]:focus { box-shadow: 0 0 0 3px var(--ring); border-radius: 4px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); cursor: pointer; margin-bottom: 12px; }
.check input { width: 17px; display: inline-block; margin-top: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { margin: 0; min-width: 120px; }
.inline-form .grow { flex: 1; min-width: 180px; }
.inline-form .btn { height: 40px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
form.inline select { min-height: 34px; padding-top: 5px; padding-bottom: 5px; font-size: 13.5px; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; min-width: 200px; }
.filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-sm);
}
.filters label { margin: 0; font-size: 12.5px; }
.filters label input, .filters label select { margin-top: 4px; }
.filters input[type=search] { min-width: 240px; flex: 1; }
.filters .btn { height: 40px; }
.inline-details summary { list-style: none; cursor: pointer; display: inline-flex; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details[open] { display: block; margin-top: 6px; }
.export-links { line-height: 2; }
.export-links a { display: inline-block; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; background: var(--bg); margin: 2px 2px 2px 0; }
.export-links a:hover { text-decoration: none; border-color: var(--line-strong); background: var(--card); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  line-height: 1; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--hover); border-color: color-mix(in srgb, var(--line-strong) 40%, var(--muted)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f1c7c4; }
.btn-danger:hover { background: #fef2f2; border-color: #e9a8a3; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: rgba(28,25,23,.06); color: var(--ink); border-color: transparent; }
.btn-block { display: flex; width: 100%; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 16px; margin-top: 12px; border-radius: 12px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
button.link { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; opacity: .85; }
button.link:hover { text-decoration: underline; }

/* ---------- Flash messages ---------- */
.flashes { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 500; border: 1px solid transparent; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.flashes .flash { margin-bottom: 0; }
.flash::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; margin-top: 7px; }
.flash-success { background: #ecfdf3; color: #166534; border-color: #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* ---------- Details list ---------- */
.details { display: grid; grid-template-columns: 140px 1fr; gap: 0 16px; margin: 0; }
.details dt { color: var(--muted); font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.details dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 500; }
.details dt:last-of-type, .details dd:last-of-type { border-bottom: none; }
.stats.inner + .details { margin-top: 6px; }

/* ---------- Alerts ---------- */
.alert-card { border-left: 4px solid var(--warn); }
.alert-list { margin: 0; padding-left: 0; list-style: none; }
.alert-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.alert-list li:last-child { border-bottom: none; }

/* ---------- Point of sale ---------- */
.item-row select { width: 100%; }
.item-row .item-desc { width: 100%; margin-top: 6px; display: none; }
.item-row.custom .item-desc { display: block; }
.item-row td { vertical-align: middle; }
.item-total { font-weight: 650; }
#items-table th:last-child, #items-table td:last-child { width: 40px; padding-left: 0; padding-right: 0; text-align: center; }
.item-remove { font-size: 18px; line-height: 1; width: 30px; }
@media (max-width: 700px) {
  /* Sale entry on a phone: each line becomes a block with the product on top and qty / price / total beneath. */
  #items-table, #items-table tbody { display: block; }
  #items-table thead { display: none; }
  #items-table tr.item-row { display: grid; grid-template-columns: 1fr 1fr 1fr 40px; gap: 8px 10px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--line); }
  #items-table tr.item-row:first-child { padding-top: 0; }
  #items-table td { display: block; padding: 0; border: none; width: auto; text-align: left; }
  #items-table td:first-child { grid-column: 1 / -1; }
  #items-table td::before { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
  #items-table td:nth-child(2)::before { content: "Qty"; }
  #items-table td:nth-child(3)::before { content: "Unit price"; }
  #items-table td:nth-child(4)::before { content: "Line"; }
  #items-table td:nth-child(2), #items-table td:nth-child(3), #items-table td:nth-child(4) { display: flex; flex-direction: column; justify-content: space-between; }
  #items-table td.item-total { padding-bottom: 9px; }
  #items-table .table input.small, #items-table input.small { width: 100%; }
  #items-table td:last-child { padding: 0; text-align: right; }
  #items-table .item-remove { height: 40px; width: 40px; }
  #add-item { margin-top: 12px; }
}
.totals-list { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 12px 0 16px; padding-top: 8px; }
.totals-list dt { color: var(--muted); }
.totals-list dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.totals-list .grand { font-size: 22px; color: var(--ink); border-top: 2px solid var(--line-strong); padding-top: 10px; font-weight: 700; letter-spacing: -.01em; }
.totals-list dt.grand { font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; align-items: flex-end; }

/* ---------- Locations ---------- */
.location-switch { margin: -4px 0 0; }
.location-switch label { color: var(--sidebar-ink); opacity: .6; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; margin: 0 0 4px; font-weight: 600; }
.location-switch select {
  background-color: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: var(--sidebar-ink); min-height: 38px; margin-top: 6px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f5f0ea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.location-switch select:hover { border-color: rgba(255,255,255,.3); }
.location-switch select:focus { border-color: rgba(255,255,255,.5); box-shadow: 0 0 0 3px rgba(255,255,255,.12); }
.location-switch select option { color: var(--ink); background: #fff; }
.location-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.location-row:last-of-type { border-bottom: none; }
.location-row .form-actions { align-items: center; }
tr.current-loc td { font-weight: 600; }
details.transfer { margin-top: 12px; }
details.transfer summary { list-style: none; cursor: pointer; display: inline-flex; }
details.transfer summary::-webkit-details-marker { display: none; }
details.transfer .inline-form { margin-top: 12px; padding: 14px; background: var(--bg); border-radius: var(--radius-sm); }
.grid-2.wide .table.compact th, .grid-2.wide .table.compact td { padding: 7px 6px; font-size: 13px; }

/* ---------- Auth / bare pages ---------- */
body.bare {
  background: var(--bg);
  background-image: radial-gradient(ellipse 70% 50% at 50% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 70%);
  background-repeat: no-repeat;
}
body.bare .content { margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 20px; max-width: 520px; }
.auth-box { width: 100%; max-width: 440px; margin: 0 auto; background: var(--card); padding: 36px 36px 32px; border-radius: 20px; border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.auth-box h1 { font-size: 24px; text-align: center; margin-bottom: 8px; }
.auth-box > p.muted { text-align: center; margin-bottom: 22px; }
.auth-box .flash { margin-bottom: 16px; }
.auth-box form { margin-top: 16px; }
.auth-box .btn-block { height: 44px; margin-top: 6px; font-size: 15px; }
.auth-box .btn:not(.btn-block) { margin-top: 8px; }

/* ---------- Receipt ---------- */
body.receipt { background: #fff; color: #000; }
.receipt-box { max-width: 640px; margin: 30px auto; padding: 24px; font-size: 14px; }
.receipt-box h1 { font-size: 22px; margin-bottom: 2px; }
.receipt-box h2 { font-size: 16px; margin-top: 18px; }
.receipt-box .footer { margin-top: 30px; text-align: center; }
.receipt-box img.logo { height: 56px; max-width: 240px; object-fit: contain; margin-bottom: 8px; }
@media print { .no-print { display: none; } .receipt-box { margin: 0; } }

/* ---------- Roaster: live screen, roast curves, profiles ---------- */
.roast-readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; margin-bottom: 14px; }
.roast-readouts .stat { background: var(--bg); border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 14px; }
.roast-readouts .stat .value { font-size: 24px; display: block; }
.roast-readouts .stat .sub { min-height: 18px; }
.roast-readouts .stat.primary { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 22%, transparent); }
.roast-readouts .stat.primary .value { font-size: 30px; }
.roast-alert { font-size: 22px; align-items: center; }
.roast-alert .btn { margin-left: auto; flex: none; }
.roast-next { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; padding: 10px 14px; margin-bottom: 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); font-size: 16px; }
.roast-next .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.roast-next .muted { margin-left: auto; font-variant-numeric: tabular-nums; }
dialog.confirm { border: 0; border-radius: var(--radius); padding: 22px 24px; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--ink); background: var(--card); font-size: 16px; line-height: 1.5; }
dialog.confirm::backdrop { background: rgba(28, 25, 23, .5); }
dialog.confirm p { margin: 0 0 18px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-actions .btn { height: 48px; padding: 0 20px; font-size: 16px; }
.roast-work { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 20px; }
.roast-side { min-width: 0; }
@media (min-width: 1240px) { .roast-work { grid-template-columns: minmax(0, 1fr) 340px; } .roast-side .roast-deck { margin-top: 0; } }
@media (min-width: 1000px) {
  #bc5-monitor:fullscreen .roast-work { grid-template-columns: minmax(0, 1fr) 340px; }
  #bc5-monitor:fullscreen .roast-deck { margin-top: 0; }
  #bc5-monitor:-webkit-full-screen .roast-work { grid-template-columns: minmax(0, 1fr) 340px; }
  #bc5-monitor:-webkit-full-screen .roast-deck { margin-top: 0; }
}
.roast-deck { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 14px; }
.dial { margin: 0; background: var(--bg); border-radius: var(--radius-sm); padding: 12px 14px; }
.dial-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.dial-head .label { font-weight: 700; font-size: 15px; margin: 0; }
.dial-head .label small { color: var(--muted); font-weight: 500; }
.dial-row { display: flex; gap: 8px; align-items: stretch; }
.dial-btn { flex: 1 1 0; min-width: 0; height: 64px; padding: 0; font-size: 17px; font-weight: 700; touch-action: manipulation; }
.dial-value { flex: 1.4 1 0; min-width: 0; height: 64px; margin: 0; text-align: center; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.dial-value::-webkit-outer-spin-button, .dial-value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.roast-events { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; }
.roast-events .btn { flex: 1 1 140px; height: 64px; font-size: 18px; font-weight: 700; touch-action: manipulation; }
.roast-events .btn.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.roast-toast { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--ink); color: #fff; font-weight: 600; }
.roast-toast .btn { margin-left: auto; flex: none; }
.roast-notes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.chip { height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.chip:hover { background: var(--hover); }
.chip:active { background: var(--brand-soft); }
.roast-note-form { display: flex; gap: 8px; flex: 1 1 260px; margin: 0; }
.roast-note-form input { flex: 1; min-width: 0; height: 44px; margin: 0; }
.roast-note-form .btn { height: 44px; flex: none; }
.roast-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.roast-foot .spacer { flex: 1; }
.roast-foot form { margin: 0; }
.roast-foot .btn { height: 44px; }
#bc5-monitor:fullscreen { overflow: auto; border-radius: 0; padding: 18px 22px; background: var(--card); }
#bc5-monitor:-webkit-full-screen { overflow: auto; border-radius: 0; padding: 18px 22px; background: var(--card); }
@media (pointer: coarse) {
  .roast-setup select, .roast-setup input { min-height: 48px; font-size: 16px; }
  .roast-setup .btn { height: 56px; font-size: 17px; }
  .roast-alert .btn { height: 52px; padding: 0 20px; font-size: 16px; }
}
@media (min-width: 700px) {
  .roast-readouts .stat .value { font-size: 30px; }
  .roast-readouts .stat.primary .value { font-size: 34px; }
}
.roast-setup { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 14px; align-items: end; margin-top: 12px; }
.roast-setup .btn { height: 46px; margin-bottom: 14px; }
.status-live { background: #dcfce7; color: #166534; }
.status-off { background: #f1f1f0; color: #6b7280; }
.stars { letter-spacing: 2px; color: var(--accent); white-space: nowrap; }
.step-rows { display: grid; gap: 8px; margin-bottom: 8px; }
.step-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.step-row input { margin: 0; }
.milestones td.est { color: var(--muted); font-style: italic; }

.rc-wrap { position: relative; }
.rc-svg { display: block; width: 100%; touch-action: pan-y; outline: none; }
.rc-svg:focus-visible { box-shadow: 0 0 0 3px var(--ring); border-radius: var(--radius-sm); }
.rc-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.rc-key { display: inline-flex; align-items: center; gap: 7px; }
.rc-swatch { display: inline-block; width: 16px; height: 0; border-top: 2px solid #8a8580; flex: none; }
.rc-swatch-bt { border-color: #d9541a; }
.rc-swatch-et { border-color: #257de0; }
.rc-swatch-ror { border-color: #008a17; }
.rc-swatch-ref { border-top-style: dashed; border-color: #8a8580; }
.rc-grid { stroke: var(--line); stroke-width: 1; }
.rc-tick { font-size: 11.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.rc-title { font-size: 11.5px; fill: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.rc-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.rc-bt { stroke: #d9541a; }
.rc-et { stroke: #257de0; }
.rc-ror { stroke: #008a17; }
.rc-ref { stroke: #8a8580; stroke-width: 1.5; stroke-dasharray: 5 4; }
.rc-dot { stroke: var(--card); stroke-width: 2; }
.rc-dot-bt { fill: #d9541a; }
.rc-dot-et { fill: #257de0; }
.rc-dot-ror { fill: #008a17; }
.rc-mark { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.rc-mark-label { font-size: 11.5px; fill: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.rc-cross { stroke: var(--ink); stroke-width: 1; opacity: .45; }
.rc-phase-1 { fill: #ecdcc8; }
.rc-phase-2 { fill: #cfa278; }
.rc-phase-3 { fill: #8f5a32; }
.rc-phase-label { font-size: 11.5px; font-weight: 600; fill: var(--ink); font-variant-numeric: tabular-nums; }
.rc-phase-label-3 { fill: #fff; }
.rc-dial { fill: var(--ink); stroke: var(--card); stroke-width: 2; }
.rc-dial-ref { fill: var(--card); stroke: #8a8580; stroke-width: 1.5; }
.rc-dial-ref-label { font-size: 11px; fill: #6f6a65; font-variant-numeric: tabular-nums; }
.rc-dial-label { font-size: 11.5px; fill: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.rc-tip {
  position: absolute; pointer-events: none; min-width: 180px; padding: 10px 12px; font-size: 12.5px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.rc-tip-time { color: var(--muted); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.rc-tip-row { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.rc-tip-row strong { font-variant-numeric: tabular-nums; }
.rc-tip-row span { color: var(--muted); }
.rc-tip-note { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); max-width: 220px; }
@media (max-width: 600px) {
  .roast-readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dial-btn { font-size: 15px; }
  .step-row { grid-template-columns: 92px minmax(0, 1fr) auto; }
}
.card-head label.inline-form { display: flex; align-items: center; gap: 10px; margin: 0; white-space: nowrap; min-width: 0; }
.card-head label.inline-form select { margin: 0; width: auto; max-width: min(420px, 60vw); }
.form-actions + form, form + form[data-confirm] { margin-top: 12px; }
.btn + h3 { margin-top: 24px; }
[hidden] { display: none !important; }
.flash-sim { background: #fef3c7; color: #92400e; border-color: #fde68a; align-items: center; margin-bottom: 20px; }
.flash-sim form { margin-left: auto; flex: none; }
.page-head .actions form { display: contents; }
