:root {
  --bg: #f4f6f8; --surface: #fff; --text: #1d2733; --muted: #64707d; --line: #dfe4ea;
  --accent: #1f5f8b; --accent-ink: #fff; --accent-soft: #e6eff6;
  --ok-bg: #e7f5ec; --ok: #1c6b3b; --err-bg: #fdecec; --err: #a12626; --warn-bg: #fff6df; --warn: #7a5600;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171d; --surface: #1b222b; --text: #e3e8ee; --muted: #94a0ad; --line: #2c3540;
    --accent: #5ca3d6; --accent-ink: #0d1620; --accent-soft: #1f3243;
    --ok-bg: #173324; --ok: #8fd9ab; --err-bg: #3a1c1c; --err: #f2a3a3; --warn-bg: #3a2f14; --warn: #f0cf85;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }
main.narrow { max-width: 420px; padding-top: 10vh; }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.05rem; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.topbar nav a:hover { color: var(--text); background: var(--bg); }
.topbar nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.who { display: flex; gap: 12px; align-items: center; font-size: .9rem; }
.linkish { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card.auth { padding: 28px; }
.narrow-card { max-width: 640px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head > div { display: flex; gap: 8px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; color: var(--muted); font-size: .85rem; }
.stat span { display: block; font-size: 1.6rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 14px; }
input, select, textarea { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; font-weight: 400;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
label.check { display: flex; align-items: center; gap: 8px; padding-top: 26px; }
label.check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 0; margin: 0 0 16px; }
legend { font-size: .85rem; color: var(--muted); padding: 0 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { margin: 0; flex: 1 1 150px; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.btn { display: inline-block; padding: 9px 16px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { border-color: var(--muted); }
.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); border-color: var(--err); background: transparent; }
.btn.full { width: 100%; margin-top: 4px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 7px; margin-bottom: 14px; font-size: .92rem; word-break: break-word; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--err-bg); color: var(--err); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }

/* Tables */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tfoot td { font-weight: 700; border-bottom: 0; }
.table.compact td { padding: 8px 6px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.inactive td { opacity: .55; }
.desc { color: var(--muted); font-size: .88rem; margin-top: 2px; }
td.desc { color: var(--text); font-size: inherit; max-width: 460px; }
.total-line { margin-top: 0; }
.badge { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); }
.badge-admin { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.bar { height: 4px; background: var(--bg); border-radius: 2px; margin-top: 6px; max-width: 260px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

@media (max-width: 760px) {
  .grid-2, .row { grid-template-columns: 1fr; }
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat span { font-size: 1.25rem; }
  label.check { padding-top: 0; }
  .topbar-inner { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .topbar nav { order: 3; flex-basis: 100%; }
}

/* Issues */
.small { font-size: .85rem; }
.badge.status-pending { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.status-approved { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.status-in_progress { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.badge.status-done { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.status-rejected { background: var(--err-bg); color: var(--err); border-color: transparent; }
.badge.prio-low { color: var(--muted); }
.badge.prio-high { color: var(--warn); border-color: currentColor; }
.badge.prio-urgent { background: var(--err); color: #fff; border-color: transparent; }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--err); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 18px; }
.count-plain { color: var(--muted); font-weight: 400; font-size: .85em; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; align-items: center; }
.tabs a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 7px; border: 1px solid transparent; }
.tabs a.active { background: var(--surface); border-color: var(--line); color: var(--text); font-weight: 600; }
.tabs .tab-toggle { margin-left: auto; font-size: .85rem; }
.issue-link { font-weight: 600; text-decoration: none; color: var(--text); }
.issue-link:hover { color: var(--accent); text-decoration: underline; }
.issue-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.issue-body { white-space: normal; line-height: 1.6; padding: 14px 16px; background: var(--bg); border-radius: 8px; margin: 12px 0 18px; word-break: break-word; }
.issue-body.clamp { max-height: 9.6em; overflow: hidden; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 18px; color: var(--muted); }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); }
.timeline li.done { color: var(--text); }
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.timeline li.current { color: var(--text); font-weight: 600; }
.timeline li.current::before { border-color: var(--accent); background: var(--accent-soft); }
.timeline li.rejected { color: var(--err); }
.timeline li.rejected::before { background: var(--err); border-color: var(--err); }
.timeline .note { font-weight: 400; color: var(--text); background: var(--bg); padding: 8px 12px; border-radius: 7px; margin-top: 6px; }
.review { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.reject-form { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.reject-form input { margin: 0; }
.withdraw { margin-top: 16px; }
.copy-link { margin-top: 8px; font-family: ui-monospace, monospace; font-size: .82rem; }
label.inline-check { padding-top: 0; font-weight: 400; }
.side-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
@media (max-width: 760px) { .side-grid { grid-template-columns: 1fr; } .tabs .tab-toggle { margin-left: 0; } }
