:root {
  --bg: #0E1311; --surface: #151D1A; --ink: #EAF0EC; --muted: #9AA8A1; --line: #26322D;
  --green: #6CC655; --on-green: #0B170A; --teal: #4FB0BE; --brass: #C9A257; --red: #E24B4A; --amber: #EF9F27;
  --r: 12px; --tap: 44px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.45 "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); min-height: 100vh; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: rgba(14,19,17,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; }
.iconbtn { width: var(--tap); height: var(--tap); border: 0; background: transparent; font-size: 26px; line-height: 1; border-radius: 50%; }
.iconbtn:active { background: var(--surface); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.badge.off { color: var(--amber); border-color: var(--amber); }

main { padding: 12px 12px 0; max-width: 640px; margin: 0 auto; }
.logo { display: block; width: 180px; margin: 32px auto 8px; }
.muted { color: var(--muted); }
.err { color: var(--red); }

form#loginForm { display: flex; flex-direction: column; gap: 10px; }
input, select, textarea { width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; }
#code { font-size: 28px; letter-spacing: .3em; text-align: center; }
button.primary { min-height: var(--tap); border: 0; border-radius: 10px; background: var(--green); color: var(--on-green); font-weight: 600; padding: 0 16px; }
button.secondary { min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 0 14px; }
button:disabled { opacity: .5; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; min-height: 38px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; color: var(--muted); }
.tabs button.on { color: var(--ink); border-color: var(--green); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 10px 12px; cursor: pointer; }
.list li.urgent { border-color: var(--red); }
.row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row1 b { font-weight: 600; }
.sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; border: 1px solid transparent; }
.st-new { background: #2A2412; color: #F3C96B; }
.st-site { background: #1E2A33; color: #8CCBE0; }
.st-pending { background: #1E2A33; color: #8CCBE0; }
.st-callback { background: #2A2412; color: #F3C96B; }
.st-scheduled { background: #1A2A3E; color: #9CC4F5; }
.st-done { background: #16301B; color: #8FE08A; }
.st-lost, .st-spam { background: #2E1A1A; color: #E89A9A; }

.card { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 12px; margin-bottom: 10px; }
.card h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.card .lab { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.actions3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.actions3 a, .actions3 button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-decoration: none; font-size: 14px; }
.actions3 .ico { font-size: 20px; }
pre.notes { white-space: pre-wrap; font: inherit; margin: 0; color: var(--ink); }

.bottom { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: rgba(14,19,17,.96); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottom button { flex: 1; min-height: 56px; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; }
.bottom button.on { color: var(--green); }
.bottom .ico { font-size: 20px; }

.toast { position: fixed; left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); background: #222D28; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; z-index: 9; }
.toast.bad { border-color: var(--red); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted); border-top-color: var(--green); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

.actgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 4px 0 14px; }
.actgrid button { min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.actgrid button.done { background: var(--green); color: var(--on-green); border-color: var(--green); font-weight: 600; grid-column: 1 / -1; }
.actgrid button.danger { color: #E89A9A; }
.sheet { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.sheet h3 { margin: 0; font-size: 16px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 18px; background: transparent; }
.chips button.on { border-color: var(--green); color: var(--green); }
.sheet .row { display: flex; gap: 8px; }
.sheet .row > * { flex: 1; }
.preview { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 15px; }
.chk { display: flex; align-items: center; gap: 8px; }
.chk input { width: 22px; min-height: 22px; }

.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: 1fr 56px 84px 36px; gap: 6px; align-items: center; }
.line input { padding: 6px 8px; min-height: 40px; }
.line .x { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: #E89A9A; }
.total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 600; margin: 10px 0; }
.btnrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.btnrow.stack { grid-template-columns: 1fr; }
.btnrow.two { grid-template-columns: 1fr 1fr; }
.btnrow a, .btnrow button { min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); display: flex; align-items: center; justify-content: center; text-decoration: none; font-size: 15px; }
.paidmark { display: inline-block; border: 2px solid var(--green); color: var(--green); border-radius: 6px; padding: 2px 10px; font-weight: 600; letter-spacing: .05em; }

.mhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mhead b { font-size: 18px; font-weight: 600; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.tile .lab { color: var(--muted); font-size: 13px; }
.tile .val { font-size: 22px; font-weight: 600; }
.tile .val.pos { color: var(--green); }
.tile .val.neg { color: #E89A9A; }
.ops { display: flex; flex-direction: column; gap: 6px; }
.op { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 8px 12px; }
.op .t { min-width: 0; }
.op .t div:last-child { color: var(--muted); font-size: 13px; }
.op .a { white-space: nowrap; font-weight: 600; }
.op .a.in { color: var(--green); }
.op .a.mi { color: var(--teal); }
