:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #2563eb; --accent-text: #fff; --ok: #15803d; --ok-bg: #e7f6ec; --err: #b91c1c; --err-bg: #fdecec;
  --warn: #b45309; --run: #dc2626; --chip: #eef1f5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b1f27; --text: #e6e8ec; --muted: #9aa3b2; --line: #2b313c;
    --accent: #3b82f6; --ok: #4ade80; --ok-bg: #16301f; --err: #f87171; --err-bg: #3a1a1a;
    --warn: #fbbf24; --run: #f87171; --chip: #262c36;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1000px; margin: 0 auto; padding: 16px; }
h2 { font-size: 20px; margin: 18px 0 10px; }
h3 { font-size: 16px; margin: 0 0 10px; }
code { background: var(--chip); padding: 2px 6px; border-radius: 4px; word-break: break-all; }

/* шапка */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
       background: var(--card); border-bottom: 1px solid var(--line); padding: 8px 16px; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px; }
.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); }
.top nav a.on { background: var(--chip); font-weight: 600; }
.me { color: var(--muted); font-size: 13px; }
.timerbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px;
            background: var(--err-bg); border-bottom: 1px solid var(--line); }
.timerbar a { color: var(--text); }
.timerbar form { margin-left: auto; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--run); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* блоки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 0 0 12px; }
.card.narrow { max-width: 460px; margin: 40px auto; }
.card.highlight { border-color: var(--accent); }
.card.work.running { border-color: var(--run); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.flash ul { margin: 6px 0 0; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn { color: var(--warn); }
.hidden { display: none !important; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 0 8px; font-size: 13px; vertical-align: middle; }
.tag { font-size: 12px; background: var(--chip); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.run { background: var(--err-bg); color: var(--run); }

/* формы */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > input:not([type=date]):not([type=checkbox]), .row > select { flex: 1 1 200px; }
.quick .row + .row { margin-top: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.stack label > * { color: var(--text); font-size: 15px; }
.stack .row label { flex: 1 1 140px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 10px; }
legend { color: var(--muted); font-size: 13px; padding: 0 4px; }
.actions { margin-top: 4px; }
.inline { display: inline; }
.w4 { width: 4em; } .w8 { width: 8em; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--card); padding: 7px 14px; border-radius: 6px;
       cursor: pointer; white-space: nowrap; color: var(--text); }
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: var(--err); background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.timefield { display: flex; flex-direction: column; gap: 6px; flex: 1 1 260px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { border: 0; background: var(--chip); border-radius: 14px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-text); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.monthnav { display: flex; gap: 14px; align-items: center; margin: 4px 0 12px; }
.monthnav a { font-size: 18px; padding: 0 6px; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 6px; color: var(--text); background: var(--card); border: 1px solid var(--line); }
.tabs a.on { border-color: var(--accent); font-weight: 600; }

/* работы */
.work-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.work-head .client { font-size: 13px; color: var(--muted); }
.work-head .title { color: var(--text); font-weight: 600; }
.work-btns { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.done-form { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }

/* таблицы */
.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list th, .list td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.list th { font-size: 13px; color: var(--muted); font-weight: 500; }
.list tfoot td { font-weight: 600; border-bottom: 0; }
.list tr.open td { background: color-mix(in srgb, var(--chip) 50%, transparent); }
.list tr.archived td { opacity: .55; }
.list.edit input:not([type=checkbox]), .list.edit select { width: 100%; }
.right { text-align: right !important; } .center { text-align: center !important; } .nowrap { white-space: nowrap; }
.report .grand { font-size: 18px; text-align: right; margin-top: 16px; }

@media (max-width: 640px) {
  main { padding: 10px; }
  .list { font-size: 14px; display: block; overflow-x: auto; }
  .list.edit input:not([type=checkbox]) { min-width: 9em; }
  .list th, .list td { padding: 6px; }
  .work-head { flex-direction: column; }
}
@media print {
  .top, .timerbar, .noprint, .flash { display: none !important; }
  body { background: #fff; color: #000; }
  .list { border: 0; }
  a { color: #000; }
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.report h3 { margin-top: 20px; }
.bigcode { font-size: 34px; letter-spacing: 6px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 6px 0; }
