:root {
  color-scheme: light dark;
  --canvas: #F6F7F9; --surface: #FFFFFF;
  --text: #14171C; --text-2: #4B5361; --text-3: #5E6673;
  --border: #E4E7EB; --border-strong: #7A828E;
  --accent: #1D4ED8; --on-accent: #FFFFFF; --focus: #1D4ED8;
  --row-selected: #EEF3FE;
  --sev-high-fg: #B42318; --sev-high-bg: #FEF3F2; --sev-high-stripe: #D92D20;
  --sev-review-fg: #93370D; --sev-review-bg: #FFFAEB; --sev-review-stripe: #B54708;
  --info-fg: #1849A9; --info-bg: #EFF6FF;
  --ok-fg: #067647; --ok-bg: #ECFDF3;
  --shadow-pop: 0 1px 2px rgb(0 0 0 / .06), 0 4px 12px rgb(0 0 0 / .08);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-xs: .8125rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.25rem; --fs-xl: 1.625rem; --fs-num: 2.25rem;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
  --ease: cubic-bezier(0.2, 0, 0, 1); --ease-exit: cubic-bezier(0.3, 0, 1, 1);
  --dur-1: 120ms; --dur-2: 200ms; --dur-3: 280ms;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0F1115; --surface: #171A1F;
    --text: #ECEEF1; --text-2: #A8AFBA; --text-3: #8F97A3;
    --border: #262A31; --border-strong: #6B7380;
    --accent: #7EA6FF; --on-accent: #0F1115; --focus: #8AB4FF;
    --row-selected: #1C2740;
    --sev-high-fg: #FF9C92; --sev-high-bg: #2B1517; --sev-high-stripe: #F97066;
    --sev-review-fg: #F7C35F; --sev-review-bg: #2A2210; --sev-review-stripe: #F7C35F;
    --info-fg: #93BBFF; --info-bg: #14213A;
    --ok-fg: #6CD9A6; --ok-bg: #0F2A1F;
    --shadow-pop: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  margin: 0; background: var(--canvas); color: var(--text);
  font: 400 var(--fs-md)/1.5 var(--font); font-feature-settings: "tnum" 1, "cv11" 1;
}
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; font-weight: 600; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0; text-wrap: pretty; }
code, .mono { font-family: var(--mono); font-feature-settings: normal; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--text-2); }
.caption { color: var(--text-3); font-size: var(--fs-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
main:focus, h1:focus, h2:focus { outline: none; }
.skip { position: absolute; left: var(--sp-4); top: -60px; background: var(--surface); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md); z-index: 10; }
.skip:focus { top: var(--sp-2); }

/* top bar */
.topbar { height: 56px; display: flex; align-items: center; gap: var(--sp-6); padding: 0 var(--sp-6); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 600; display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 40px; }
.brand .mark { width: 28px; height: 28px; flex: none; }
a.brand { color: inherit; text-decoration: none; }
a.brand:hover { color: var(--accent); }
.topnav { flex: 1; }
.topbar.bare .company, .topbar.bare .who { display: none; }
.who { display: flex; align-items: center; gap: var(--sp-4); color: var(--text-2); font-size: var(--fs-sm); }
.link { background: none; border: 0; padding: 0 var(--sp-2); min-height: 40px; color: var(--accent); font: inherit; cursor: pointer; border-radius: var(--r-sm); }
.link:hover { text-decoration: underline; }

main { max-width: 1440px; margin: 0 auto; padding: var(--sp-8) var(--sp-6) var(--sp-12); }
.col-sm { max-width: 400px; margin: var(--sp-12) auto 0; }
.col-md { max-width: 640px; margin: 0 auto; }
.col-lg { max-width: 880px; margin: 0 auto; }
.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-6); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-6); }

/* banner */
.banner { padding: var(--sp-3) var(--sp-6); background: var(--sev-high-bg); color: var(--text); border-bottom: 1px solid var(--sev-high-stripe); display: flex; gap: var(--sp-4); align-items: center; }
.banner strong { color: var(--sev-high-fg); }

