:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --text: #15202b;
  --muted: #5d6b78;
  --line: #dde3e8;
  --accent: #0f6e5c;
  --accent-text: #ffffff;
  --accent-soft: #e2f3ef;
  --warn: #9a5b00;
  --warn-soft: #fff3df;
  --bad: #a3281f;
  --bad-soft: #fde8e6;
  --info-soft: #e7eef8;
  --info: #24518a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1418;
    --surface: #172026;
    --surface-2: #1c262d;
    --text: #e6edf2;
    --muted: #93a3b0;
    --line: #2a363f;
    --accent: #3fbf9f;
    --accent-text: #08201a;
    --accent-soft: #163a32;
    --warn: #f0b45a;
    --warn-soft: #3a2c14;
    --bad: #f08a80;
    --bad-soft: #3d1c19;
    --info-soft: #1a2a40;
    --info: #9cc0f0;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); flex: 0 0 30px; }
.title { font-weight: 700; font-size: 17px; }
.sub { color: var(--muted); font-size: 13px; }
main { max-width: 1200px; margin: 0 auto; padding: 18px 16px 48px; }
h2 { margin: 0 0 4px; font-size: 18px; }
.sectionhead { margin: 22px 0 10px; }
.sectionhead p { margin: 0; }
.muted { color: var(--muted); font-weight: 400; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.narrow { max-width: 420px; margin: 40px auto; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font: inherit; min-height: 40px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  font: inherit; font-weight: 600; padding: 9px 16px; min-height: 40px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); cursor: pointer;
}
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; }
.err { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }

/* state cards: equal height, actions pinned to the bottom */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; align-items: stretch; }
.card {
  display: flex; flex-direction: column; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.card.off { background: var(--surface-2); }
.card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card .code { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.card .nm { font-size: 17px; font-weight: 700; }
.card .count { font-size: 24px; font-weight: 700; margin: 10px 0 2px; }
.card .count small { font-size: 12px; color: var(--muted); font-weight: 500; }
.card dl { margin: 8px 0 12px; font-size: 13px; }
.card dt { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; margin-top: 8px; }
.card dd { margin: 2px 0 0; }
.card .foot { margin-top: auto; display: flex; gap: 8px; }
.card .foot button, .card .foot .btn, .card .foot .pending { flex: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 600; padding: 9px 16px; min-height: 40px; border-radius: 8px; text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.pending {
  display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 8px;
  border: 1px dashed var(--line); color: var(--muted); font-size: 13px; font-weight: 600;
}
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.b-live { background: var(--accent-soft); color: var(--accent); }
.b-run { background: var(--info-soft); color: var(--info); }
.b-paid { background: var(--warn-soft); color: var(--warn); }
.b-err { background: var(--bad-soft); color: var(--bad); }
.b-none { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.cardnote { font-size: 12px; color: var(--muted); }
.cardnote.bad { color: var(--bad); }

/* search form */
.fields { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.f { flex: 1 1 150px; min-width: 0; }
.f.grow { flex: 3 1 260px; }
.f.small { flex: 0 1 120px; }
.f.inline { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.f.inline label { margin: 0; white-space: nowrap; }
.f.inline select { width: auto; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.check { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; color: var(--text); font-weight: 500; }
.check input { width: auto; min-height: 0; }
.spacer { flex: 1; }

/* results */
.meta { margin: 14px 2px 8px; color: var(--muted); font-size: 13px; min-height: 1.2em; }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { background: var(--surface-2); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tbody tr.hit { cursor: pointer; }
tbody tr.hit:hover, tbody tr.hit.open { background: var(--surface-2); }
td .nm { font-weight: 600; }
td .id { color: var(--muted); font-size: 12px; }
.due-missed { color: var(--bad); font-weight: 600; }
.due-soon { color: var(--warn); font-weight: 600; }
tr.detail td { background: var(--surface-2); padding: 0; }
.dwrap { padding: 14px 16px 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 22px; }
.dwrap h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.dwrap p { margin: 0; font-size: 14px; }
.dwrap .wide { grid-column: 1 / -1; }
.dwrap a { color: var(--accent); }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 10px; }
@media (max-width: 640px) {
  .top { padding: 12px 14px; }
  main { padding: 12px 10px 40px; }
  .actions .spacer { display: none; }
  .actions button { flex: 1 1 30%; }
}
