:root {
  --bg: #f6f5f0;
  --card: #ffffff;
  --sunk: #efede6;
  --text: #1d1f1a;
  --muted: #6a6c63;
  --line: rgba(29, 31, 26, 0.12);
  --line-strong: rgba(29, 31, 26, 0.24);
  --accent: #2f6b35;
  --accent-ink: #ffffff;
  --accent-soft: #e3efdc;
  --accent-text: #24572a;
  --warn-soft: #fbefd6;
  --warn-text: #84520a;
  --danger: #b3261e;
  --danger-soft: #fbe5e2;
  --blue-soft: #e2edf8;
  --blue-text: #1d4f86;
  --radius: 12px;
  --tap: 44px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161714;
    --card: #20221e;
    --sunk: #2a2c27;
    --text: #ecebe4;
    --muted: #a3a59b;
    --line: rgba(236, 235, 228, 0.12);
    --line-strong: rgba(236, 235, 228, 0.26);
    --accent: #7cc283;
    --accent-ink: #10230f;
    --accent-soft: #263a25;
    --accent-text: #a6dba9;
    --warn-soft: #3b2f17;
    --warn-text: #f0c46d;
    --danger: #f2877f;
    --danger-soft: #3d2120;
    --blue-soft: #1f3044;
    --blue-text: #9cc4ee;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; }
h1, h2 { font-weight: 600; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 17px; margin-bottom: 8px; }
p { margin: 0; }
pre { white-space: pre-wrap; font: 14px/1.5 inherit; margin: 12px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hint { font-size: 14px; color: var(--muted); }
.err { color: var(--danger); font-size: 14px; }
.warn-text { color: var(--warn-text); }
.nowrap { white-space: nowrap; }

/* ---------- shell: menu on the side on a tablet, at the bottom on a phone ---------- */

.shell { min-height: 100vh; }
.side { display: none; }
.main {
  padding: 16px 16px calc(88px + env(safe-area-inset-bottom));
  max-width: 1100px;
  margin: 0 auto;
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: var(--tap); padding: 4px 0; font-size: 12px; text-decoration: none; color: var(--muted); border-radius: 10px;
}
.bottom a.on { color: var(--accent-text); }
.bottom svg, .side svg { width: 22px; height: 22px; fill: currentColor; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); }
  .bottom { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 2px;
    position: sticky; top: 0; height: 100vh; padding: 20px 14px;
    border-right: 1px solid var(--line); background: var(--card);
  }
  .side a {
    display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 12px;
    border-radius: 10px; text-decoration: none; color: var(--text);
  }
  .side a.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
  .side .brand { font-weight: 700; margin-bottom: 14px; padding: 0 8px; }
  .side .side-account { margin-top: auto; color: var(--muted); font-size: 14px; }
  .main { padding: 24px 32px 48px; }
}

/* ---------- blocks ---------- */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card.narrow, form.narrow { max-width: 640px; }
.warn-card { background: var(--warn-soft); color: var(--warn-text); border-color: transparent; }
.warn-card p { margin-bottom: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.cols { display: grid; gap: 14px; }
.cols .card { margin: 0; }
@media (min-width: 700px) { .cols { grid-template-columns: 1fr 1fr; margin-bottom: 14px; } }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 10px; }
.inline .grow { flex: 1 1 160px; }
.inline .err { flex-basis: 100%; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; text-decoration: none; }