/* forms and buttons */
label, legend { font-weight: 500; font-size: var(--fs-sm); }
.field { display: grid; gap: var(--sp-1); }
input[type=email], input[type=password], input[type=text], textarea, select {
  width: 100%; min-height: 40px; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
input[type=email]:hover, input[type=password]:hover, input[type=text]:hover, textarea:hover, select:hover { border-color: var(--text-3); }
textarea { min-height: 72px; resize: vertical; }
.btn {
  min-height: 40px; padding: 0 var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 500 var(--fs-md)/1 var(--font); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  transition-property: background-color, transform, border-color; transition-duration: var(--dur-1); transition-timing-function: var(--ease);
}
.btn:hover { background: var(--row-selected); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn[disabled], .btn[aria-disabled=true] { opacity: .55; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }
.hint { font-size: var(--fs-sm); color: var(--text-2); }
.err-text { color: var(--sev-high-fg); font-size: var(--fs-sm); font-weight: 500; }

/* upload */
.drop { border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface); min-height: 160px; display: grid; place-content: center; text-align: center; gap: var(--sp-2); padding: var(--sp-6); transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease); }
.drop.over { background: var(--row-selected); border-color: var(--accent); }
.bar { height: 2px; background: var(--border); overflow: hidden; border-radius: 1px; margin-top: var(--sp-2); }
.bar::after { content: ""; display: block; height: 100%; width: 35%; background: var(--accent); animation: slide 1.1s var(--ease) infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.problems { background: var(--sev-high-bg); border: 1px solid var(--sev-high-stripe); border-radius: var(--r-md); padding: var(--sp-4); }
.problems ul { margin: var(--sp-2) 0 0; padding-left: var(--sp-6); }
.problems li { color: var(--text); }
.recent { list-style: none; margin: var(--sp-2) 0 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.recent li + li { border-top: 1px solid var(--border); }
.recent button, .recent a { all: unset; box-sizing: border-box; width: 100%; min-height: 48px; padding: var(--sp-2) var(--sp-4); display: flex; justify-content: space-between; gap: var(--sp-4); align-items: center; cursor: pointer; flex-wrap: wrap; }
.recent button:hover, .recent a:hover { background: var(--row-selected); }
.recent button:focus-visible, .recent a:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; line-height: 1.5; white-space: nowrap; animation: pop var(--dur-2) var(--ease); }
.badge.high { background: var(--sev-high-bg); color: var(--sev-high-fg); }
.badge.review { background: var(--sev-review-bg); color: var(--sev-review-fg); }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.neutral { background: var(--canvas); color: var(--text-2); border: 1px solid var(--border); }
.badge.open { background: var(--info-bg); color: var(--info-fg); }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* flags screen */
.head { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-6); justify-content: space-between; align-items: flex-end; margin-bottom: var(--sp-4); }
.summary { color: var(--text-2); font-size: var(--fs-sm); }
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.chip { min-height: 40px; padding: 0 var(--sp-4); border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text); font: 500 var(--fs-sm)/1 var(--font); cursor: pointer; transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease); }
.chip:active { transform: scale(.97); }
.chip[aria-pressed=true] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-6); align-items: start; }
@media (min-width: 1200px) {
  .split.has-panel { grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); }
  .panel { position: sticky; top: var(--sp-4); max-height: calc(100vh - 2 * var(--sp-4)); overflow: auto; }
}
.table-wrap { position: relative; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 0 var(--sp-3); height: 44px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color var(--dur-1) var(--ease); }
tbody tr:hover { background: var(--row-selected); }
tbody tr[aria-selected=true] { background: var(--row-selected); }
td.stripe-cell { padding: 0; width: 3px; }
.stripe { display: block; width: 3px; height: 44px; background: var(--border); }
.stripe.high { background: var(--sev-high-stripe); }
.stripe.review { background: var(--sev-review-stripe); }
.rowbtn { all: unset; box-sizing: border-box; min-height: 40px; display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-family: var(--mono); font-weight: 500; padding: 0 var(--sp-1); border-radius: var(--r-sm); color: var(--accent); }
.rowbtn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.what { min-width: 180px; }
.zero { background: var(--ok-bg); color: var(--text); border: 1px solid var(--ok-fg); border-radius: var(--r-lg); padding: var(--sp-6); display: grid; gap: var(--sp-3); animation: rise var(--dur-3) var(--ease); }
.zero .big { font-size: var(--fs-num); font-weight: 600; color: var(--ok-fg); font-variant-numeric: tabular-nums; line-height: 1.1; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* detail panel */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-6); }
.panel-body { display: grid; gap: var(--sp-4); animation: fadein var(--dur-2) var(--ease); }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.ptitle { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.box { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); background: var(--surface); }
.box .lab { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.box .val { font-size: var(--fs-num); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-width: 480px) { .vs { grid-template-columns: 1fr; } .box .val { font-size: var(--fs-xl); } }
.calc { font-family: var(--mono); font-size: var(--fs-sm); background: var(--info-bg); color: var(--text); border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3); overflow-wrap: anywhere; }
.sec-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.reqs > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: var(--sp-2); list-style: none; }
.reqs > summary::-webkit-details-marker { display: none; }
.reqs > summary::before { content: ''; flex: none; width: 8px; height: 8px; border: solid var(--text-2); border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform var(--dur-2) var(--ease); }
.reqs[open] > summary::before { transform: rotate(45deg); }
.reqs > summary h2 { margin: 0; text-wrap: balance; }
.reqs[open] > summary { margin-bottom: var(--sp-4); }
.reqs ul { margin: 0; padding-left: var(--sp-6); display: grid; gap: var(--sp-1); }
.reqs p, .reqs li { text-wrap: pretty; }
.reqs .rec { color: var(--text); font-size: inherit; border-left: 3px solid var(--accent); padding-left: var(--sp-3); }
details.source summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; color: var(--accent); font-size: var(--fs-sm); font-weight: 500; }
details.source dl { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); overflow-wrap: anywhere; gap: 2px var(--sp-4); margin: var(--sp-2) 0 0; font-size: var(--fs-sm); background: var(--info-bg); padding: var(--sp-3); border-radius: var(--r-sm); }
details.source dt { color: var(--text-2); font-family: var(--mono); }
details.source dd { margin: 0; font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.related { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.rel { flex: 1 1 140px; border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }
.rel.this { border: 2px solid var(--sev-high-stripe); }
.rel .l { color: var(--text-2); }
.rel .c { font-family: var(--mono); font-weight: 500; }
fieldset { border: 0; border-top: 1px solid var(--border); margin: 0; padding: var(--sp-4) 0 0; display: grid; gap: var(--sp-2); }
fieldset legend { padding: 0; font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--sp-2); }
.radio { display: flex; align-items: center; gap: var(--sp-3); min-height: 40px; font-weight: 400; font-size: var(--fs-md); }
.radio input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }

