:root {
  color-scheme: light dark;
  --bg: #f4efe4;
  --panel: #fffdf8;
  --ink: #1b2a23;
  --muted: #62706a;
  --line: #ddd5c3;
  --green: #10241c;
  --green-2: #1c3a2c;
  --brass: #b08d57;
  --gold: #c9a227;
  --accent: #1c3a2c;
  --accent-ink: #fff;
  --ok: #2e7d4f;
  --warn: #a8710b;
  --bad: #b3352e;
  --ok-bg: #e3f1e8;
  --warn-bg: #f7ecd2;
  --bad-bg: #f6dcda;
  --shadow: 0 1px 2px rgba(16, 36, 28, 0.08), 0 4px 14px rgba(16, 36, 28, 0.06);
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1a14;
    --panel: #12261d;
    --ink: #efe7d8;
    --muted: #a3ada5;
    --line: #26412f;
    --accent: #c9a227;
    --accent-ink: #10241c;
    --ok: #6fcf97;
    --warn: #e6b94d;
    --bad: #f08a82;
    --ok-bg: #153524;
    --warn-bg: #3a2f10;
    --bad-bg: #3e1d1b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body.has-sheet { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; }
.ok-text { color: var(--ok); }
.form-error { color: var(--bad); min-height: 1.2em; font-size: 14px; }

/* ------------------------------------------------------------------ buttons / fields */
.btn {
  appearance: none; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--brass); }
