:root {
  --bg: #f5f3f0; --card: #fff; --ink: #1f1a17; --muted: #6f655d; --line: #e3ddd5;
  --accent: #6b1a24; --accent-ink: #fff; --ok: #1f6b35; --warn: #8a4b0c; --bad: #9b1c1c; --info: #1d4f7a;
  --radius: 10px;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171412; --card: #221e1b; --ink: #eee7df; --muted: #a79c92; --line: #3a332e;
    --accent: #c9505f; --ok: #6cc486; --warn: #e3a45c; --bad: #f08a8a; --info: #7fb3e3;
  }
}
:root[data-theme="dark"] { --bg: #171412; --card: #221e1b; --ink: #eee7df; --muted: #a79c92; --line: #3a332e; --accent: #c9505f; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: .2em 0 .6em; }
h1 small { font-size: .9rem; font-weight: 400; vertical-align: middle; }
h2 { font-size: 1.1rem; margin: 0 0 .8em; }
h3 { font-size: 1rem; margin: 1em 0 .5em; }
code { background: rgba(127,127,127,.15); padding: 1px 5px; border-radius: 4px; font-size: .88em; overflow-wrap: anywhere; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 16px; background: #2b0b10; color: #fff; min-height: 54px; flex-wrap: wrap; }
.logo { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.logo span { color: #e9d5a9; font-weight: 500; }
.tabs { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.tabs a { color: #e8dcd8; text-decoration: none; padding: 16px 10px; border-bottom: 3px solid transparent; }
.tabs a.on, .tabs a:hover { color: #fff; border-bottom-color: #e9d5a9; }
.who { display: flex; gap: 14px; align-items: center; font-size: .9rem; }
.who a, .who .linkish { color: #e8dcd8; }
.page { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; min-width: 0; }
.card.danger { border-color: rgba(155,28,28,.35); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }
.crumbs { margin: 0; font-size: .9rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: transparent; color: var(--bad); border-color: rgba(155,28,28,.4); }
.btn.sm { padding: 4px 10px; font-size: .88rem; }
.btn.block { width: 100%; margin-top: 6px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.inline-form { display: inline; margin: 0; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; max-width: 100%; }
textarea { width: 100%; }
input:not([type=checkbox]):not([type=radio]):not([type=file]) { width: 100%; }
input.w-sm { width: 110px !important; }
input.low { border-color: var(--warn); }
label { display: block; font-weight: 600; font-size: .9rem; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
label.inline { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.stack { display: flex; flex-direction: column; gap: 10px; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; margin-bottom: 4px; }
.row { display: flex; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; border: 1px solid; }
.flash-ok { background: rgba(31,107,53,.1); border-color: rgba(31,107,53,.3); }
.flash-warn { background: rgba(138,75,12,.1); border-color: rgba(138,75,12,.3); }
.flash-info { background: rgba(29,79,122,.08); border-color: rgba(29,79,122,.25); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.kpi span { color: var(--muted); font-size: .85rem; }
.kpi strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 8px; }
.tbl td { border-bottom: 1px solid var(--line); padding: 9px 8px; vertical-align: top; }
.tbl.compact td { padding: 6px 8px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; }
.tbl td.low { color: var(--warn); font-weight: 700; }
.tbl .pos { color: var(--ok); } .tbl .neg { color: var(--bad); }
tr.dim td { opacity: .55; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.st-pending { background: rgba(127,127,127,.15); color: var(--muted); }
.st-new { background: rgba(29,79,122,.12); color: var(--info); }
.st-in_production { background: rgba(138,75,12,.13); color: var(--warn); }
.st-engraved { background: rgba(107,26,36,.12); color: var(--accent); }
.st-ready { background: rgba(31,107,53,.14); color: var(--ok); }
.st-completed { background: rgba(31,107,53,.08); color: var(--ok); border-color: rgba(31,107,53,.3); }
.st-canceled { background: rgba(155,28,28,.1); color: var(--bad); text-decoration: line-through; }
.pay-paid { background: rgba(31,107,53,.14); color: var(--ok); }
.pay-unpaid { background: rgba(138,75,12,.12); color: var(--warn); }
.pay-comp { background: rgba(29,79,122,.12); color: var(--info); }
.pay-refunded { background: rgba(127,127,127,.15); color: var(--muted); }
.em-sent { background: rgba(31,107,53,.14); color: var(--ok); }
.em-failed { background: rgba(155,28,28,.12); color: var(--bad); }
.em-queued { background: rgba(127,127,127,.15); color: var(--muted); }
.chip { display: inline-block; padding: 0 6px; border-radius: 5px; background: rgba(127,127,127,.14); font-size: .8rem; margin-right: 3px; }
.note-dot { color: var(--warn); }
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters input[type=search] { flex: 1; min-width: 200px; width: auto !important; }
.bulkbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.bulkbar [data-selcount] { font-weight: 600; min-width: 90px; }
.stage-list { list-style: none; margin: 0; padding: 0; }
.stage-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.stage-list li:last-child { border: 0; }
.item { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item-preview { width: 100%; height: auto; max-height: 220px; object-fit: contain; background: #f3ede4; border-radius: 8px; }
.item-meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { padding: 2px 0; font-size: 1.02rem; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.sum { margin: 12px 0 0 auto; max-width: 280px; }
.sum div { display: flex; justify-content: space-between; } .sum dt, .sum dd { margin: 0; }
.sum .grand { font-weight: 700; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.timeline li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.status-steps { display: flex; flex-direction: column; gap: 4px; }
.radio-card { display: flex; gap: 8px; align-items: center; font-weight: 500; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--accent); background: rgba(107,26,36,.07); }
.note { background: rgba(138,75,12,.08); padding: 8px 10px; border-radius: 7px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.thumb { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); font-size: .85rem; }
.thumb img { width: 100%; height: 110px; object-fit: contain; background: #f3ede4; border-radius: 7px; }
.warn { color: var(--warn); font-style: normal; font-weight: 700; }
.tmpl { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.tmpl summary { cursor: pointer; }
.tmpl[open] { display: flex; flex-direction: column; gap: 8px; }
.email-body { white-space: pre-wrap; font: inherit; background: rgba(127,127,127,.07); padding: 14px; border-radius: 8px; }
.art-list { display: grid; gap: 10px; margin-bottom: 14px; }
.art { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: center; }
.art img { width: 140px; background: #f3ede4; border-radius: 7px; }
.art.dim { opacity: .5; }
.bars .bar { display: inline-block; height: 10px; width: calc(var(--v) * 120px); min-width: 2px; background: var(--accent); border-radius: 3px; vertical-align: middle; margin-right: 6px; }
.daychart { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-bottom: 20px; overflow-x: auto; }
.day { flex: 1 0 18px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.day span { width: 100%; max-width: 28px; height: calc(var(--v) * 100%); min-height: 2px; background: var(--accent); border-radius: 3px 3px 0 0; }
.day small { position: absolute; bottom: -18px; font-size: .65rem; color: var(--muted); white-space: nowrap; }
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 900px) {
  .grid2, .grid-main { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item { grid-template-columns: 1fr; }
  .topbar { gap: 0 16px; padding-top: 8px; }
  .logo { order: 1; }
  .who { order: 2; margin-left: auto; }
  .tabs { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 8px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { padding: 10px 8px; white-space: nowrap; }
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .03em; }
.row-actions { white-space: nowrap; display: flex; gap: 10px; }
input.w-date { width: 180px !important; }
.roles dt { font-weight: 700; margin-top: 8px; }
.roles dd { margin: 2px 0 0; color: var(--muted); }
.filters label { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.filters label > input, .filters label > select { margin-top: 0; }
.who .me { color: #e8dcd8; }
.entry-items { list-style: none; margin: 0 0 12px; padding: 0; }
.entry-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.entry-thumb svg { width: 100%; height: auto; max-height: 120px; display: block; }
.entry-text { margin: 4px 0 8px; overflow-wrap: anywhere; }
.btn.danger.sm { padding: 4px 10px; }
@media (max-width: 600px) { .entry-item { grid-template-columns: 1fr; } }