/* report */
.rhead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2) var(--sp-6); align-items: flex-start; }
.stats { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.stats b { font-variant-numeric: tabular-nums; }
.report-table td { height: auto; padding: var(--sp-2) var(--sp-3); vertical-align: top; }
.note-cell { min-width: 160px; overflow-wrap: anywhere; }
dialog { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); padding: var(--sp-6); max-width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog[open] { animation: rise var(--dur-3) var(--ease); }
.skeleton td > span { display: block; height: 14px; border-radius: 4px; background: var(--border); }

@media (max-width: 640px) {
  main { padding: var(--sp-6) var(--sp-4) var(--sp-12); }
  .topbar { padding: 0 var(--sp-4); gap: var(--sp-3); }
  .panel, .card { padding: var(--sp-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .btn:active { transform: none; }
  .bar { display: none; }
}

@media print {
  .tabbar { display: none !important; }
  :root { color-scheme: light; --canvas: #fff; --surface: #fff; --text: #14171C; --text-2: #4B5361; --text-3: #5E6673; --border: #E4E7EB; --sev-high-fg: #B42318; --sev-high-bg: #FEF3F2; --sev-review-fg: #93370D; --sev-review-bg: #FFFAEB; --ok-fg: #067647; --ok-bg: #ECFDF3; --info-bg: #EFF6FF; --info-fg: #1849A9; }
  .topbar, .banner, .skip, .no-print, .btn { display: none !important; }
  main { padding: 0; max-width: none; }
  .table-wrap { overflow: visible; border: 0; }
  tr { break-inside: avoid; }
}

/* ---- dashboard additions ---- */
.recent a { color: var(--text); text-decoration: none; }
.recent a[aria-current=true] { background: var(--row-selected); }
.topbar { gap: var(--sp-4); }
.company { flex: 1; display: flex; align-items: center; min-width: 0; color: var(--text-2); font-size: var(--fs-sm); }
.company select { width: auto; max-width: 100%; min-height: 40px; }
#team-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar { position: relative; display: flex; gap: var(--sp-1); padding: 0 var(--sp-6); background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.tabbar button { min-height: 44px; padding: 0 var(--sp-4); border: 0; border-bottom: 3px solid transparent; background: none; color: var(--text-2); font: 500 var(--fs-md)/1 var(--font); cursor: pointer; white-space: nowrap; transition-property: color, border-color, background-color; transition-duration: var(--dur-1); transition-timing-function: var(--ease); }
.tabbar button:hover { color: var(--text); background: var(--row-selected); }
.tabbar button[aria-selected=true] { color: var(--text); font-weight: 600; }
.tab-ind { position: absolute; left: 0; bottom: 0; width: 100px; height: 3px; background: var(--accent); transform-origin: 0 0; transform: scaleX(0); transition: transform var(--dur-3) var(--ease); pointer-events: none; }
.tabbar button:focus-visible { outline-offset: -3px; }
.mode { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); border-left-width: 3px; }
.stat.high { border-left-color: var(--sev-high-stripe); } .stat.review { border-left-color: var(--sev-review-stripe); } .stat.ok { border-left-color: var(--ok-fg); }
.stat .big { font-size: var(--fs-num); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .lab { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.badge.ai { background: var(--info-bg); color: var(--info-fg); animation: none; }
.ai-label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
.ai-panel { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--info-fg); border-radius: var(--r-lg); padding: var(--sp-6); display: grid; gap: var(--sp-4); }
.ai-headline { font-size: var(--fs-lg); font-weight: 600; line-height: 1.3; }
.priorities { margin: 0; padding-left: var(--sp-6); display: grid; gap: var(--sp-4); }
.priorities p { margin-top: var(--sp-1); }
.warns { margin: 0; padding-left: var(--sp-6); display: grid; gap: var(--sp-2); }
.refresh { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.chip-sep { width: 1px; background: var(--border-strong); margin: 0 var(--sp-1); }
.filter-selects { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.filter-selects .field { min-width: min(260px, 100%); }
.upl { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: var(--fs-sm); }
.mini { margin: var(--sp-1) 0 0; padding-left: var(--sp-6); font-size: var(--fs-sm); }
/* spreadsheet */
.sheet-wrap { max-height: 70vh; overflow: auto; }
.sheet th.sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; min-width: 150px; box-shadow: 1px 0 0 var(--border); }
.sheet thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); }
.sheet thead th.sticky { z-index: 3; }
.sheet tbody th.sticky { height: 44px; font-weight: 500; font-size: var(--fs-sm); line-height: 1.25; padding-top: 2px; padding-bottom: 2px; }
.sheet th .rid { display: block; }
.cellbtn { all: unset; box-sizing: border-box; position: relative; min-height: 40px; min-width: 40px; width: 100%; display: inline-flex; align-items: center; justify-content: flex-end; padding: 0 var(--sp-1); cursor: pointer; border-radius: var(--r-sm); font-variant-numeric: tabular-nums; transition: background-color var(--dur-1) var(--ease); }
.cellbtn:hover { background: var(--row-selected); }
.cellbtn:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.cellbtn[data-open]::after, .swatch::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 10px 10px 0; border-color: transparent var(--sev-review-stripe) transparent transparent; }
.swatch { position: relative; display: inline-block; width: 10px; height: 10px; vertical-align: middle; border: 1px solid var(--border-strong); }
.legend { display: flex; align-items: center; gap: var(--sp-2); }
.sugs { margin-top: var(--sp-8); }
/* chat */
.chat-log { display: grid; gap: var(--sp-3); min-height: 160px; max-height: 55vh; overflow: auto; padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); align-content: start; }
.msg { display: grid; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--border); max-width: 92%; animation: fadein var(--dur-2) var(--ease); }
.msg.user { background: var(--row-selected); justify-self: end; }
.msg.user.failed { opacity: .8; }
.msg.ai { background: var(--surface); border-left: 3px solid var(--info-fg); justify-self: start; }
.msg.err { background: var(--sev-high-bg); border-color: var(--sev-high-stripe); }
.who-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.answer { white-space: pre-wrap; overflow-wrap: anywhere; }
.ask-form { display: grid; gap: var(--sp-2); }
@media (max-width: 640px) { .tabbar { padding: 0 var(--sp-2); } .msg { max-width: 100%; } .topbar .brand-word { display: none; } }