.btn:focus-visible, .chip:focus-visible, .tab:focus-visible, .icon-btn:focus-visible, .az-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.danger-text { color: var(--bad); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn { appearance: none; font: inherit; border: 0; background: transparent; color: inherit; width: 44px; height: 44px; border-radius: 10px; cursor: pointer; font-size: 18px; position: relative; display: inline-grid; place-items: center; }
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
input[type=text], input[type=search], input[type=password], input[type=number], select, textarea {
  font: inherit; width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
textarea { resize: vertical; min-height: 80px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.row-end { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: calc(8px + var(--safe-t)) 16px 8px; background: var(--green); color: #efe7d8; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1.5px solid var(--gold); border-radius: 6px; font-family: Georgia, serif; font-size: 14px; letter-spacing: 1px; color: #efe7d8; }
.mark.big { width: 64px; height: 64px; font-size: 24px; margin: 0 auto 14px; background: var(--green); }
.brand-name { font-family: Georgia, "Times New Roman", serif; font-size: 22px; }
.tabs { display: flex; gap: 4px; margin-left: 16px; flex: 1; }
.tab { display: flex; align-items: center; gap: 8px; padding: 0 14px; min-height: 44px; border-radius: 10px; text-decoration: none; color: #efe7d8cc; font-weight: 600; position: relative; }
.tab:hover { background: rgba(255, 255, 255, 0.08); }
.tab.on { background: rgba(255, 255, 255, 0.14); color: #fff; }
.tab.alert::after { content: ""; position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.top-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.top-right .icon-btn { color: #efe7d8; }
.printer-chip { font-size: 13px; font-weight: 600; text-decoration: none; padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.printer-chip::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; background: #8a948d; }
.printer-chip.ok::before { background: #6fcf97; }
.printer-chip.warn::before { background: #e6b94d; }
.printer-chip.bad::before { background: #f08a82; }
.bell .badge { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--gold); color: #10241c; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

.view { max-width: 980px; margin: 0 auto; padding: 18px 16px calc(40px + var(--safe-b)); }
.page-title { font-family: Georgia, "Times New Roman", serif; font-size: 28px; font-weight: 500; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 180px; }

/* ------------------------------------------------------------------ cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.card h2 { font-size: 18px; margin-bottom: 8px; }
.card.attention { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--panel)); }
.move-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.move-row p { margin-top: 2px; }

/* ------------------------------------------------------------------ chips / A-Z */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; align-items: center; -webkit-overflow-scrolling: touch; }
.chip { appearance: none; font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); display: inline-flex; align-items: center; gap: 8px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip .count { font-size: 12px; opacity: 0.7; }
.archived-toggle { margin-left: auto; white-space: nowrap; font-size: 14px; }
.az { display: flex; flex-wrap: wrap; gap: 3px; margin: 2px 0 12px; }
.az-btn { appearance: none; font: inherit; font-weight: 700; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: default; padding: 0; }
.az-btn.on { background: var(--green); border-color: var(--green); color: #fff; cursor: pointer; }

/* ------------------------------------------------------------------ file list */
.loc { margin-bottom: 26px; }
.loc-head { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 22px; padding: 6px 0; border-bottom: 2px solid var(--brass); margin-bottom: 8px; }
.loc-head .muted { font-family: inherit; font-size: 14px; }
.letter-head { font-weight: 800; color: var(--brass); font-size: 15px; padding: 10px 0 2px; scroll-margin-top: 80px; }
.file { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; }
.file.to-move { border-color: var(--gold); }
.letter-tile { width: 52px; height: 52px; border-radius: 8px; background: #000; color: #fff; display: grid; place-items: center; font-family: "Arial Black", Arial, sans-serif; font-weight: 900; font-size: 28px; }
.file h3 { font-size: 17px; word-break: break-word; }
.file-contents { color: var(--muted); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.file-where { font-size: 14px; margin-top: 2px; }
.file-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--muted); margin-top: 4px; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ink); }
.empty { text-align: center; padding: 50px 16px; }
.empty-art { width: 96px; height: 96px; margin: 0 auto 14px; display: grid; place-items: center; background: #000; color: #fff; border-radius: 14px; font: 900 30px "Arial Black", Arial, sans-serif; }
.empty h2 { margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

/* ------------------------------------------------------------------ places / printers */
.place { display: flex; align-items: center; gap: 12px; }
.place-main { flex: 1; min-width: 0; }
.place-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.range-row { display: flex; align-items: center; gap: 10px; }
.letter-in { width: 64px !important; text-align: center; text-transform: uppercase; }
.device-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.device-head h3 { font-size: 18px; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: #8a948d; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.form-grid .row-end, .form-grid .check { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.field > span { font-weight: 600; color: var(--muted); }
.custom-size { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.custom-size[hidden] { display: none; }
.steps { padding-left: 20px; margin: 8px 0 14px; display: grid; gap: 6px; }
.pair-row { display: flex; gap: 10px; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 3px; text-transform: uppercase; max-width: 240px; font-size: 18px !important; }
.job { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.job-main { flex: 1; min-width: 0; word-break: break-word; }

/* ------------------------------------------------------------------ forms inside sheets */
.form { display: grid; gap: 6px; }
.form > label { font-weight: 600; font-size: 14px; margin-top: 8px; color: var(--muted); }
.confirm-text { font-size: 17px; margin-bottom: 8px; }
.big-letter { width: 110px; height: 110px; margin: 4px auto 14px; background: #000; color: #fff; display: grid; place-items: center; border-radius: 14px; font: 900 64px "Arial Black", Arial, sans-serif; }
.result-title { text-align: center; font-size: 22px; font-weight: 700; word-break: break-word; }
.result-where { text-align: center; font-size: 19px; margin: 10px 0; }
.sheet-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.note { padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; border: 1px solid var(--line); }
.note.unread { border-color: var(--gold); }
.note.error { background: var(--bad-bg); } .note.warn { background: var(--warn-bg); }
.note p { margin: 2px 0; }

/* ------------------------------------------------------------------ sticker preview */
.preview-box { border: 1px dashed var(--line); border-radius: 12px; padding: 10px; margin-top: 10px; }
.preview-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.preview-stage { background: #c9c9c9; border-radius: 8px; padding: 12px; display: grid; place-items: center; overflow: hidden; }
.preview-wrap { background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); overflow: hidden; }
.preview-frame { border: 0; background: #fff; display: block; transform-origin: top left; pointer-events: none; }

/* ------------------------------------------------------------------ sheets + toasts */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(5, 12, 9, 0.6); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.sheet { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border-radius: 18px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5); }
.sheet.wide { max-width: 620px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 20px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.sheet-head h2 { font-size: 20px; font-family: Georgia, serif; font-weight: 500; }
.sheet-body { padding: 8px 20px 20px; }
.toasts { position: fixed; left: 0; right: 0; bottom: calc(18px + var(--safe-b)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: #17261f; color: #efe7d8; padding: 12px 18px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); max-width: 520px; transition: opacity 0.3s, transform 0.3s; }
.toast.ok { border-left: 5px solid #6fcf97; } .toast.error { border-left: 5px solid #f08a82; } .toast.info { border-left: 5px solid var(--gold); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ------------------------------------------------------------------ sign in */
.login-body { display: grid; place-items: center; background: radial-gradient(circle at 50% 20%, #10241c 0%, #0b1a14 100%); color: #efe7d8; padding: 20px; }
.login { width: 100%; max-width: 360px; text-align: center; }
.login h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 34px; margin-bottom: 4px; }
.login .muted { color: #a3ada5; margin-bottom: 22px; }
.login form { display: grid; gap: 10px; }
.login input[type=password] { background: #12261d; border-color: #26412f; color: #efe7d8; text-align: center; font-size: 18px; min-height: 52px; }
.login .btn.primary { background: var(--gold); color: #10241c; border-color: var(--gold); min-height: 52px; font-size: 17px; }
.login .form-error { color: #f08a82; }

/* ------------------------------------------------------------------ narrow screens: tabs move to the bottom like an app */
@media (max-width: 720px) {
  .topbar { gap: 8px; padding-left: 12px; padding-right: 8px; }
  .brand-name { font-size: 20px; }
  .printer-chip { max-width: 150px; font-size: 12px; padding: 6px 10px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 30; background: var(--green); padding: 6px 8px calc(6px + var(--safe-b)); justify-content: space-around; box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3); }
  .tab { flex-direction: column; gap: 2px; padding: 4px 12px; min-height: 52px; font-size: 12px; flex: 1; justify-content: center; }
  .tab-icon { font-size: 20px; }
  .view { padding-bottom: calc(100px + var(--safe-b)); }
  .file { grid-template-columns: 44px 1fr; }
  .letter-tile { width: 44px; height: 44px; font-size: 24px; }
  .file-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .overlay { align-items: flex-end; padding: 0; }
  .sheet, .sheet.wide { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; }
  .pair-row { flex-direction: column; }
  .code { max-width: none; }
  .toasts { bottom: calc(80px + var(--safe-b)); }
}
@media (min-width: 721px) { .tab-icon { display: none; } }
@media print { .topbar, .toasts { display: none; } }
