:root {
  --accent: #3B4A6B; --accent-dark: #2B3752; --tint: #E8ECF4; --bg: #F4F5F7; --card: #fff; --ink: #1E2330; --muted: #677089;
  --line: #DDE1E8; --ok: #2E7D4F; --ok-bg: #E3F3E9; --warn: #A15C00; --warn-bg: #FDF0DC; --bad: #B3261E; --bad-bg: #FBE4E2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4; }
a { color: var(--accent); }
h1 { font-size: 24px; margin: 4px 0 14px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }
header#top { position: sticky; top: 0; z-index: 10; background: var(--accent); color: #fff; display: flex; align-items: center;
  gap: 16px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-size: 17px; }
.brand img { width: 30px; height: 30px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
nav a { color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 8px; opacity: .85; }
nav a.on, nav a:hover { background: rgba(255,255,255,.16); opacity: 1; }
.count:not(:empty) { background: #F2B544; color: #2B2200; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; margin-left: 2px; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tiles a.tile { display: block; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-left: 5px solid var(--accent); border-radius: 12px; padding: 14px 16px; }
.tiles a.tile:hover { background: var(--tint); }
.tile b { font-size: 18px; display: block; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--accent); background: var(--accent);
  color: #fff; border-radius: 9px; padding: 9px 16px; font-size: 15px; cursor: pointer; text-decoration: none; min-height: 40px; }
.btn.light { background: #fff; color: var(--accent); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.bad { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 70px; }
input[type=checkbox] { width: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 15px; }
.pill.on { background: var(--accent); color: #fff; border-color: var(--accent); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--tint); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tag.waiting { background: var(--warn-bg); color: var(--warn); }
.tag.approved, .tag.match { background: var(--ok-bg); color: var(--ok); }
.tag.declined, .tag.over { background: var(--bad-bg); color: var(--bad); }
.tag.plain { background: var(--tint); color: var(--accent-dark); }
.cols { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check .tag { white-space: normal; }
.doc-item { display: block; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.doc-item:hover { background: var(--tint); }
.doc-item .spread { align-items: flex-start; }
.check { margin-top: 4px; font-size: 13px; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task input { width: 22px; height: 22px; margin-top: 1px; flex: none; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task .t-title { font-weight: 600; }
.overdue { color: var(--bad); font-weight: 600; }
.preview { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
img.preview { height: auto; max-height: 80vh; object-fit: contain; }
.docpage { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; }
.login { max-width: 420px; margin: 40px auto; }
.login .logo { text-align: center; margin-bottom: 14px; }
.login .logo img { width: 72px; height: 72px; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 14px; }
.names .pill { border-radius: 10px; padding: 14px 8px; text-align: center; }
.pin { font-size: 24px; letter-spacing: .3em; text-align: center; }
.note { background: var(--warn-bg); border: 1px solid #F0D3A6; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.note.ok { background: var(--ok-bg); border-color: #BFE3CC; }
.err { color: var(--bad); min-height: 20px; margin: 6px 0; }
.drop { display: block; border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; background: #fff; cursor: pointer; }
.drop.on { border-color: var(--accent); background: var(--tint); }
.drop b { display: block; font-size: 17px; margin-bottom: 4px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 10px; z-index: 50; max-width: 90vw; }
.crumbs { font-size: 14px; margin-bottom: 4px; }
.crumbs a { text-decoration: none; }
.empty { color: var(--muted); font-style: italic; padding: 6px 0; }
body:not(.owner) .owner-only { display: none !important; }
@media (max-width: 860px) {
  .cols, .docpage, .two { grid-template-columns: 1fr; }
  nav { width: 100%; margin-left: 0; gap: 2px; }
  nav a { white-space: nowrap; padding: 7px 9px; }
  main { padding: 12px; }
  .preview { height: 60vh; }
  table.cards thead { display: none; }
  table.cards tr { display: block; border-bottom: 1px solid var(--line); padding: 6px 0; }
  table.cards td { display: block; border: 0; padding: 2px 4px; }
  table.cards td.num { text-align: left; }
}