.metrics { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.metric p { font-size: 13px; color: var(--muted); }
.metric b { display: block; font-size: 24px; font-weight: 650; letter-spacing: -0.01em; margin: 2px 0; }
.metric small { font-size: 13px; color: var(--muted); }
.big-num { font-size: 20px; font-weight: 600; margin: 8px 0 4px; }

.tag {
  display: inline-block; font-size: 12px; line-height: 1.6; padding: 0 8px; border-radius: 999px;
  background: var(--sunk); color: var(--muted); font-weight: 600; white-space: nowrap;
}
.tag.big { font-size: 14px; padding: 2px 12px; }
.tag.warn, .st-collecting { background: var(--warn-soft); color: var(--warn-text); }
.tag.accent, .st-laid { background: var(--blue-soft); color: var(--blue-text); }
.st-ready, .st-open { background: var(--accent-soft); color: var(--accent-text); }

.bar { display: block; height: 8px; border-radius: 4px; background: var(--sunk); overflow: hidden; margin: 8px 0 6px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.bline { display: block; text-decoration: none; padding: 12px 0; border-top: 1px solid var(--line); }
.card .bline:first-of-type { border-top: 0; padding-top: 4px; }
.list .bline:first-child { border-top: 0; }
.bline .row { justify-content: flex-start; align-items: center; }
.bline .row .tag { margin-left: auto; }
.bline .small { display: block; color: var(--muted); }

.todo { list-style: none; margin: 0 0 4px; padding: 0; }
.todo li { border-top: 1px solid var(--line); }
.todo li:first-child { border-top: 0; }
.todo a { display: flex; align-items: center; gap: 10px; min-height: var(--tap); text-decoration: none; }
.todo li.muted { padding: 10px 0; }

.items { list-style: none; margin: 0; padding: 0; }
.item { padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 2px; }
.item > .row a, a.row { text-decoration: none; }
.item .small { margin-top: 2px; }
.items > .muted { padding: 8px 0; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }

.steps { display: flex; gap: 6px; list-style: none; margin: 0 0 10px; padding: 0; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.steps li { padding: 2px 10px; border-radius: 999px; background: var(--sunk); }
.steps li.done { text-decoration: line-through; opacity: 0.7; }
.steps li.this { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: var(--sunk); }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 15px; }
.btn.big { min-height: 52px; font-size: 17px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, textarea, select {
  font: inherit; font-size: 17px; color: var(--text); background: var(--card);
  border: 1px solid var(--line-strong); border-radius: 10px; min-height: var(--tap); padding: 8px 12px; width: 100%;
}
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-size: 16px; color: var(--text); min-height: var(--tap); }
label.check input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--accent); }
input:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; border-color: var(--accent); }

.seg { display: inline-flex; background: var(--sunk); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a { min-height: 38px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 10px; text-decoration: none; font-size: 15px; color: var(--muted); }
.seg a.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.seg.wide { display: flex; margin-bottom: 14px; }
.seg.wide a { flex: 1; justify-content: center; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips a {
  flex: none; min-height: 38px; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 999px; text-decoration: none; font-size: 15px; background: var(--card);
}
.chips a span { color: var(--muted); font-size: 13px; }
.chips a.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chips a.on span { color: inherit; opacity: 0.7; }
.search { margin-bottom: 12px; }

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.more-acts { position: relative; }
.more-acts .pop {
  position: absolute; right: 0; z-index: 5; margin-top: 6px; min-width: 250px;
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}
.drop[open] { flex-basis: 100%; }
.drop form { margin-top: 10px; }
.card-details { margin-bottom: 14px; }
.card-details > summary { margin-bottom: 10px; }
details.more summary { cursor: pointer; font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td a { font-weight: 600; }

.toast {
  position: sticky; top: 8px; z-index: 20; display: flex; gap: 10px; align-items: flex-start;
  background: var(--accent-soft); color: var(--accent-text); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
  white-space: pre-line; font-size: 15px;
}
.toast.bad { background: var(--danger-soft); color: var(--danger); }
.toast span { flex: 1; }
.toast-x { border: 0; background: none; color: inherit; font-size: 22px; line-height: 1; cursor: pointer; min-width: 32px; min-height: 32px; }

/* ---------- login ---------- */

.bare { display: flex; justify-content: center; }
.login { width: 100%; max-width: 420px; padding: 48px 16px; text-align: center; }
.login h1 { margin-top: 12px; }
.login form { margin-top: 24px; text-align: left; }
.or { text-align: center; color: var(--muted); font-size: 14px; }