/* the real file input is visually hidden; show its focus on the button label */
#file:focus-visible ~ .drop .btn { outline: 2px solid var(--focus); outline-offset: 2px; }

/* roles */
.role-select { width: auto; min-width: 112px; }
#role-badge:empty { display: none; }
dialog .actions { justify-content: flex-end; }
td .btn { min-height: 40px; }

/* column matching */
.check { display: flex; align-items: center; gap: var(--sp-2); font-weight: 500; }
.check input { width: 1.125rem; height: 1.125rem; }
.check[hidden] { display: none; }
td select { min-width: 14rem; max-width: 100%; }

/* home dashboard: one card per section; picking one opens it with the tabs on top */
.dash { max-width: 1040px; margin: 0 auto; }
.dash-grid { list-style: none; margin: var(--sp-6) 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: var(--sp-4); }
.dash-card { position: relative; display: flex; flex-direction: column; gap: var(--sp-2); height: 100%; padding: var(--sp-6); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); color: inherit; text-decoration: none; transition-property: border-color, box-shadow, transform; transition-duration: var(--dur-2); transition-timing-function: var(--ease); }
.dash-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-pop); transform: translateY(-2px); }
.dash-card:active { transform: translateY(0) scale(.99); transition-duration: var(--dur-1); }
.dash-card:focus-visible { outline-offset: 3px; }
.dash-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: var(--sp-2); border-radius: var(--r-md); background: var(--info-bg); color: var(--info-fg); }
.dash-icon svg { width: 22px; height: 22px; }
.dash-card h2 { font-size: var(--fs-lg); }
.dash-card p { color: var(--text-2); }
.dash-go { margin-top: auto; padding-top: var(--sp-2); color: var(--accent); font-size: var(--fs-sm); font-weight: 500; }
.dash-go span { display: inline-block; transition: transform var(--dur-2) var(--ease); }
.dash-card:hover .dash-go span { transform: translateX(3px); }
@media (prefers-reduced-motion: reduce) { .dash-card, .dash-card:hover, .dash-card:active, .dash-card:hover .dash-go span { transform: none; } }

