:root {
  --bg: #f5f2ee;
  --panel: #ffffff;
  --ink: #26211d;
  --muted: #7d726a;
  --line: #e6dfd7;
  --accent: #6b4f3a;
  --accent-ink: #fff;
  --ok: #2f6b4f;
  --ok-bg: #e6f2eb;
  --warn: #8a5a10;
  --warn-bg: #fbf0dc;
  --err: #a33a2c;
  --err-bg: #fbe7e3;
  --am: #c98b2b;
  --pm: #4b5a8a;
  --radius: 10px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 24px; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 58px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.top .brand { font-weight: 650; letter-spacing: .02em; white-space: nowrap; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav a { color: #d9d0c8; text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.top .badge { background: #e7b36a; color: var(--ink); border-radius: 999px; font-size: 12px; padding: 1px 7px; margin-left: 4px; font-weight: 650; }
.top form { margin: 0; }
.top .who { color: #bfb4aa; font-size: 13px; white-space: nowrap; }
.top button.link { background: none; border: 0; color: #d9d0c8; cursor: pointer; font: inherit; }

main { max-width: 1320px; margin: 0 auto; padding: 28px 24px 80px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel + .panel { margin-top: 16px; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #cfc5bb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 13px; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #c9a98b; outline-offset: 1px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.list td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #faf8f5; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 999px; text-decoration: none; color: var(--ink); border: 1px solid transparent; }
.tabs a.on { background: #fff; border-color: var(--line); font-weight: 600; }

.status { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: #eee6de; color: var(--ink); white-space: nowrap; }
.status.new { background: #e7b36a; }
.status.in_review { background: #f2dfc4; }
.status.sent { background: #dfe6f3; color: #2d3f6b; }
.status.ordered { background: var(--ok-bg); color: var(--ok); }
.status.closed { background: #eee; color: #777; }
.status.awaiting_payment { background: #f1e4f2; color: #6b3570; }

.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #f0ebe5; margin: 2px 4px 2px 0; }

/* Case page */
.case-grid { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .case-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 0 0 4px; font-weight: 500; }
.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.photos a { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #eee; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sticky { position: sticky; top: 78px; }

.step-group { border-top: 1px solid var(--line); padding: 14px 0 6px; }
.step-group:first-child { border-top: 0; padding-top: 0; }
.prow { display: grid; grid-template-columns: 24px 44px 1fr auto; gap: 12px; align-items: center; padding: 8px; border-radius: 8px; }
.prow.on { background: #faf6f1; }
.prow.conflict { background: var(--err-bg); }
.prow img, .prow .ph { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: #eee6de; }
.prow .t { font-weight: 600; }
.prow .meta { font-size: 12px; color: var(--muted); }
.prow .unsuit { font-size: 12px; color: var(--warn); font-weight: 600; }
.prow .auto { font-size: 11px; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-left: 6px; }
.prow .extra { grid-column: 3 / -1; display: grid; grid-template-columns: 70px 150px 1fr; gap: 8px; }
@media (max-width: 640px) { .prow .extra { grid-template-columns: 70px 1fr; } .prow .extra input[data-act=note] { grid-column: 1 / -1; } }
.slots { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.slots button { border: 0; background: #fff; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.slots button + button { border-left: 1px solid var(--line); }
.slots button.on.am { background: var(--am); color: #fff; }
.slots button.on.pm { background: var(--pm); color: #fff; }
.slots button:disabled { cursor: default; opacity: .4; }

.issues { display: grid; gap: 8px; margin-bottom: 14px; }
.issue { padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.issue.err { background: var(--err-bg); color: var(--err); }
.issue.warn { background: var(--warn-bg); color: var(--warn); }
.issue.ok { background: var(--ok-bg); color: var(--ok); }

.routine { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.routine ol { margin: 0; padding-left: 18px; font-size: 14px; }
.routine h3 { margin: 0 0 6px; font-size: 13px; }
.routine .am h3 { color: var(--am); } .routine .pm h3 { color: var(--pm); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.total { font-size: 18px; font-weight: 650; }

/* Products */
.pcard { display: grid; grid-template-columns: 56px 1fr; gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.pcard:first-child { border-top: 0; }
.pcard img, .pcard .ph { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #eee6de; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; }
.pgrid label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.saved { color: var(--ok); font-size: 13px; font-weight: 600; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .panel { width: 100%; max-width: 380px; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
textarea.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; min-height: 60vh; }
.photos figure { margin: 0; }
.photos figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; text-align: center; }
.kv dd.flag { color: var(--warn); }
.kv dd.flag::before { content: "⚑ "; }

select.prio-very-important { border-color: #c98b2b; background: #fdf3e2; font-weight: 600; }
select.prio-important { border-color: #8aa0c8; background: #eef2fa; }
select.prio-good { background: #f3f5f2; }
.prio-tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.prio-tag.prio-very-important { background: #fdf3e2; color: #8a5a10; }
.prio-tag.prio-important { background: #eef2fa; color: #2d3f6b; }
.prio-tag.prio-good { background: #eef3ec; color: #2f6b4f; }
.pcard .badge { background: #fbe3c6; color: #7a4a12; border-radius: 999px; font-size: 11px; padding: 1px 8px; margin-left: 6px; font-weight: 650; }
