/* natui runtime styles. Colors come from theme.css, generated from the spec. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--reading-bg);
  color: var(--text);
  font: var(--font-size)/1.4 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}
svg { display: block; overflow: hidden; }
svg text { fill: currentColor; font-size: var(--font-size); }
.icon-defs { position: absolute; width: 0; height: 0; }
[hidden] { display: none !important; }

/* Shell grid: menu bar on top, rail on the left, status bar at the bottom. */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: var(--menubar-h) minmax(0, 1fr) var(--statusbar-h);
  height: 100vh;
}
.menubar, .statusbar { grid-column: 1 / 3; display: flex; align-items: stretch; background: var(--chrome); }
.menubar { border-bottom: 1px solid var(--border); }
.statusbar { border-top: 1px solid var(--border); color: var(--text-muted); }
.menubar-spacer { flex: 1; min-width: 8px; }
.menubar-menus, .menubar-brand { flex: none; }
.menubar-brand .brand { font-size: 15px; font-weight: 600; fill: var(--text); }
a.brand-mark { cursor: pointer; outline: none; }
/* The product mark (ui/brand/logo.svg) keeps its contrast on the light chrome. */
html[data-theme="light"] .product-logo { --logo-hi: #2f6fcc; --logo-mid: #1d5bb8; --logo-core: #157a5e; }
a.brand-mark:hover .hit { fill: var(--hover); }
a.brand-mark:focus-visible .hit { stroke: var(--focus); stroke-width: 2; }
.menubar-search { flex: 0 1 440px; min-width: 160px; color: var(--text-muted); }
.search-box { fill: var(--input); stroke: var(--border); }
.menubar-search:focus-within .search-box { stroke: var(--focus); stroke-width: 2; }
.menubar-search input {
  width: calc(100% - 44px); height: 28px; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; padding: 0;
}
.menubar-search input::placeholder { color: var(--text-muted); opacity: 1; }
.menubar-user { flex: none; margin-right: 8px; }
.avatar-bg { fill: var(--accent); }
.avatar-initials { fill: var(--accent-text); font-weight: 600; font-size: 12px; }
.menubar-user .avatar-ring { fill: none; stroke: transparent; stroke-width: 2; }
.menubar-user[data-user-switch] { cursor: pointer; outline: none; }
.menubar-user[data-user-switch]:hover .avatar-ring,
.menubar-user[aria-expanded="true"] .avatar-ring { stroke: var(--text-muted); }
.menubar-user[data-user-switch]:focus-visible .avatar-ring { stroke: var(--focus); }
/* Detail pane with a compose box: the content scrolls above a fixed box. */
.pane.has-compose { display: flex; flex-direction: column; overflow: hidden; }
.pane-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.compose { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 10px 16px 12px; border-top: 1px solid var(--border); background: var(--reading-bg); }
.compose-row { display: flex; gap: 8px; align-items: center; }
.compose-attach { flex: none; color: var(--text-muted); }
.compose-attach .attach-ring { fill: none; stroke: currentColor; stroke-width: 1.5; }
.compose-attach:hover, .compose-attach[aria-expanded="true"] { color: var(--accent); }
.compose-attach[aria-disabled="true"] { opacity: .4; }
.compose-refs { flex: none; }
.ref-chip rect { fill: var(--card); stroke: var(--border); }
.ref-chip { color: var(--accent); cursor: pointer; outline: none; }
.ref-chip text { fill: var(--text); font-size: 12px; }
.ref-chip:hover rect { fill: var(--hover); }
.ref-chip:focus-visible rect { stroke: var(--focus); stroke-width: 2; }
.ref-chip.pending use:last-of-type { color: var(--text-muted); }
.attach-input { width: 100%; height: 36px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; padding: 0; }
.attach-input::placeholder { color: var(--text-muted); opacity: 1; }
.lookup-row { color: var(--text); }
.lookup-row[aria-selected="true"] .hit { fill: var(--selected); }
.lookup-title { fill: var(--text); }
.lookup-subtitle, .lookup-kind { fill: var(--text-muted); font-size: 12px; }
.compose-field { flex: 1; min-width: 0; overflow: visible; }
.compose-box { fill: var(--input); stroke: var(--border); }
.compose-field:focus-within .compose-box { stroke: var(--focus); stroke-width: 2; }
.compose-input { width: calc(100% - 28px); height: 38px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; padding: 0; }
.compose-input::placeholder { color: var(--text-muted); opacity: 1; }
.compose-input:disabled { cursor: not-allowed; }
.compose-send { flex: none; color: var(--accent); }
.compose-send[aria-disabled="true"] { opacity: .4; }
.msg-meta { fill: var(--text-muted); font-size: 12px; }
.msg-text { fill: var(--text); }
.bubble { fill: var(--hover); }
.msg.mine .bubble { fill: var(--selected); }
.user-option .detail { fill: var(--text-muted); font-size: 12px; }
.user-option .check { color: var(--accent); }
.user-menu .menu-heading { fill: var(--text-muted); font-size: 12px; font-weight: 600; }

.rail { grid-row: 2; display: flex; flex-direction: column; background: var(--chrome); border-right: 1px solid var(--border); }
.rail-spacer { flex: 1; }
.rail-item { color: var(--text-muted); cursor: pointer; }
.rail-item .indicator { fill: var(--accent); opacity: 0; }
.rail-item[aria-selected="true"] { color: var(--accent); }
.rail-item[aria-selected="true"] .indicator { opacity: 1; }
.rail-item[aria-selected="true"] .hit { fill: var(--hover); }
.badge-count rect { fill: var(--danger); }
.badge-count text { fill: var(--danger-text); font-size: 10.5px; font-weight: 700; }

.views { grid-row: 2; grid-column: 2; display: flex; min-width: 0; min-height: 0; }
.view { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.commandbar { flex: none; display: flex; align-items: center; height: var(--commandbar-h); background: var(--command-bar); border-bottom: 1px solid var(--border); overflow: hidden; }
.commandbar > svg { flex: none; }
.commandbar > .view-search { flex: 0 1 440px; min-width: 200px; margin-left: 12px; color: var(--text-muted); }
.view-search:focus-within .search-box { stroke: var(--focus); stroke-width: 2; }
.view-search input {
  width: calc(100% - 44px); height: 30px; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; padding: 0;
}
.view-search input::placeholder { color: var(--text-muted); opacity: 1; }
.panes { display: flex; flex: 1; min-height: 0; }
.pane { flex: none; overflow-y: auto; overflow-x: hidden; min-height: 0; position: relative; }
.pane.fill { flex: 1; min-width: 280px; }
.pane-nav { background: var(--nav-bg); }
.pane.has-filters { display: flex; flex-direction: column; overflow: hidden; container-type: inline-size; }
.list-filters { flex: none; max-height: 60%; overflow: auto; padding: 10px 16px 14px; border-top: 1px solid var(--border); }
.list-filters h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.filter-fields { display: grid; gap: 6px; }
.filter-fields label { display: grid; grid-template-columns: minmax(52px, 1fr) minmax(0, 2fr); gap: 6px; align-items: center; color: var(--text-muted); font-size: 12px; }
.filter-fields input, .filter-fields select, .list-filters button {
  min-width: 0; min-height: 30px; padding: 3px 6px; border: 1px solid var(--text-muted); border-radius: 4px;
  background: var(--input); color: var(--text); font: inherit;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@container (max-width: 205px) { .filter-fields label { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.list-filters button { margin-top: 8px; cursor: pointer; }
.list-filters :is(input, select, button):focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.pane-list { background: var(--list-bg); }
.pane-detail { background: var(--reading-bg); }
.pane-svg { width: 100%; }
.splitter { flex: none; width: 1px; background: var(--border); position: relative; cursor: col-resize; outline: none; }
.splitter::after { content: ""; position: absolute; inset: 0 -3px; }
.splitter:hover, .splitter:focus-visible { background: var(--focus); }

/* Interactive SVG elements: transparent hit rectangles that light up. */
.hit { fill: transparent; }
[role="menuitem"], [role="button"], [role="tab"], [role="option"], [role="treeitem"], .cmd-btn { cursor: pointer; outline: none; }
.menu-title:hover .hit, .menu-title[aria-expanded="true"] .hit,
.cmd-btn:hover .hit, .rail-item:hover .hit, .menu-item:hover .hit,
.nav-item:hover .hit, .row:hover .bg { fill: var(--hover); }
.menu-title:focus-visible .hit, .cmd-btn:focus-visible .hit, .rail-item:focus-visible .hit,
.menu-item:focus .hit, .nav-item:focus-visible .hit, .row:focus-visible .bg {
  stroke: var(--focus); stroke-width: 2; fill: var(--hover);
}
.cmd-btn { color: var(--text); }
.cmd-btn use { color: var(--accent); }
.cmd-btn[aria-disabled="true"] { opacity: 0.4; cursor: default; }
.cmd-btn[aria-disabled="true"]:hover .hit { fill: transparent; }
.menu-title { color: var(--text); }

/* Overlay: drop-down menus, dialogs, and toasts float above the panes. */
.overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 10; }
.overlay > g:not([hidden]) { pointer-events: auto; }
.menu-card, .dialog-card { fill: var(--card); stroke: var(--border); filter: drop-shadow(0 6px 16px rgba(0,0,0,.5)); }
.menu-item { color: var(--text); }
.menu-item use { color: var(--text-muted); }
.menu-item .shortcut { fill: var(--text-muted); font-size: 12px; }
.menu-item[aria-disabled="true"] { opacity: 0.45; }
.menu-sep { stroke: var(--border); }
.toast rect { fill: var(--card); stroke: var(--border); }
.toast text { fill: var(--text); }
.dialog-scrim { fill: rgba(0,0,0,.5); }
.dialog-card + text, .dialog text { fill: var(--text); }
.dialog .btn rect { fill: var(--input); stroke: var(--border); }
.dialog .btn.primary rect { fill: var(--accent); stroke: none; }
.dialog .btn.primary text { fill: var(--accent-text); font-weight: 600; }
.dialog .btn:focus-visible rect { stroke: var(--focus); stroke-width: 2; }
.dialog .btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.dialog-form { display: flex; flex-direction: column; gap: 14px; color: var(--text); font: inherit; }
.dialog-form label { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.dialog-form select { display: block; width: 100%; box-sizing: border-box; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--input); color: var(--text); font: inherit; }
.dialog-form select:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.dialog-form textarea, .dialog-form input { display: block; width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--input); color: var(--text); font: inherit; }
.dialog-form textarea { resize: vertical; min-height: 84px; }
.dialog-form textarea:focus, .dialog-form input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.dialog-form ::placeholder { color: var(--text-muted); opacity: 1; }
.dialog-form .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.dialog-form .chips:empty { display: none; }
.dialog-form .chip { padding: 3px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.dialog-form .chip:hover { background: var(--hover); }
.dialog-form .chip:focus-visible { outline: 2px solid var(--focus); }
.dialog-form .hint { margin-top: 6px; color: var(--text-muted); font-size: 12px; }
.msg-tag { fill: var(--warning); font-weight: 600; }
/* Annotations: yellow, in place of the recorded value. */
.annotated .field-value { fill: var(--warning-text); font-weight: 600; }
.annotated-bg { fill: var(--warning); }
/* A detail shown as it was at an earlier time. */
.asof-banner > rect { fill: var(--warning); fill-opacity: .16; stroke: var(--warning); stroke-opacity: .5; }
.asof-banner text { fill: var(--text); }
.asof-back text { fill: var(--text); font-weight: 600; }
.history-list { display: flex; flex-direction: column; gap: 2px; max-height: 100%; overflow-y: auto; }
.history-row { display: grid; grid-template-columns: 150px 140px 1fr; gap: 12px; align-items: baseline; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.history-row:hover { background: var(--hover); }
.history-row:focus-visible { outline: 2px solid var(--focus); }
.history-row .when, .history-row .who { color: var(--text-muted); font-size: 12px; }
.history-list .hint, .dialog-form p.hint { margin: 0; color: var(--text-muted); font-size: 12px; }
/* Dashboard tiles. */
.tile-title { font-size: 15px; font-weight: 600; fill: var(--text); }
.tile-row, .tile-head { cursor: pointer; outline: none; }
.tile-row:hover .hit, .tile-head:hover .hit { fill: var(--hover); }
.tile-row:focus-visible .hit, .tile-head:focus-visible .hit { stroke: var(--focus); stroke-width: 2; fill: var(--hover); }
.tile-primary { fill: var(--text); }
.tile-row.bold .tile-primary { font-weight: 600; }
.tile-secondary, .tile-meta { fill: var(--text-muted); font-size: 12px; }

/* Pane content drawn by the runtime. */
.pane-title { font-size: 15px; font-weight: 600; fill: var(--text); }
.group-label { font-size: 12px; font-weight: 600; fill: var(--text-muted); }
.nav-item { color: var(--text-muted); }
.nav-item text { fill: var(--text); }
.nav-item .count { fill: var(--accent); font-weight: 600; font-size: 12px; }
.nav-item[aria-selected="true"] .hit { fill: var(--selected); }
.row .bg { fill: transparent; }
.row .sep { stroke: var(--border); }
.row[aria-selected="true"] .bg { fill: var(--selected); }
.row[aria-selected="true"] .bar { fill: var(--accent); }
.row .bar { fill: transparent; }
.row .primary { font-size: 14px; fill: var(--text); }
.row.bold .primary { font-weight: 600; }
.row.bold .bar { fill: var(--accent); }
.row .secondary { fill: var(--text); }
.row.bold .secondary { fill: var(--accent); font-weight: 600; }
.row .preview, .row .meta { fill: var(--text-muted); font-size: 12px; }
.badge rect { fill: none; stroke: var(--border); }
.badge text { font-size: 11px; fill: var(--text-muted); }
.empty { fill: var(--text-muted); }

.detail-title { font-size: 20px; font-weight: 600; fill: var(--text); }
.detail-subtitle { fill: var(--text-muted); }
.chip rect { fill: none; }
.chip text { font-size: 12px; font-weight: 600; }
.section-card { fill: var(--card); stroke: var(--border); }
.section-title { font-size: 12px; font-weight: 600; fill: var(--text-muted); letter-spacing: .04em; text-transform: uppercase; }
.field-label { fill: var(--text-muted); }
.field-value, .cell, .tl-text, .body-text { fill: var(--text); }
.th { fill: var(--text-muted); font-size: 12px; font-weight: 600; }
.table-sep { stroke: var(--border); }
.tl-when { fill: var(--text-muted); font-size: 12px; }
.tl-dot { fill: var(--accent); }
.tl-line { stroke: var(--text-muted); stroke-opacity: .45; stroke-width: 1.5; }
.detail-actions .cmd-btn use { color: var(--accent); }

/* Tones for flags, chips, and status items. */
.tone-neutral { color: var(--text-muted); }
.tone-accent { color: var(--accent); }
.tone-success { color: var(--success); }
.tone-warning { color: var(--warning); }
.tone-danger { color: var(--danger); }
.chip.tone-accent rect { stroke: var(--accent); } .chip.tone-accent text { fill: var(--accent); }
.chip.tone-success rect { stroke: var(--success); } .chip.tone-success text { fill: var(--success); }
.chip.tone-warning rect { stroke: var(--warning); } .chip.tone-warning text { fill: var(--warning); }
.chip.tone-danger rect { stroke: var(--danger); } .chip.tone-danger text { fill: var(--danger); }
.chip.tone-neutral rect { stroke: var(--border); } .chip.tone-neutral text { fill: var(--text-muted); }
.status-item text { font-size: 12px; }
.status-item.tone-neutral text { fill: var(--text-muted); }
.status-item use { color: inherit; }
.status-item.tone-success text { fill: var(--text-muted); }

@media (prefers-reduced-motion: no-preference) {
  .row .bg, .hit { transition: fill .08s linear; }
}
@media print {
  .rail, .menubar, .commandbar, .statusbar, .pane-nav, .pane-list, .splitter, .overlay { display: none !important; }
  .app { display: block; height: auto; }
  body { overflow: visible; }
}
.pane-tiles { background: var(--reading-bg); }

/* Links in table cells, such as filed documents. */
.cell-link .cell { fill: var(--accent); text-decoration: underline; }
.record-link { cursor: pointer; outline: none; }
.record-link text { fill: var(--accent); }
.record-link:hover text { text-decoration: underline; }
.record-link .link-focus { fill: transparent; }
.record-link:focus-visible .link-focus { stroke: var(--focus); stroke-width: 2; }
.cell-link:focus-visible { outline: 2px solid var(--focus); }

/* Bookmark toggle in a detail header: a white outline, or filled and blue when on. */
/* A tile's group heading (tile groupBy); its items are indented under it. */
.tile-group { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; fill: var(--text-muted); }

/* Live updates (ADR 0019): a changed row or value glows once in the accent
   color and fades. One pulse, well under three flashes a second. */
.flash { fill: var(--accent); opacity: 0; pointer-events: none; animation: natui-flash 2.3s ease-out 1 both; }
@keyframes natui-flash { 0% { opacity: 0; } 13% { opacity: .32; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .flash { animation: natui-flash-still 2s step-end 1 both; }
  @keyframes natui-flash-still { 0% { opacity: .32; } 100% { opacity: 0; } }
}

/* Dashboard buttons for everyday processes (a tile with commands). */
.tile-action-bg { fill: var(--input); stroke: var(--border); }
.tile-action:hover .tile-action-bg, .tile-action:focus-visible .tile-action-bg { stroke: var(--accent); }
.tile-action-label { fill: var(--text); font-weight: 600; }
.tile-action-key { fill: var(--text-muted); font-size: 12px; }

/* Calendar panes: a week of days by hours (pane type calendar). */
.cal-line { stroke: var(--border); stroke-width: 1; }
.cal-day { fill: var(--text-muted); font-size: 12px; font-weight: 600; }
.cal-hour { fill: var(--text-muted); font-size: 11px; }
.cal-item { cursor: pointer; outline: none; }
.cal-item .bg { fill: var(--card); stroke: var(--border); }
.cal-item:hover .bg { fill: var(--hover); }
.cal-item[aria-selected="true"] .bg { fill: var(--selected); stroke: var(--accent); }
.cal-item:focus-visible .bg { stroke: var(--focus); stroke-width: 2; }
.cal-item .primary { fill: var(--text); font-size: 12px; font-weight: 600; }
.cal-item .secondary { fill: var(--text-muted); font-size: 11px; }
.cal-nav { cursor: pointer; outline: none; }
.cal-nav rect { fill: var(--card); stroke: var(--border); }
.cal-nav:hover rect { fill: var(--hover); }
.cal-nav:focus-visible rect { stroke: var(--focus); stroke-width: 2; }
.cal-nav text { fill: var(--text); font-size: 12px; }
