:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --surface: #fff;
  --ink: #171c29;
  --muted: #5b6476;
  --line: #e0e4ec;
  --nav: #101623;
  --nav-card: #1c2637;
  --accent: #ac243b;
  --accent-hover: #8d1c31;
  --soft-red: #fcecef;
  --soft-green: #e7f4ed;
  --soft-amber: #fbf0db;
  --radius: 16px;
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main { min-width: 0; }
a { color: var(--accent); }
button, input, select { font: inherit; }
button, .button, select, input { min-height: 42px; }
button, .button {
  display: inline-flex; gap: 7px; align-items: center; justify-content: center; padding: 9px 15px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink);
  text-decoration: none; font-weight: 650; cursor: pointer;
}
button:hover, .button:hover { background: #f1f3f7; }
button:disabled { cursor: default; opacity: .55; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-hover); }
input:not([type="checkbox"]), select {
  min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  color: var(--ink); padding: 8px 10px;
}
:focus-visible { outline: 3px solid #6178bd; outline-offset: 2px; }
.skip { position: absolute; left: 12px; top: -80px; padding: 10px; background: #fff; z-index: 5; }
.skip:focus { top: 12px; }
.shell { display: grid; grid-template-columns: 254px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--nav); color: #edf0f6; padding: 30px 16px 22px; display: flex; flex-direction: column;
  gap: 37px; height: 100vh; position: sticky; top: 0;
}
.brand { display: inline-flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; margin-inline: 10px; }
.brand-mark {
  display: grid; place-items: center; height: 42px; width: 42px; background: #d74355; color: #fff;
  border-radius: 12px; font: 800 26px/1 "Segoe UI", sans-serif; letter-spacing: -2px; padding-right: 2px;
}
.brand strong { display: block; font-size: 16px; letter-spacing: .17em; line-height: 1.2; }
.brand small { display: block; color: #acb6cc; font-size: 13px; margin-top: 3px; }
nav { display: grid; gap: 5px; }
nav a { border-radius: 9px; color: #c2cadb; display: flex; min-height: 41px; align-items: center; padding: 9px 12px; text-decoration: none; font-size: 14px; }
nav a:hover { background: var(--nav-card); }
nav a[aria-current="page"] { background: var(--nav-card); color: white; box-shadow: inset 3px 0 #eb5d70; font-weight: 650; }
.sidebar-foot {
  margin-top: auto; display: flex; gap: 10px; align-items: baseline; padding: 13px 10px 0;
  border-top: 1px solid #293347; font-size: 13px;
}
.foot-sub { display: block; color: #a4aec1; font-size: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #56c39a; flex: none; }
.workspace {
  min-height: 72px; background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 32px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
}
.workspace-selector, .date-label, .workspace-actions, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.workspace-selector > span, .date-label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.workspace select { font-weight: 650; }
.content { margin: 0 auto; padding: 30px 32px 44px; max-width: 1500px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(29px, 3vw, 43px); letter-spacing: -.045em; line-height: 1.13; }
h2 { font-size: 20px; letter-spacing: -.024em; line-height: 1.3; }
h3 { font-size: 16px; }
.page-head p { color: var(--muted); margin-top: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: grid; gap: 14px; min-width: 0; }
.panel, .kpi { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel { padding: 19px; }
.panel h2 + p, .panel h3 + p { margin-top: 5px; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-title p { color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.kpi { display: flex; flex-direction: column; padding: 15px 17px; color: inherit; text-decoration: none; }
.kpi:hover { border-color: #b7becb; }
.kpi strong { display: block; margin: 9px 0 4px; font-size: clamp(20px, 2.2vw, 32px); line-height: 1.16; letter-spacing: -.035em; overflow-wrap: anywhere; }
.kpi .late { color: var(--accent); }
.two { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; }
.bucket { display: grid; grid-template-columns: minmax(108px, 1fr) minmax(85px, 2fr) auto; align-items: center; gap: 9px; margin: 9px 0; font-size: 13px; }
.bucket strong { text-align: right; }
meter { width: 100%; height: 12px; accent-color: #6f80a3; }
meter::-webkit-meter-bar { background: #edf0f6; border: 0; border-radius: 9px; }
meter::-webkit-meter-optimum-value { background: #7f8fb4; border-radius: 9px; }
.late-bar meter::-webkit-meter-optimum-value { background: #c94a60; }
.late-bar meter { accent-color: #c94a60; }
.recommendation { display: grid; gap: 10px; background: #f8f9fc; border-radius: 11px; padding: 14px; }
.recommendation .actions { gap: 8px; }
.attention { color: #941d31; }
.badge {
  display: inline-block; border-radius: 6px; background: #eef1f7; color: #484f62;
  padding: 3px 7px; font-size: 12px; font-weight: 650; line-height: 1.45;
}
.badge.danger { background: var(--soft-red); color: #931d31; }
.badge.ok { background: var(--soft-green); color: #20593f; }
.badge.warn { background: var(--soft-amber); color: #754500; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 10px 9px; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; font-weight: 680; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-label { color: var(--ink); display: block; font-weight: 650; overflow-wrap: anywhere; }
.text-link { min-height: 0; display: inline; background: transparent; padding: 0; border: 0; color: var(--accent); text-align: left; }
.text-link:hover { background: transparent; text-decoration: underline; }
.notice { padding: 12px 15px; border: 1px solid #cbd7ed; background: #edf3fc; border-radius: 10px; margin-bottom: 12px; }
.notice.error { border-color: #f0c3cb; background: var(--soft-red); color: #721b29; }
.empty { padding: 18px 0; color: var(--muted); }
.controls { display: flex; align-items: end; gap: 9px; flex-wrap: wrap; }
.controls label, .mapping label, .chat-input label { display: grid; gap: 5px; min-width: 0; }
.controls label span, .mapping label span, .chat-input label span { font-size: 13px; color: var(--muted); }
.mapping { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 9px; }
.mapping select { width: 100%; }
.import-section { gap: 16px; }
.import-section ol { margin: 5px 0 0; padding-left: 20px; }
.alert-row { padding: 10px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.alert-row:last-child { border-bottom: 0; }
.alert-row small { display: block; color: var(--muted); }
.chat-log { display: grid; gap: 12px; }
.bubble { border-radius: 10px; padding: 12px 14px; background: #edf1f8; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user { background: var(--soft-red); margin-left: 15%; }
.chat-input { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.chat-sources { margin: 4px 0 0; padding-left: 20px; }
dialog { width: min(92vw, 730px); max-height: 88vh; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); padding: 20px; }
dialog::backdrop { background: rgb(16 24 40 / .65); }
dialog form { margin-top: 14px; }
@media (max-width: 1080px) {
  .shell { grid-template-columns: 210px minmax(0, 1fr); }
  .content, .workspace { padding-inline: 21px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; gap: 11px; padding: 12px 10px 7px; }
  .sidebar-foot { display: none; }
  nav { display: flex; overflow-x: auto; }
  nav a { flex: none; white-space: nowrap; }
  .workspace { align-items: start; flex-direction: column; }
  .content, .workspace { padding-inline: 12px; }
  .content { padding-top: 19px; }
  .two { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 13px; }
  .kpi { padding: 11px; }
}
@media (max-width: 370px) {
  .bucket { grid-template-columns: minmax(100px, 1fr) minmax(40px, 1fr) auto; gap: 5px; font-size: 12px; }
  .workspace-actions { gap: 5px; }
}

.agent-grid { gap: 16px; }
.agent-grid details summary { cursor: pointer; }
.agent-grid .alert-row + form { margin-top: 12px; }
.hosted-print { display: none; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body:has(.hosted-print) .shell, body:has(.hosted-print) dialog { display: none !important; }
  .hosted-print { display: block; font-size: 10pt; color: #000; }
  .hosted-print th, .hosted-print td { padding: 4px 6px; overflow-wrap: anywhere; }
  .hosted-print tr { break-inside: avoid; }
}
