:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  color: #192435;
  background: #f3f5f8;
  --nav: #162030;
  --soft: #f3f5f8;
  --border: #dce2ea;
  --muted: #526174;
  --red: #b71832;
  --red-hover: #9c1128;
  --white: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.55; }
a { color: #9c152b; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid #e45876; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 3vw, 2.8rem); line-height: 1.12; letter-spacing: -.035em; }
h2 { font-size: 1.22rem; line-height: 1.3; }
input, textarea, select, button { font: inherit; }
input, select, textarea {
  border: 1px solid #aebac9; border-radius: 7px; background: #fff; color: inherit;
  padding: .6rem .75rem; min-height: 44px; min-width: 0; width: 100%;
}
textarea { resize: vertical; }
label { display: grid; gap: .26rem; color: #344256; font-weight: 600; font-size: .92rem; }
label.checkbox { display: flex; gap: .5rem; align-items: center; font-weight: 500; min-height: 38px; }
input[type="checkbox"] { accent-color: var(--red); width: 1.14rem; height: 1.14rem; min-height: 0; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
small { color: var(--muted); }
.button {
  display: inline-flex; justify-content: center; align-items: center; gap: .45rem; min-height: 44px;
  padding: .5rem .95rem; border: 1px solid #bcc7d4; border-radius: 8px; color: #273448;
  background: #fff; text-decoration: none; font-weight: 650; font-size: .9375rem; text-align: center;
}
.button:hover { background: #f5f7fa; }
.button.primary { background: var(--red); border-color: var(--red); color: #fff; }
.button.primary:hover { background: var(--red-hover); }
.workspace { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.4rem .95rem; background: var(--nav); color: #fff; }
.brand { display: flex; align-items: center; gap: .7rem; color: inherit; line-height: 1.35; text-decoration: none; }
.brand img { object-fit: contain; flex: 0 0 auto; background: #fff; border-radius: 9px; }
.brand small { display: block; font-size: .85rem; }
.sidebar .brand { padding: .25rem .35rem 1.55rem; }
.sidebar .brand small, .sidebar .user small { color: #c2ccdd; }
.sidebar nav { display: grid; gap: .3rem; }
.sidebar nav a {
  min-height: 46px; display: flex; align-items: center; gap: .8rem; padding: .6rem .7rem;
  color: #e1e7f0; border-radius: 8px; text-decoration: none; font-weight: 600;
}
.sidebar nav a:hover, .sidebar nav a[aria-current="page"] { background: #2c3749; color: #fff; }
.sidebar nav a[aria-current="page"] { box-shadow: inset 3px 0 #ff4d69; }
.sidebar nav svg, .signout svg { flex: 0 0 auto; }
.user { margin-top: auto; padding: 1rem .35rem 0; border-top: 1px solid #3c4657; overflow-wrap: anywhere; }
.user small { display: block; }
.signout { margin-top: .5rem; min-height: 42px; color: #e1e7f0; display: flex; gap: .5rem; align-items: center; padding: 0; border: 0; background: transparent; }
.topbar { position: sticky; top: 0; z-index: 1; min-height: 61px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-bottom: 1px solid var(--border); background: #fff; padding: .75rem clamp(1rem, 3vw, 2.7rem); color: #415066; font-weight: 650; }
.private { display: inline-flex; gap: .4rem; align-items: center; font-size: .86rem; color: #4b596c; }
.private svg { width: 16px; height: 16px; }
.content { padding: 2rem clamp(1rem, 3vw, 2.7rem) 3rem; max-width: 1680px; margin: 0 auto; }
.heading { display: flex; gap: 1.2rem; justify-content: space-between; align-items: center; margin: 0 0 1.5rem; }
.heading p, .auth-card p { margin-top: .5rem; color: var(--muted); }
.heading .button { flex-shrink: 0; }
.back { display: inline-block; margin-bottom: .85rem; font-weight: 650; }
.counts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.count-card { display: grid; gap: .5rem; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; text-decoration: none; color: #233148; }
.count-card:hover { border-color: #d28e9c; }
.count-card > div { display: flex; gap: .6rem; justify-content: space-between; align-items: flex-start; color: #49586d; font-size: .94rem; font-weight: 650; }
.count-card svg { flex-shrink: 0; color: var(--red); }
.count-card strong { font-size: 2rem; line-height: 1.2; }
.dashboard, .record-layout { display: grid; gap: 1rem; }
.dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.record-layout { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; min-width: 0; }
.panel + .panel, .record-layout + .panel { margin-top: 1rem; }
.stack > .panel + .panel { margin-top: 0; }
.panel-head, .panel-body { padding: 1rem 1.15rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); }
.panel-head a { display: flex; align-items: center; gap: .25rem; font-size: .9rem; font-weight: 600; white-space: nowrap; }
.panel-head a svg { width: 17px; height: 17px; }
.filters {
  padding: .95rem 1.1rem; display: flex; flex-wrap: wrap; align-items: end; gap: .8rem;
  border-bottom: 1px solid var(--border);
}
.filters label { min-width: 8rem; }
.filters label:has(input[type="search"]) { flex: 1 1 14rem; }
.filter-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.results { padding: .65rem 1.1rem; color: var(--muted); font-size: .94rem; }
.table-scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
th { padding: .75rem 1rem; background: #eef2f6; color: #3c4a5e; font-size: .89rem; font-weight: 700; }
td { padding: .72rem 1rem; border-top: 1px solid #e5eaf0; overflow-wrap: anywhere; }
tbody tr:hover { background: #fbf5f7; }
td:first-child { min-width: 9rem; }
.record-link { color: #17243a; font-weight: 700; text-decoration: underline; text-decoration-color: #9baabe; }
.row-sub { display: block; font-size: .84rem; margin-top: .12rem; }
.badge { display: inline-block; background: #edf0f5; color: #3f4d62; border-radius: 6px; padding: .2rem .48rem; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.badge.green { background: #e6f3ec; color: #16553b; }
.badge.blue { background: #e9f0fb; color: #204b7f; }
.badge.amber { background: #fcf1df; color: #7b4715; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: .5rem; border-top: 1px solid var(--border); padding: 1rem; }
.pager > :first-child, .pager > :last-child { min-width: 5.5rem; }
.empty { padding: 1.4rem 1.1rem; color: var(--muted); }
.pairs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1.15rem; margin: 0; }
.pairs div { padding-bottom: .45rem; border-bottom: 1px solid #e7ebf0; min-width: 0; }
dt { font-weight: 650; color: #4a596e; font-size: .88rem; }
dd { margin: .18rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.source summary, td summary { cursor: pointer; color: #344256; font-weight: 650; }
.source summary { padding: .8rem 1.1rem; }
.source p { margin-bottom: .6rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.wide { grid-column: 1/-1; }
fieldset { border: 1px solid var(--border); border-radius: 7px; padding: .65rem 1rem; }
legend { font-weight: 700; }
.stack { display: grid; gap: .8rem; }
.stack .button { justify-self: start; }
.muted { color: var(--muted); }
.timeline, .checklist { padding-left: 0; list-style: none; margin: .8rem 0 0; }
.timeline li { border-top: 1px solid var(--border); padding: .65rem 0; }
.timeline p { white-space: pre-wrap; overflow-wrap: anywhere; }
.checklist li { display: flex; gap: .55rem; align-items: center; }
.checked { color: #16553b; font-weight: 800; }
.notice, .error { padding: .8rem 1rem; border-radius: 8px; margin: 0 0 1rem; color: #16553b; background: #e6f3ec; }
.notice label { margin: .6rem 0; }
.error { color: #8a1930 !important; background: #fcebf0; }
.error-panel { padding: 2rem; }
.error-panel p { margin: .6rem 0 1rem; }
.account-tools { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .4rem; }
.signed-out { display: grid; min-height: 100vh; place-items: center; background: radial-gradient(ellipse at center top, #e4e9f1, #f4f6f9 70%); }
.signed-out main { width: min(100%, 31rem); }
.auth-card { border-radius: 15px; border: 1px solid var(--border); padding: clamp(1.3rem, 4vw, 2.1rem); background: #fff; box-shadow: 0 10px 28px #23395913; }
.auth-card .brand { margin-bottom: 1.7rem; }
.auth-card form { display: grid; gap: .95rem; margin: 1.2rem 0; }
.auth-note { color: var(--muted); border-top: 1px solid var(--border); padding-top: .9rem; display: flex; align-items: center; gap: .55rem; font-size: .9rem; }
@media (max-width: 1080px) {
  .dashboard, .record-layout { grid-template-columns: minmax(0, 1fr); }
  .counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .workspace { display: block; }
  .sidebar { position: static; height: auto; padding: .75rem; }
  .sidebar .brand { padding-bottom: .65rem; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar nav a { font-size: .9rem; padding: .45rem; gap: .45rem; }
  .user { display: flex; gap: .7rem; align-items: center; padding-top: .4rem; margin-top: .4rem; font-size: .86rem; }
  .user form { margin-left: auto; }
  .signout { margin: 0; }
  .topbar { position: static; min-height: 46px; }
  .content { padding-top: 1.1rem; }
  .heading { align-items: start; flex-direction: column; gap: .75rem; }
}
@media (max-width: 480px) {
  .pairs, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .filters label { flex: 1 1 8rem; }
  .count-card { padding: .75rem; }
}
