:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1f2420;
  --quiet: #5f665f;
  --line: #dcdad2;
  --accent: #3d5a3a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161917;
    --surface: #1f2320;
    --ink: #ecebe6;
    --quiet: #a3a99f;
    --line: #333833;
    --accent: #8fb889;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.top {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { color: var(--accent); font-weight: 700; text-decoration: none; }
main { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}
h1 { margin: 0 0 8px; font-size: 1.5rem; }
.quiet { color: var(--quiet); }
.foot { text-align: center; color: var(--quiet); font-size: 0.8rem; padding: 24px 16px; }

/* layout */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 0.95rem; }
.nav a { color: var(--ink); text-decoration: none; }
.who { color: var(--quiet); }
main { max-width: 1180px; }
.narrow { max-width: 480px; margin: 40px auto; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
h2 { font-size: 1.05rem; margin: 18px 0 8px; }
h2:first-child { margin-top: 0; }
a { color: var(--accent); }

/* buttons */
.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 6px;
       padding: 9px 16px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.small { padding: 5px 10px; font-size: 0.9rem; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.nav .btn { color: #fff; }

/* list */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); background: var(--surface); }
.tabs a.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pill { display: inline-block; min-width: 1.6em; text-align: center; border-radius: 999px; background: var(--line); padding: 0 6px; font-size: 0.8rem; }
.pill.warn { background: #f3d9b1; color: #6b4300; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 260px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table.cases { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.cases th, .cases td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cases th { color: var(--quiet); font-weight: 600; white-space: nowrap; }
.cases tr.flag td:first-child { border-left: 4px solid #a8323e; }
.late { color: #a8323e; font-weight: 600; }
.empty { color: var(--quiet); padding: 24px 0; }
.status { display: inline-block; font-size: 0.8rem; padding: 2px 8px; border-radius: 999px; background: var(--line); white-space: nowrap; }
.s-resolved, .s-settled { background: #d5e8d1; color: #24461f; }
.s-not_claimed { background: #e6e1d6; color: #4a4536; }
.s-sent, .s-decided, .s-customer_told, .s-info_complete { background: #dfe7f2; color: #1e3a5c; }

/* forms */
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
                          border-radius: 6px; padding: 8px 10px; width: 100%; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; color: var(--quiet); }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.form label.check input { width: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
.grid .wide, .form > label.wide { grid-column: 1 / -1; margin-bottom: 12px; }
.error { background: #f6d6d9; color: #6d1420; padding: 10px 14px; border-radius: 6px; }
.cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

/* timeline */
.note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.note-form .btn { align-self: flex-start; }
.events { list-style: none; padding: 0; margin: 0; }
.ev { padding: 8px 0; border-top: 1px solid var(--line); font-size: 0.92rem; }
.ev-meta { color: var(--quiet); font-size: 0.8rem; }
.ev-change { color: var(--quiet); }
.ev-closed { font-weight: 600; }

/* lookup + linked records */
.lookup { margin-bottom: 16px; }
.lookup p { margin: 0 0 8px; }
.lookup-row { display: flex; gap: 8px; flex-wrap: wrap; }
.lookup-row input { flex: 1 1 200px; }
.found { background: var(--bg); border-radius: 6px; padding: 8px 10px; margin-top: 8px !important; }
fieldset.lines { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 12px; padding: 10px 12px; }
fieldset.lines legend { color: var(--quiet); font-size: 0.88rem; padding: 0 4px; }
fieldset.lines label { padding: 4px 0; }
.side { display: flex; flex-direction: column; gap: 16px; }
.linked-block { border-top: 1px solid var(--line); padding: 10px 0; font-size: 0.92rem; }
.linked-block:first-child { border-top: 0; padding-top: 0; }
.linked-block h3 { font-size: 0.95rem; margin: 0 0 4px; }
.linked-block p { margin: 0 0 6px; }
ul.plain { list-style: none; padding: 0; margin: 6px 0; }
ul.plain li { padding: 3px 0; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.thumbs .file { display: inline-block; font-size: 0.8rem; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; }
details summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
