:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #6b7079;
  --line: #e4e4e0;
  --line-strong: #d3d3ce;
  --accent: #1f3a5f;
  --accent-hover: #172c48;
  --row-hover: #fafaf8;
  --err: #a12a2a;
  --ok: #2f5d3a;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "tnum";
}
#app { min-height: 100vh; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* Top bar */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 32px; }
.wordmark { font-weight: 600; font-size: 15px; letter-spacing: 0.01em; white-space: nowrap; }
.wordmark span { color: var(--muted); font-weight: 400; margin-left: 8px; padding-left: 8px; border-left: 1px solid var(--line-strong); }
.nav { display: flex; gap: 4px; height: 100%; }
.nav button { background: none; border: 0; padding: 0 12px; height: 100%; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.nav button:hover { color: var(--text); }
.nav button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.user { margin-left: auto; display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.user-name { color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 4px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: #b9b9b3; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.block { width: 100%; height: 40px; margin-top: 20px; }
.btn:focus-visible, .link:focus-visible, .in:focus-visible, .nav button:focus-visible, .folders button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.strong { color: var(--text); font-weight: 500; text-align: left; }

/* Sign in */
.signin-wrap { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 96px 20px 40px; }
.signin { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 32px; }
.signin h1 { font-size: 18px; margin-bottom: 24px; }
.f { display: block; font-size: 13px; font-weight: 500; margin: 14px 0 6px; }
.in { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; font: inherit; font-size: 16px; color: var(--text); }
.in:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.12); }
.err { color: var(--err); background: #fbf2f2; border: 1px solid #efd6d6; border-radius: 4px; padding: 8px 12px; margin: 0 0 8px; font-size: 13px; }
.ok { color: var(--ok); font-size: 13px; }

/* Page */
.wrap { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 32px 24px 48px; }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; min-height: 30px; }
.page-h h1 { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

.layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.folders { display: flex; flex-direction: column; gap: 2px; }
.folders button { display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: 0; border-radius: 4px; padding: 8px 10px; cursor: pointer; text-align: left; color: var(--text); }
.folders button:hover { background: #efefec; }
.folders button.on { background: #e9ecf1; color: var(--accent); font-weight: 500; }
.count { color: var(--muted); font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: 14px; }
.card-tools { display: flex; align-items: center; gap: 12px; }
.drop.over { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.hidden-input { display: none; }

/* Tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fbfbfa; white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--row-hover); }
td.name { font-weight: 500; }
.num { text-align: right; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.actions .link + .link { margin-left: 16px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* Preview */
.back { position: fixed; inset: 0; background: rgba(15, 18, 24, 0.45); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 10; }
.modal { background: var(--surface); border-radius: 6px; width: min(960px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); }
.modal-h { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-t { min-width: 0; }
.modal-t h2 { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-a { display: flex; gap: 8px; flex-shrink: 0; }
.preview-frame { width: 100%; height: 72vh; border: 0; background: #f2f2f0; }
.preview-img { max-width: 100%; max-height: 72vh; display: block; margin: 0 auto; padding: 16px; }
.preview-text { margin: 0; padding: 20px; max-height: 72vh; overflow: auto; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.preview-none { padding: 40px 20px; text-align: center; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }

@media (max-width: 760px) {
  .top-in { padding: 0 16px; gap: 16px; }
  .wordmark span, .user-name { display: none; }
  .nav button { padding: 0 8px; }
  .wrap { padding: 20px 16px 32px; }
  .layout { grid-template-columns: 1fr; gap: 16px; }
  .folders { flex-direction: row; overflow-x: auto; gap: 4px; }
  .folders button { width: auto; white-space: nowrap; gap: 8px; }
  .col-folder, .col-by { display: none; }
  th, td { padding-left: 12px; padding-right: 12px; }
  .signin-wrap { padding-top: 48px; }
  .signin { padding: 24px; }
}

/* Filing status */
.due { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.due .sep { margin-left: 8px; }
.st { font-size: 13px; color: var(--muted); }
.st::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #b9b9b3; margin-right: 6px; vertical-align: middle; position: relative; top: -1px; }
.st.st-ok { color: var(--ok); } .st.st-ok::before { background: #3f7a4e; }
.st.st-warn { color: #8a6116; } .st.st-warn::before { background: #c08a2a; }
.st.st-bad { color: var(--err); } .st.st-bad::before { background: #b23a3a; }
.sel { height: 30px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; font: inherit; font-size: 13px; padding: 0 8px; color: var(--text); }
@media (max-width: 760px) { .page-h { flex-direction: column; align-items: flex-start; gap: 8px; } }

/* Clickable rows and detail */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f3f5f8; }
tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.back-link { display: inline-block; margin-bottom: 16px; font-size: 13px; }
.detail-h { align-items: flex-end; }
.detail-h .muted { margin-top: 4px; }
.sec { font-size: 14px; margin: 28px 0 10px; }

/* Admin: summary, toolbar, grid */
.summary { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 16px; overflow: hidden; }
.sum { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 16px; background: none; border: 0; border-right: 1px solid var(--line); cursor: pointer; text-align: left; border-top: 2px solid transparent; }
.sum:last-child { border-right: 0; }
.sum b { font-size: 20px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sum span { font-size: 12px; color: var(--muted); }
.sum:hover { background: var(--row-hover); }
.sum.on { background: #f3f5f8; }
.sum-overdue.on { border-top-color: #b23a3a; } .sum-incomplete.on, .sum-late.on { border-top-color: #c08a2a; } .sum-filed.on { border-top-color: #3f7a4e; } .sum-due.on { border-top-color: #9a9a94; }
.sum-overdue b { color: var(--err); } .sum-incomplete b, .sum-late b { color: #8a6116; } .sum-filed b { color: var(--ok); }
.sum:focus-visible, .seg button:focus-visible, .mark:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tb-count { margin-left: auto; }
.in.sm { height: 30px; font-size: 13px; padding: 0 10px; width: 240px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-right: 1px solid var(--line-strong); background: none; height: 28px; padding: 0 12px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.sort-l { display: inline-flex; align-items: center; gap: 6px; }
td.overdue { color: var(--err); font-weight: 500; }
table.filings td, table.grid td { padding-top: 9px; padding-bottom: 9px; }

.detail-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.detail-top .back-link { margin: 0; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .btn { width: 30px; padding: 0; font-size: 16px; }
.stepper .btn[disabled] { opacity: 0.4; cursor: default; }
.detail-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 8px; }
.detail-h h1 { font-size: 20px; }
.glance { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.glance > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 16px; border-right: 1px solid var(--line); min-width: 110px; }
.glance > div:last-child { border-right: 0; }
th.cell, td.cell { text-align: center; }
.mark { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 4px; font-size: 14px; line-height: 1; border: 0; background: none; }
.mark.ok { color: var(--ok); background: #eef4ef; cursor: pointer; }
.mark.ok:hover { background: #dde9df; }
.mark.miss { color: var(--err); background: #fbf2f2; }
.mark.pend { color: #9a9a94; }

.groups { overflow: hidden; }
.group + .group { border-top: 1px solid var(--line); }
.group summary { display: flex; align-items: center; gap: 12px; padding: 11px 16px; cursor: pointer; list-style: none; user-select: none; }
.group summary::-webkit-details-marker { display: none; }
.group summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform 0.12s; margin-right: 2px; }
.group[open] summary::before { transform: rotate(45deg); }
.group summary:hover { background: var(--row-hover); }
.g-title { font-weight: 500; }
.group table { border-top: 1px solid var(--line); }
.card.activity { margin-top: 16px; }

@media (max-width: 760px) {
  .summary { grid-template-columns: repeat(3, 1fr); }
  .sum { border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .in.sm { width: 100%; }
  .tb-count { margin-left: 0; }
  .glance { width: 100%; }
  .glance > div { flex: 1; min-width: 0; padding: 8px 10px; }
  table.grid th.cell { font-size: 10px; white-space: normal; }
}
@media (max-width: 760px) {
  .top-in { gap: 10px; }
  .nav { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { white-space: nowrap; padding: 0 7px; font-size: 13px; }
  .user { margin-left: 0; flex-shrink: 0; }
  .wordmark { flex-shrink: 0; }
  html, body { overflow-x: hidden; }
}

/* Next filing card */
.filing-card { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 6px; margin-bottom: 20px; }
.filing-card.complete { border-left-color: #3f7a4e; }
.fc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px 20px 14px; }
.fc-main { flex: 1; min-width: 0; }
.fc-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.fc-date { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; margin-top: 2px; }
.fc-sub { margin-top: 2px; font-size: 13px; }
.fc-cd { font-weight: 600; color: var(--accent); }
.fc-cd.warn { color: #8a6116; } .fc-cd.bad { color: var(--err); } .fc-cd.ok { color: var(--ok); }
.fc-bar { height: 4px; background: #ecece8; border-radius: 2px; margin-top: 10px; max-width: 360px; overflow: hidden; }
.fc-bar i { display: block; height: 100%; background: var(--accent); }
.filing-card.complete .fc-bar i { background: #3f7a4e; }
.fc-act { flex-shrink: 0; }
.fc-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); }
.fc-list li { display: grid; grid-template-columns: 18px 1fr; grid-template-rows: auto auto; column-gap: 8px; padding: 10px 16px; border-right: 1px solid var(--line); align-items: center; font-size: 13px; }
.fc-list li:last-child { border-right: 0; }
.fc-mark { grid-row: 1 / 3; width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
li.has .fc-mark { background: #eef4ef; color: var(--ok); }
li.miss .fc-mark { border: 1.5px dashed #c5c5bf; }
.fc-type { font-weight: 500; }
.fc-file, .fc-missing, .fc-up { font-size: 12px; justify-self: start; }
.fc-file { color: var(--muted); }
.fc-missing { color: var(--muted); }
li.miss { grid-template-rows: auto auto; }
li.miss .fc-up { grid-column: 2; }
li.miss .fc-missing { display: inline; }
@media (max-width: 760px) {
  .fc-head { flex-direction: column; padding: 14px 16px; }
  .fc-act, .fc-act .btn { width: 100%; }
  .fc-list { grid-template-columns: 1fr 1fr; }
  .fc-list li:nth-child(2n) { border-right: 0; }
  .fc-list li:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
.fc-line { display: flex; gap: 10px; align-items: center; font-size: 12px; }
.fc-prev { margin-top: 4px; font-size: 12px; color: var(--err); }
.detail-h + .filing-card { margin-top: 16px; }

/* New markers, reminders */
.new-count { display: inline-block; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px; margin-left: 6px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 600; text-align: center; vertical-align: 1px; }
.new-mark { margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--accent); letter-spacing: 0.02em; }
.upload-err { color: var(--err); font-size: 13px; }
.rem summary { gap: 14px; }
.rem-kind { font-size: 12px; font-weight: 500; min-width: 76px; color: var(--muted); }
.rk-overdue { color: var(--err); } .rk-escalation { color: #8a6116; } .rk-due-soon { color: var(--accent); }
.rem .g-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rem-to { white-space: nowrap; }
.rem-st { white-space: nowrap; }
.rem-body { margin: 0; padding: 12px 16px 16px 44px; border-top: 1px solid var(--line); font: 13px/1.6 Inter, sans-serif; white-space: pre-wrap; color: var(--text); background: #fbfbfa; }
@media (max-width: 760px) { .rem-to, .rem-st { display: none; } }