/* motion: screens and banners ease in; same-site page changes cross-fade with the logo gliding between pages */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }
.dash-grid > li { animation: rise var(--dur-3) var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
.banner { animation: drop var(--dur-2) var(--ease) both; }
.tabbar button:active { background: var(--border); }
@media (prefers-reduced-motion: no-preference) { @view-transition { navigation: auto; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 260ms; animation-timing-function: cubic-bezier(0.2, 0, 0, 1); }
.topbar .mark { view-transition-name: tally-logo; }

/* flag details open as a row under the picked flag */
tbody tr.detail-row, tbody tr.detail-row:hover { background: var(--canvas); }
.detail-row > td { height: auto; padding: var(--sp-3); }
/* stays in view when the table is wider than the screen and scrolls sideways */
.detail-row .panel { position: sticky; left: var(--sp-3); top: auto; max-width: calc(100vw - 2 * var(--sp-4) - 2 * var(--sp-3)); max-height: none; overflow: visible; }

/* demo login: the credentials under the sign-in card, and a reminder inside the demo that nothing is saved */
.demo-login { display: grid; gap: var(--sp-2); padding: var(--sp-4); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }
.demo-cred { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); }
.demo-cred code { padding: 2px var(--sp-2); border-radius: var(--r-sm); background: var(--info-bg); color: var(--info-fg); font-weight: 500; }
.demo-note { font-size: var(--fs-sm); color: var(--text); background: var(--info-bg); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); }
.demo-sample { border-color: var(--accent); }
