/* Axis Platforms design system
 * Tokens, type scale and component styles taken from axisplatforms.ai.
 * The standalone extension uses system fonts without external font requests. */

:root {
  /* Brand */
  --axis-blue: #007AFF;
  --axis-blue-hover: #0066D6;
  --axis-blue-100: #E8F2FF;
  --axis-blue-200: #B3D7FF;
  --axis-blue-300: #5DA9FF;
  --axis-blue-700: #0055B3;
  --axis-blue-900: #003D80;
  --sidebar-bg: #2563EB;

  /* Surfaces */
  --bg-page: #FBFBFB;
  --bg-card: #FFFFFF;
  --bg-inset: #F2F2F7;
  --bg-hover: #E5E5EA;

  /* Ink */
  --text-primary: #1C1C1E;
  --text-muted: #48484A;
  --text-secondary: #8E8E93;
  --text-placeholder: #C7C7CC;

  /* Lines */
  --border: rgba(0, 0, 0, 0.05);
  --border-strong: rgba(0, 0, 0, 0.10);

  /* Semantic */
  --green: #00C805;
  --amber: #FF9F0A;
  --orange: #FF6B00;
  --red: #FF3B30;
  --purple: #BF5AF2;
  --indigo: #5E5CE6;
  --cyan: #64D2FF;
  --silver: #AEAEB2;

  /* Confidence ramp */
  --c-verified: #00A804;
  --c-verified-bg: #E7F9E8;
  --c-likely: #007AFF;
  --c-likely-bg: #E8F2FF;
  --c-uncertain: #E08800;
  --c-uncertain-bg: #FFF4E0;
  --c-notfound: #8E8E93;
  --c-notfound-bg: #F2F2F7;

  /* Geometry */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  --rail: 232px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--axis-blue); text-decoration: none; }

/* ==================================================================== *
 * Shell
 * ==================================================================== */

.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  gap: 22px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand svg { flex: 0 0 30px; }
.brand-name {
  font-size: 16.5px; font-weight: 600; letter-spacing: -0.01em; color: #fff;
}
.brand-sub {
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.07em;
  text-transform: uppercase; color: rgba(255, 255, 255, 0.72); margin-top: 1px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-md);
  background: transparent; border: 0; width: 100%;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13.5px; font-weight: 500; text-align: left;
  transition: background .14s ease, color .14s ease;
}
.nav-item:hover:not(:disabled) { background: rgba(255, 255, 255, 0.10); color: #fff; }
.nav-item[aria-current='true'] { background: #fff; color: #2563EB; font-weight: 600; }
.nav-item:disabled { opacity: .42; cursor: default; }
.nav-item .count {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  background: rgba(255, 255, 255, 0.18); padding: 1px 7px; border-radius: var(--radius-pill);
}
.nav-item[aria-current='true'] .count { background: var(--axis-blue-100); color: var(--axis-blue-700); }

.rail-foot {
  margin-top: auto; font-size: 11px; color: rgba(255, 255, 255, 0.6);
  padding: 0 6px; line-height: 1.45;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 30px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.015em; }
.topbar .sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 1px; }
.topbar .spacer { flex: 1; }

.view { padding: 26px 30px 60px; flex: 1; }
.view[hidden] { display: none; }

/* ==================================================================== *
 * Primitives
 * ==================================================================== */

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--bg-card);
  color: var(--text-primary); font-size: 13px; font-weight: 500;
  transition: background .14s ease, border-color .14s ease, transform .1s ease;
}
.btn:hover { background: var(--bg-inset); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary {
  background: var(--axis-blue); border-color: var(--axis-blue); color: #fff;
}
.btn-primary:hover { background: var(--axis-blue-hover); border-color: var(--axis-blue-hover); }
.btn-sm { padding: 5px 11px; font-size: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  font-family: var(--font-mono);
}
.chip.verified  { background: var(--c-verified-bg);  color: var(--c-verified); }
.chip.likely    { background: var(--c-likely-bg);    color: var(--c-likely); }
.chip.uncertain { background: var(--c-uncertain-bg); color: var(--c-uncertain); }
.chip.not_found { background: var(--c-notfound-bg);  color: var(--c-notfound); }
.chip.ocr       { background: #F3E8FF; color: #7B2CBF; }
.chip.neutral   { background: var(--bg-inset); color: var(--text-muted); }

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-secondary); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; }
.stat { padding: 15px 17px; }
.stat .k {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-secondary);
}
.stat .v {
  font-family: var(--font-mono); font-size: 25px; font-weight: 600;
  letter-spacing: -0.02em; margin-top: 5px; line-height: 1;
}
.stat .n { font-size: 11.5px; color: var(--text-secondary); margin-top: 5px; }

