* { box-sizing: border-box; }
html { height: 100%; }
body { min-height: 100%; margin: 0; color: var(--text); background: var(--canvas); font: 15px/1.5 var(--font); letter-spacing: 0; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { min-width: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 1000; top: -60px; left: 16px; padding: 10px 14px; color: #fff; background: var(--sidebar); }
.skip-link:focus { top: 12px; }
.staging-banner { max-width: 100vw; min-height: 34px; padding: 7px 16px; color: #71440b; background: #fff5df; border-bottom: 1px solid #ebd3a2; overflow-wrap: anywhere; text-align: center; font-size: 13px; font-weight: 700; }
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 34px); }
.sidebar { display: flex; flex-direction: column; min-width: 0; padding: 22px 14px; color: #fff; background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 20px; }
.brand > span { display: grid; place-items: center; width: 42px; height: 38px; border-radius: 6px; color: #fff; background: var(--accent); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 20px; }
.brand small { color: #b8c7d5; }
#primary-navigation { display: grid; gap: 3px; overflow-y: auto; padding: 5px 0; }
.nav-button { width: 100%; padding: 9px 12px; color: #dce4ef; background: transparent; border: 0; border-radius: 6px; text-align: left; cursor: pointer; }
.nav-button:hover { color: #fff; background: var(--sidebar-hover); }
.nav-button[aria-current="page"] { color: var(--sidebar); background: var(--sidebar-active); font-weight: 700; }
.nav-group { margin: 13px 12px 4px; color: #9fb4c5; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.sidebar-footer { display: grid; gap: 3px; margin-top: auto; padding: 16px 10px 0; color: #b8c7d5; border-top: 1px solid #31506a; font-size: 12px; }
.workspace { min-width: 0; padding: 28px 34px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 12px; font-weight: 800; text-transform: uppercase; }
h1, h2, h3, p { letter-spacing: 0; overflow-wrap: anywhere; }
h1 { margin: 0; font-size: 30px; line-height: 1.2; }
h2 { margin: 0 0 14px; font-size: 22px; }
h3 { margin: 0 0 8px; font-size: 16px; }
.topbar-actions, .button-row, .dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.button { min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 700; }
.button.primary { color: #fff; background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { color: var(--text); background: var(--surface); border-color: var(--line); }
.button.danger { color: var(--danger); background: var(--surface); border-color: #dfaaaa; }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.live-status { min-height: 25px; margin: 13px 0 18px; color: var(--muted); }
#main-content { min-width: 0; }
.page-grid, .metric-grid, .split-grid { display: grid; gap: 16px; }
.page-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split-grid { grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); }
.split-grid > :only-child { grid-column: 1 / -1; }
.panel, .metric-card { min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel.wide { grid-column: 1 / -1; }
.metric-card .value { margin: 6px 0 2px; font-size: 28px; font-weight: 800; }
.muted, .helper { color: var(--muted); }
.helper { font-size: 13px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 750; }
.status.success { color: var(--success); background: var(--success-bg); }
.status.warning { color: var(--warning); background: var(--warning-bg); }
.status.danger { color: var(--danger); background: var(--danger-bg); }
.status.info, .status.neutral { color: var(--info); background: var(--info-bg); }
.table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.table-wrap:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
table { width: 100%; max-width: 100%; table-layout: fixed; border-collapse: collapse; background: var(--surface); }
caption { padding: 12px; color: var(--muted); text-align: left; }
th, td { min-width: 0; padding: 11px 13px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; text-align: left; vertical-align: top; }
th { background: var(--surface-subtle); }
tr:last-child td { border-bottom: 0; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, fieldset legend { font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--text); background: var(--surface); border: 1px solid #8fa4b5; border-radius: 6px; }
.field textarea { min-height: 96px; resize: vertical; }
fieldset { margin: 0 0 15px; padding: 15px; border: 1px solid var(--line); border-radius: 6px; }
.choice { display: flex; gap: 9px; align-items: flex-start; margin: 9px 0; }
.empty, .error, .notice { padding: 18px; border-radius: 6px; }
.empty { color: var(--muted); border: 1px dashed #92a6b6; text-align: center; }
.error { color: var(--danger); background: var(--danger-bg); border: 1px solid #e4b2b2; }
.notice { color: var(--text); background: var(--info-bg); border: 1px solid #b9cbd8; }
.chat-log { min-height: 220px; max-height: 430px; overflow-y: auto; user-select: text; -webkit-user-select: text; }
.chat-message { margin: 0 0 12px; padding: 12px 14px; border-radius: 6px; background: var(--surface-subtle); }
.chat-message.user { border-left: 4px solid var(--accent); }
.voice-state { display: flex; align-items: center; gap: 12px; }
.voice-indicator { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.voice-indicator.listening { background: var(--success); box-shadow: 0 0 0 5px var(--success-bg); }
.drop-zone { padding: 32px; border: 2px dashed #8fa4b5; border-radius: 6px; text-align: center; }
.drop-zone.dragging { border-color: var(--accent); background: var(--accent-soft); }
dialog { width: min(520px, calc(100% - 32px)); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 50px rgba(16,42,67,.22); }
dialog::backdrop { background: rgba(16,42,67,.55); }
.dialog-actions { justify-content: flex-end; margin-top: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  #primary-navigation { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 260px; }
  .sidebar-footer { display: none; }
  .workspace { padding: 22px 18px 34px; }
  .topbar, .split-grid { display: grid; grid-template-columns: 1fr; }
  .page-grid, .metric-grid { grid-template-columns: 1fr; }
}
@media (forced-colors: active) {
  :focus-visible { outline-color: Highlight; }
  .status, .button, .panel, .metric-card, .drop-zone, .field input, .field select, .field textarea, .table-wrap { border: 1px solid CanvasText; forced-color-adjust: auto; }
  .nav-button[aria-current="page"] { outline: 2px solid Highlight; }
  .status::before { content: "Status: "; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
