:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1c1f24;
  --muted: #646b76;
  --border: #dde0e5;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --ok: #1a7f37;
  --warn: #b35900;
  --danger: #c62828;
  --new: #6e56cf;
  --await: #b35900;
  --submitted: #1f6feb;
  --printing: #0e7c86;
  --done: #1a7f37;
  --rejected: #c62828;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1b1e24;
    --surface-2: #23272f;
    --text: #e6e8eb;
    --muted: #9aa1ac;
    --border: #2e333c;
    --accent: #4c8dff;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; margin-right: auto; }
.brand small { font-weight: 500; color: var(--muted); margin-left: 6px; font-size: 13px; }
.nav { display: flex; gap: 4px; }
.nav a, .nav button {
  padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--text);
  background: none; border: 0; cursor: pointer;
}
.nav a.active { background: var(--surface-2); font-weight: 600; }
.status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--danger); }
.dot.warn { background: var(--warn); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--border); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--danger); }
.switch input:checked::after { left: 19px; }

.banner { padding: 10px 16px; background: var(--danger); color: #fff; font-weight: 600; text-align: center; }
.banner[hidden] { display: none; }

/* ---------- board ---------- */
main { padding: 16px; }
.tabs { display: none; gap: 6px; overflow-x: auto; padding-bottom: 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.tab {
  flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.tab .count { font-weight: 700; margin-left: 4px; }

.board { display: grid; grid-template-columns: repeat(6, minmax(230px, 1fr)); gap: 12px; align-items: start; }
.column { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.column h2 { display: flex; align-items: center; gap: 8px; margin: 2px 2px 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .03em; }
.column h2::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--col); }
.column h2 .count { margin-left: auto; color: var(--muted); font-weight: 600; }
.column .empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 0; }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); border-left: 4px solid var(--col);
  padding: 10px 12px; margin-bottom: 10px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-id { font-weight: 700; }
.card-time { color: var(--muted); font-size: 12px; }
.card-phone { font-size: 13px; }
.card-file { font-weight: 600; word-break: break-word; margin: 4px 0 2px; }
.card-meta { color: var(--muted); font-size: 13px; }
.card-amount { font-size: 20px; font-weight: 700; margin-top: 6px; }
.card-amount small { font-size: 12px; font-weight: 500; color: var(--muted); }
.shot { display: block; margin-top: 8px; width: 100%; max-height: 180px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; background: var(--surface-2); }
.note { margin-top: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.note.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.note.info { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.jobs { margin-top: 8px; display: grid; gap: 6px; }
.job { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-size: 13px; display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.job small { color: var(--muted); }
.job.failed, .job.check { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.job.failed small, .job.check small { color: var(--danger); }
.job.done small { color: var(--ok); }
.job-acts { display: flex; gap: 6px; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.note.web { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }
.note.mixed { background: color-mix(in srgb, var(--new) 12%, transparent); color: var(--new); }
.note.counter { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.links { display: flex; gap: 12px; margin-top: 8px; font-size: 13px; }
.links a { cursor: pointer; }

.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: 14px; min-height: 38px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ok); border-color: var(--ok); color: #fff; flex: 1 1 100%; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

.col-new { --col: var(--new); }
.col-await { --col: var(--await); }
.col-submitted { --col: var(--submitted); }
.col-printing { --col: var(--printing); }
.col-done { --col: var(--done); }
.col-rejected { --col: var(--rejected); }

@media (max-width: 700px) {
  .topbar { position: static; gap: 6px 12px; }
  .brand small { display: none; }
  .status-row { flex: 1 1 100%; order: 3; gap: 6px 14px; }
  .nav { margin-left: -10px; }
}

@media (max-width: 1100px) {
  .tabs { display: flex; }
  .board { display: block; }
  .column { display: none; background: none; padding: 0; }
  .column.active { display: block; }
  .column h2 { display: none; }
}

/* ---------- modal & lightbox ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: 12px; width: 100%; max-width: 420px; padding: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.dialog h3 { margin: 0 0 8px; }
.dialog p { margin: 0 0 12px; color: var(--muted); }
.dialog input[type=text], .dialog textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.dialog .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.dialog .chips button { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dialog ul { margin: 0; padding-left: 18px; max-height: 50vh; overflow: auto; font-size: 14px; }
.dialog li { margin-bottom: 6px; }
.dialog li small { color: var(--muted); display: block; }

.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .92); overflow: auto; display: flex; cursor: zoom-in; }
.lightbox img { margin: auto; max-width: 100%; max-height: 100vh; object-fit: contain; }
.lightbox.zoomed { cursor: zoom-out; }
.lightbox.zoomed img { max-width: none; max-height: none; width: 200%; }
.lightbox .close { position: fixed; top: 10px; right: 12px; font-size: 30px; color: #fff; background: none; border: 0; cursor: pointer; line-height: 1; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 70; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0, 0, 0, .25); max-width: calc(100% - 32px); }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- forms / pages ---------- */
.page { max-width: 860px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 17px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.field input { font-size: 15px; color: var(--text); padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
td.num, th.num { text-align: right; }
table input { width: 80px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.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(--border); border-radius: var(--radius); padding: 14px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input[type=date] { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0 0 18px; color: var(--muted); }
.login input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); margin-bottom: 12px; font-size: 16px; }
.login .btn { width: 100%; }
.login .error { color: var(--danger); font-size: 14px; margin-bottom: 10px; }