/* ==================================================================== *
 * Intake
 * ==================================================================== */

.intake-wrap { max-width: 960px; margin: 0 auto; }

.drop {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--bg-card); padding: 52px 30px; text-align: center;
  transition: border-color .16s ease, background .16s ease;
}
.drop.over { border-color: var(--axis-blue); background: var(--axis-blue-100); }
.drop h2 { margin: 16px 0 6px; font-size: 19px; font-weight: 600; letter-spacing: -0.015em; }
.drop p { margin: 0 0 18px; color: var(--text-secondary); font-size: 13.5px; }
.drop .glyph { color: var(--axis-blue); }

.pipeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 22px; }
.pipe-step { padding: 14px 15px; }
.pipe-step .n {
  font-family: var(--font-mono); font-size: 11px; color: var(--axis-blue); font-weight: 600;
}
.pipe-step .t { font-weight: 600; font-size: 13px; margin: 4px 0 3px; }
.pipe-step .d { font-size: 12px; color: var(--text-secondary); line-height: 1.42; }

/* ==================================================================== *
 * Processing — the scan animation
 * ==================================================================== */

.proc { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }

.scan-stage { padding: 18px; position: relative; }
.scan-frame {
  position: relative; border-radius: var(--radius-md); overflow: hidden;
  background: var(--bg-inset); aspect-ratio: 8.5 / 11;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.scan-frame canvas { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Sweep bar that tracks the page currently being read. */
.scan-frame::after {
  content: ''; position: absolute; left: 0; right: 0; height: 34%;
  top: -34%; pointer-events: none;
  background: linear-gradient(180deg,
    rgba(0, 122, 255, 0) 0%,
    rgba(0, 122, 255, 0.16) 55%,
    rgba(0, 122, 255, 0.42) 96%,
    rgba(0, 122, 255, 0.85) 100%);
  animation: sweep 1.9s cubic-bezier(.4, 0, .5, 1) infinite;
}
.scan-frame.done::after { animation: none; opacity: 0; }
@keyframes sweep {
  0%   { top: -34%; opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.scan-meta { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.scan-row { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; }
.scan-row .lab { color: var(--text-secondary); min-width: 74px; }
.scan-row .val { font-family: var(--font-mono); font-weight: 500; }

.bar { height: 5px; border-radius: var(--radius-pill); background: var(--bg-inset); overflow: hidden; }
.bar > i {
  display: block; height: 100%; width: 0%; border-radius: inherit;
  background: linear-gradient(90deg, var(--axis-blue-300), var(--axis-blue));
  transition: width .28s cubic-bezier(.4, 0, .2, 1);
}

/* Page grid — each tile lights up as its text lands */
.page-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(15px, 1fr));
  gap: 3px; margin-top: 16px;
}
.pg {
  aspect-ratio: 1 / 1.3; border-radius: 2px; background: var(--bg-inset);
  transition: background .3s ease, transform .3s ease;
}
.pg.text { background: var(--axis-blue-200); }
.pg.ocr  { background: #DDBBFF; }
.pg.now  { background: var(--axis-blue); transform: scale(1.35); }

/* Field stream */
.stream-head {
  display: flex; align-items: center; gap: 10px; padding: 15px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.stream-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.stream { max-height: 620px; overflow-y: auto; padding: 6px 0; }
.stream-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  padding: 8px 18px; border-bottom: 1px solid var(--border);
  animation: land .34s cubic-bezier(.2, .9, .3, 1) both;
}
.stream-row:last-child { border-bottom: 0; }
@keyframes land {
  from { opacity: 0; transform: translateY(-7px); }
  to   { opacity: 1; transform: none; }
}
.stream-row .lbl { font-size: 12.5px; font-weight: 500; }
.stream-row .vl {
  font-size: 12px; color: var(--text-muted); font-family: var(--font-mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px;
}
.stream-row .pg-ref { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }

/* ==================================================================== *
 * Abstract
 * ==================================================================== */

.abs-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filters input[type='search'] {
  padding: 7px 12px; border-radius: var(--radius-md); border: 1px solid var(--border-strong);
  font-family: inherit; font-size: 13px; min-width: 210px; background: var(--bg-card);
}
.filters input[type='search']:focus { outline: 2px solid var(--axis-blue-200); border-color: var(--axis-blue); }

.toggle {
  padding: 6px 12px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: var(--bg-card); font-size: 12px; font-weight: 500; color: var(--text-muted);
}
.toggle[aria-pressed='true'] { background: var(--axis-blue); border-color: var(--axis-blue); color: #fff; }

.group { margin-bottom: 14px; overflow: hidden; }
.group > summary {
  list-style: none; cursor: pointer; padding: 13px 18px;
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 14px; background: var(--bg-card);
  border-bottom: 1px solid transparent;
}
.group[open] > summary { border-bottom-color: var(--border); }
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before {
  content: '▸'; color: var(--text-secondary); font-size: 11px; transition: transform .15s ease;
}
.group[open] > summary::before { transform: rotate(90deg); }
.group .gcount { margin-left: auto; display: flex; gap: 5px; }

.field {
  display: grid; grid-template-columns: 218px 1fr; gap: 16px;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
}
.field:last-child { border-bottom: 0; }
.field:hover { background: #FCFCFD; }
.field.is-not_found { background: repeating-linear-gradient(45deg, #FAFAFB, #FAFAFB 9px, #F5F5F7 9px, #F5F5F7 18px); }
.field.approved { background: var(--c-verified-bg); }

.f-name { font-size: 13px; font-weight: 600; }
.f-key { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-placeholder); margin-top: 2px; }
.f-body { min-width: 0; }
.f-value { font-size: 13.5px; font-weight: 500; word-break: break-word; }
.f-value.none { color: var(--text-secondary); font-style: italic; font-weight: 400; }

.f-quote {
  margin-top: 8px; padding: 9px 12px; border-left: 3px solid var(--axis-blue-200);
  background: var(--bg-inset); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px; color: var(--text-muted); line-height: 1.55;
}
.f-quote::before { content: '“'; }
.f-quote::after  { content: '”'; }

.f-meta { margin-top: 8px; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; font-size: 11.5px; }
.f-cite {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-muted);
  background: var(--bg-inset); padding: 2px 8px; border-radius: var(--radius-sm);
}
.f-note { font-size: 11.5px; color: var(--c-uncertain); margin-top: 6px; }
.f-audit { font-size: 11.5px; color: var(--text-secondary); margin-top: 3px; }

.approve {
  margin-left: auto; display: flex; gap: 5px;
}

/* ==================================================================== *
 * Portfolio
 * ==================================================================== */

.tablewrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-card); }
table.grid { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.grid th, table.grid td {
  padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap; vertical-align: top;
}
table.grid th {
  position: sticky; top: 0; background: var(--bg-inset); z-index: 1;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 600; color: var(--text-muted); cursor: pointer; user-select: none;
}
table.grid th:hover { color: var(--axis-blue); }
table.grid th .dir { color: var(--axis-blue); }
table.grid tbody tr:hover { background: #FCFCFD; }
table.grid td.v { font-family: var(--font-mono); }
table.grid td .cell-cite { font-size: 10px; color: var(--text-placeholder); display: block; margin-top: 2px; font-family: var(--font-mono); }
.sticky-col { position: sticky; left: 0; background: var(--bg-card); z-index: 2; box-shadow: 1px 0 0 var(--border); }
table.grid th.sticky-col { background: var(--bg-inset); z-index: 3; }

/* ==================================================================== *
 * Calendar
 * ==================================================================== */

.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; font-size: 12px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }
.cal-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border-strong); border-radius: 2px;
}
.tl-year {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: var(--text-secondary); letter-spacing: .08em; margin: 18px 0 8px -26px;
  padding-left: 26px;
}
.tl-item { position: relative; padding: 10px 14px; margin-bottom: 8px; }
.tl-item::before {
  content: ''; position: absolute; left: -23px; top: 17px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--axis-blue); box-shadow: 0 0 0 3px var(--bg-page);
}
.tl-item.relative::before { background: var(--silver); }
.tl-item .when { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.tl-item .what { font-size: 13px; font-weight: 500; margin-top: 2px; }
.tl-item .who { font-size: 11.5px; color: var(--text-secondary); margin-top: 5px; display: flex; align-items: center; }
.tl-item .formula {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted);
  margin-top: 4px; line-height: 1.5; padding-left: 9px;
  border-left: 2px solid var(--border-strong);
}
.tl-item .what { font-size: 13.5px; font-weight: 600; }

/* ==================================================================== *
 * Deal picker + misc
 * ==================================================================== */

.deal-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.deal-tab {
  padding: 7px 14px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: var(--bg-card); font-size: 12.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
}
.deal-tab[aria-pressed='true'] { background: var(--axis-blue); border-color: var(--axis-blue); color: #fff; }
.deal-tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.empty { text-align: center; padding: 70px 20px; color: var(--text-secondary); }
.empty h3 { color: var(--text-primary); font-weight: 600; margin: 0 0 6px; font-size: 15px; }

.footnote {
  margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-secondary); line-height: 1.6;
}

@media (max-width: 1080px) {
  .proc { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 780px) {
  .rail { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .shell { flex-direction: column; }
  .nav { flex-direction: row; }
  .rail-foot { display: none; }
  .field { grid-template-columns: 1fr; gap: 6px; }
}

@media print {
  .rail, .filters, .approve, .topbar .btn { display: none !important; }
  .view { padding: 0; }
  .group { break-inside: avoid; }
}

/* ==================================================================== *
 * Anchor bar
 * ==================================================================== */

.anchors { padding: 0; margin-bottom: 16px; }
.anchors > summary {
  list-style: none; cursor: pointer; padding: 13px 18px;
  display: flex; align-items: baseline; gap: 10px; font-size: 13.5px;
}
.anchors > summary::-webkit-details-marker { display: none; }
.anchors > summary::before {
  content: '▸'; color: var(--text-secondary); font-size: 11px; transition: transform .15s ease;
}
.anchors[open] > summary::before { transform: rotate(90deg); }
.anchors[open] > summary { border-bottom: 1px solid var(--border); }

.anchor-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 12px; padding: 16px 18px 4px;
}
.anchor { display: flex; flex-direction: column; gap: 4px; }
.anchor .al { font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.anchor input[type='date'] {
  padding: 7px 10px; border-radius: var(--radius-md); border: 1px solid var(--border-strong);
  font-family: var(--font-mono); font-size: 12.5px; background: var(--bg-card); color: var(--text-primary);
}
.anchor input:focus { outline: 2px solid var(--axis-blue-200); border-color: var(--axis-blue); }
.anchor .as { font-size: 10.5px; font-family: var(--font-mono); }
.anchor .as.user  { color: var(--axis-blue); }
.anchor .as.lease { color: var(--c-verified); }
.anchor .as.open  { color: var(--c-uncertain); }
.anchor-note { margin: 10px 18px 16px; font-size: 11.5px; color: var(--text-secondary); line-height: 1.55; }

/* ==================================================================== *
 * Rent table
 * ==================================================================== */

table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid.rent tbody tr.abated { background: repeating-linear-gradient(45deg,#FAFAFB,#FAFAFB 9px,#F4F4F7 9px,#F4F4F7 18px); }
table.grid.rent tbody tr.yr-start td { border-top: 2px solid var(--border-strong); }
table.grid tfoot td {
  position: sticky; bottom: 0; background: var(--bg-inset);
  border-top: 2px solid var(--border-strong); font-variant-numeric: tabular-nums;
}
table.grid tfoot td.sticky-col { background: var(--bg-inset); z-index: 3; }
.tablewrap { max-height: 640px; overflow: auto; }

.prov { margin-top: 16px; padding: 15px 18px; }
.prov-h {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px;
}
.prov ul { margin: 0; padding-left: 17px; }
.prov li { font-size: 12.5px; color: var(--text-muted); line-height: 1.65; margin-bottom: 3px; }
.prov li.warn { color: var(--c-uncertain); }

/* ==================================================================== *
 * Calendar — month cells
 * ==================================================================== */

.cal-controls {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 16px 0 14px;
}
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-md); overflow: hidden; }
.seg-b {
  padding: 7px 13px; border: 0; background: var(--bg-card); font-size: 12.5px;
  font-weight: 500; color: var(--text-muted); border-right: 1px solid var(--border);
}
.seg-b:last-child { border-right: 0; }
.seg-b[aria-pressed='true'] { background: var(--axis-blue); color: #fff; }

.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.leg {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: var(--bg-card); font-size: 11.5px; font-weight: 500; color: var(--text-secondary);
  transition: background .13s ease, color .13s ease, opacity .13s ease;
}
.leg i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.leg[aria-pressed='false'] { opacity: .42; }
.leg[aria-pressed='true'] { color: var(--text-primary); background: var(--bg-inset); }

.cal-grid { padding: 14px 16px; overflow-x: auto; }
.cal-head, .cal-row { display: grid; grid-template-columns: 62px repeat(12, minmax(62px, 1fr)); gap: 4px; }
.cal-head { margin-bottom: 6px; }
.cal-mh {
  font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-secondary); text-align: center;
}
.cal-row { margin-bottom: 4px; }
.cal-yl {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  display: flex; flex-direction: column; justify-content: center; padding-right: 6px;
}
.cal-yl span { font-family: var(--font-mono); font-size: 10px; color: var(--text-placeholder); font-weight: 400; }

.cal-cell {
  --heat: 0;
  position: relative; border-radius: var(--radius-sm); min-height: 46px;
  padding: 5px 6px; border: 1px solid var(--border);
  background: color-mix(in srgb, var(--axis-blue) calc(var(--heat) * 100%), var(--bg-card));
  transition: transform .12s cubic-bezier(.2,.9,.3,1), box-shadow .12s ease, border-color .12s ease;
  cursor: default; overflow: hidden;
}
.cal-cell:hover {
  transform: translateY(-2px) scale(1.035); z-index: 4;
  box-shadow: var(--shadow-md); border-color: var(--axis-blue-300);
}
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.abated {
  background: repeating-linear-gradient(45deg,#F7F7FA,#F7F7FA 5px,#EFEFF4 5px,#EFEFF4 10px);
}
.cal-cell.has-ms { border-color: var(--border-strong); }
.cc-top { display: flex; align-items: center; justify-content: space-between; gap: 3px; }
.cc-m { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-placeholder); }
.cal-cell:hover .cc-m { color: var(--text-secondary); }
.cc-dots { display: inline-flex; gap: 2px; }
.cc-dots i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.cc-v {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  margin-top: 5px; color: var(--text-primary); white-space: nowrap;
}
.cal-cell.abated .cc-v { color: var(--text-secondary); font-style: italic; }

.cal-side { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.cal-side .card { padding: 15px 17px; }
.ms-list { max-height: 340px; overflow-y: auto; }
.ms { display: flex; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.ms:last-child { border-bottom: 0; }
.ms-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: 0 0 8px; }
.ms-when { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.ms-what { font-size: 12.5px; margin-top: 1px; }
.ms-calc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; line-height: 1.45; }
.ms-cite { font-family: var(--font-mono); font-size: 10px; color: var(--text-placeholder); margin-top: 2px; }
.ms-none { font-size: 12.5px; color: var(--text-secondary); padding: 8px 0; }

@media (max-width: 1100px) { .cal-side { grid-template-columns: 1fr; } }

.cal-cell { min-height: 54px; }
.cc-ms {
  font-size: 8.5px; line-height: 1.25; color: var(--text-secondary);
  margin-top: 3px; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.cal-cell:hover .cc-ms { color: var(--text-muted); }
.cal-cell.has-ms { box-shadow: inset 0 0 0 1px var(--border-strong); }

/* Derived-value audit trail */
.chip.derived      { background: #EDE9FE; color: #6D28D9; }
.chip.derived_open { background: #F1F5F9; color: #475569; }
.field.is-derived      { background: #FCFBFF; }
.field.is-derived_open { background: #FCFCFD; }

.f-calc {
  margin-top: 8px; padding: 8px 11px; border-radius: var(--radius-sm);
  background: #F6F4FF; border-left: 3px solid #A78BFA;
  font-size: 12px; color: var(--text-muted); line-height: 1.55;
}
.f-calc.warn { background: var(--c-uncertain-bg); border-left-color: var(--c-uncertain); }
.fc-h {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: #6D28D9; margin-right: 6px;
}
.f-calc.warn .fc-h { color: var(--c-uncertain); }
.fc-in { margin-top: 4px; font-size: 11px; color: var(--text-secondary); }
.fc-in span { font-weight: 500; }
.fc-was { margin-top: 4px; font-size: 11px; color: var(--text-secondary); font-style: italic; }

/* ==================================================================== *
 * Shell additions — breadcrumb, subtabs, overlays
 * ==================================================================== */

body.locked { overflow: hidden; }
.topbar-l { min-width: 0; }
.topbar h1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.crumb {
  background: none; border: 0; padding: 0; font: inherit; font-weight: 500;
  color: var(--axis-blue); cursor: pointer;
}
.crumb:hover { text-decoration: underline; }
.crumb-sep { color: var(--text-placeholder); font-weight: 400; }
#topbar-actions { display: flex; gap: 7px; flex-shrink: 0; }

.subtabs {
  display: flex; gap: 3px; margin: 18px 0 4px;
  border-bottom: 1px solid var(--border);
}
.subtab {
  padding: 9px 15px; border: 0; background: none; font-size: 13.5px; font-weight: 500;
  color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subtab:hover { color: var(--text-primary); }
.subtab[aria-pressed='true'] { color: var(--axis-blue); border-bottom-color: var(--axis-blue); font-weight: 600; }

.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(16, 20, 28, 0.42); backdrop-filter: blur(3px); padding: 26px;
}
.overlay[hidden] { display: none; }
.modal { width: min(720px, 100%); max-height: 86vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-head {
  display: flex; align-items: center; gap: 12px; padding: 17px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16.5px; font-weight: 600; }
.modal-x {
  margin-left: auto; border: 0; background: none; font-size: 22px; line-height: 1;
  color: var(--text-secondary); padding: 0 4px;
}
.modal-body { padding: 18px 20px 22px; }

/* Processing overlay */
.proc { width: min(1040px, 100%); max-height: 88vh; overflow: auto; box-shadow: var(--shadow-lg); }
.proc-head { display: flex; align-items: baseline; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--border); }
.proc-head h2 { margin: 0; font-size: 16.5px; font-weight: 600; }
.proc-body { display: grid; grid-template-columns: 320px 1fr; gap: 18px; padding: 18px 20px 22px; }
.proc-side { min-width: 0; }
.proc .stream { max-height: 300px; }
.proc .scan-frame { aspect-ratio: 8.5/11; }
@media (max-width: 900px) { .proc-body { grid-template-columns: 1fr; } }

/* ==================================================================== *
 * Lease list
 * ==================================================================== */

.lease-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 14px; }
.lease-card {
  position: relative; display: flex; text-align: left; padding: 0; overflow: hidden;
  border: 1px solid var(--border); background: var(--bg-card); font: inherit;
  transition: transform .13s cubic-bezier(.2,.9,.3,1), box-shadow .13s ease, border-color .13s ease;
}
.lease-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.lc-stripe { width: 4px; flex: 0 0 4px; }
.lc-main { padding: 16px 18px; flex: 1; min-width: 0; }
.lc-top { display: flex; align-items: center; gap: 9px; }
.lc-top h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-parties { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 7px; font-size: 12px; color: var(--text-muted); }
.lc-parties b { color: var(--text-secondary); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .05em; margin-right: 4px; }
.lc-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: 8px;
  margin-top: 13px; padding: 11px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.lf-k { display: block; font-size: 9.5px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-secondary); }
.lf-v { display: block; font-family: var(--font-mono); font-size: 13px; font-weight: 500; margin-top: 3px; }
.lc-foot { display: flex; align-items: center; gap: 10px; margin-top: 11px; flex-wrap: wrap; }
.lc-next { font-size: 12px; color: var(--text-muted); flex: 1; min-width: 170px; }
.lc-next b { color: var(--text-secondary); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .05em; margin-right: 5px; }
.lc-next b.warn { color: var(--c-uncertain); }
.lc-prog { display: flex; align-items: center; gap: 4px; }
.lc-appr { font-size: 10.5px; color: var(--text-secondary); font-family: var(--font-mono); margin-left: 4px; }

.upnext { padding: 15px 18px; margin-bottom: 16px; }
.up-list { display: flex; flex-direction: column; }
.up {
  display: flex; align-items: center; gap: 11px; padding: 8px 0; border: 0; background: none;
  border-bottom: 1px solid var(--border); font: inherit; text-align: left; width: 100%;
}
.up:last-child { border-bottom: 0; }
.up:hover { background: #FCFCFD; }
.up-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.up-date { font-family: var(--font-mono); font-size: 12px; font-weight: 600; min-width: 96px; }
.up-label { font-size: 13px; flex: 1; min-width: 0; }
.up-deal { font-size: 11.5px; color: var(--text-secondary); }
.up-in { font-family: var(--font-mono); font-size: 11px; color: var(--text-placeholder); min-width: 84px; text-align: right; }

/* Lease hero */
.lease-hero { padding: 16px 18px; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 13px; }
.hf { min-width: 0; }
.hf-k { display: block; font-size: 9.5px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-secondary); }
.hf-v { display: block; font-size: 13.5px; font-weight: 500; margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==================================================================== *
 * Month calendar
 * ==================================================================== */

.cal-layout { display: grid; grid-template-columns: 1fr 320px; gap: 14px; align-items: start; }
@media (max-width: 1180px) { .cal-layout { grid-template-columns: 1fr; } }

.mcal { padding: 0; overflow: hidden; }
.mcal-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.mnav {
  width: 30px; height: 30px; border-radius: var(--radius-md); border: 1px solid var(--border-strong);
  background: var(--bg-card); font-size: 17px; line-height: 1; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.mnav:hover { background: var(--bg-inset); color: var(--text-primary); }
.mcal-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; min-width: 172px; }
.mcal-title span { color: var(--text-secondary); font-weight: 400; }
.mcal-jumps { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.mcal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  padding: 9px 10px 6px; background: var(--bg-card);
}
.mcal-dow div {
  font-size: 10px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-secondary); text-align: center;
}
.mcal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 0 10px 12px;
}
.cal-d {
  min-height: 92px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-card); padding: 5px 6px; overflow: hidden;
  display: flex; flex-direction: column; gap: 3px;
}
.cal-d.out { background: transparent; border-color: transparent; }
.cal-d.past { background: #FCFCFD; }
.cal-d.past .cal-dn { color: var(--text-placeholder); }
.cal-d.busy { border-color: var(--border-strong); }
.cal-d.today {
  border-color: var(--axis-blue); box-shadow: inset 0 0 0 1px var(--axis-blue);
  background: var(--axis-blue-100);
}
.cal-dn {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-muted);
  display: flex; align-items: center; gap: 5px;
}
.cal-d.today .cal-dn { color: var(--axis-blue-700); }
.cal-dn .td {
  font-size: 8.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: var(--axis-blue); color: #fff; padding: 1px 5px; border-radius: var(--radius-pill);
}
.cal-ev { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ev {
  --c: var(--axis-blue);
  border-left: 2.5px solid var(--c); padding: 2px 4px; border-radius: 3px;
  background: color-mix(in srgb, var(--c) 9%, transparent);
  font-size: 10px; line-height: 1.3; min-width: 0;
}
.ev-amt { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); display: block; }
.ev-l { display: block; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-d { display: block; color: var(--text-placeholder); font-size: 9px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.more { border-left-color: transparent; color: var(--text-secondary); font-style: italic; }

.mcal-agenda { padding: 15px 17px; max-height: 640px; overflow-y: auto; }
.ag { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.ag:last-child { border-bottom: 0; }
.ag-d {
  --c: var(--axis-blue);
  flex: 0 0 38px; text-align: center; border-left: 3px solid var(--c); padding-left: 8px;
}
.ag-dn { display: block; font-family: var(--font-mono); font-size: 15px; font-weight: 600; line-height: 1.1; }
.ag-dw { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); }
.ag-b { min-width: 0; flex: 1; }
.ag-t { font-size: 12.5px; font-weight: 500; }
.ag-deal { font-size: 11px; color: var(--axis-blue); margin-top: 1px; }
.ag-x { font-size: 11px; color: var(--text-secondary); margin-top: 2px; line-height: 1.45; }
.ag-cite { font-family: var(--font-mono); font-size: 10px; color: var(--text-placeholder); margin-top: 2px; }

.deal-key { display: flex; gap: 7px; flex-wrap: wrap; margin: 0 0 14px; }
.dk {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px;
  border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: var(--bg-card); font-size: 12px; font-weight: 500;
}
.dk:hover { background: var(--bg-inset); }
.dk i { width: 9px; height: 9px; border-radius: 50%; }

/* ==================================================================== *
 * Review modal
 * ==================================================================== */

.rv-lead { margin: 0 0 16px; font-size: 13.5px; color: var(--text-muted); line-height: 1.6; }
.rv-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.rv-stats .stat { padding: 12px 14px; }
.rv-stats .v { font-size: 21px; }
.rv-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.rv-prompt summary { cursor: pointer; font-size: 12.5px; color: var(--axis-blue); }
.rv-prompt pre {
  white-space: pre-wrap; font-family: var(--font-mono); font-size: 11px; line-height: 1.6;
  background: var(--bg-inset); padding: 13px 15px; border-radius: var(--radius-md);
  margin-top: 9px; color: var(--text-muted);
}
.rv-note { font-size: 11.5px; color: var(--text-secondary); margin: 14px 0 0; line-height: 1.55; }
@media (max-width: 620px) { .rv-stats { grid-template-columns: 1fr; } }

.proc-fail {
  margin: 14px 20px 0; padding: 12px 15px; border-radius: var(--radius-md);
  background: #FFF1F0; border: 1px solid #FFCDC9; color: #B42318;
  font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.proc-fail span { color: var(--text-muted); font-family: var(--font-mono); font-size: 11.5px; }
.proc-fail button { margin-left: auto; }
