/* Capital Signal apps: the customer app and the editor, in the Chamber design system.
   tokens.css is the design system, copied unchanged. This file maps the apps' plain markup
   (cards, forms, tables, tags) onto it. Every value is a token, except the app states the system
   does not define yet, which are marked "Proposed" below and listed in docs/DESIGN-APP.md. */

:root {
  /* Proposed: an error and destructive-action colour. The system has none; 7.4:1 on white. */
  --cs-danger: #a3261b;
  /* App shell measures, from the system's spacing. */
  --app-header: 64px;
  --app-nav: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font: var(--text-body); font-family: var(--font-sans); color: var(--navy); background: var(--mist); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3 { font-family: var(--font-serif); font-optical-sizing: auto; font-weight: 400; letter-spacing: -0.01em; color: var(--navy); text-wrap: balance; }
p, li { text-wrap: pretty; }
a { color: var(--steel-700); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--navy); }
code { font: var(--text-code); background: var(--mist); color: var(--navy); padding: 1px 6px; border-radius: var(--radius-control); overflow-wrap: anywhere; }
code.secret { display: block; padding: var(--space-12) var(--space-14); font-size: 14px; }
::selection { background: var(--steel-200); color: var(--navy); }
:where(a, button, input, select, textarea, summary):focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
[hidden] { display: none !important; } /* elements styled with display must still hide */

.skip { position: absolute; left: -9999px; top: var(--space-8); z-index: 40; background: var(--white); color: var(--navy); padding: var(--space-12) var(--space-16); font-weight: 600; border: 2px solid var(--navy); border-radius: var(--radius-control); text-decoration: none; }
.skip:focus { left: var(--space-16); }

/* ---------------------------------------------------------------- header */
.bar { position: sticky; top: 0; z-index: 20; height: var(--app-header); display: flex; align-items: center; gap: var(--space-16) var(--space-24); padding: 0 var(--space-24); background: var(--header-ground); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line-100); }
.brand { display: inline-flex; align-items: flex-end; gap: var(--space-12); color: var(--navy); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--navy); }
.brand-name { font: var(--text-brand-name); font-family: var(--font-serif); letter-spacing: -0.015em; font-size: 21px; line-height: 1; padding-bottom: 2px; }
.brand-mark { display: block; flex: none; width: 46px; height: auto; } /* The Chamber mark; its floor sits on the name's baseline */
.brand-sub { align-self: center; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--steel-700); padding: var(--space-4) var(--space-8); border: 1px solid var(--line-300); border-radius: var(--radius-control); line-height: 1; }
#who { margin-left: auto; display: flex; align-items: center; gap: var(--space-12); font-size: 14px; color: var(--ink-600); min-width: 0; }
#who .who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#who button { margin-left: var(--space-4); }
.menu-btn { display: none; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--app-nav) minmax(0, 1fr); min-height: calc(100vh - var(--app-header)); position: relative; }
/* The navigation column runs the full height of long pages, not only the sticky panel. */
body.signed-in .shell::before { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: var(--app-nav); background: var(--white); border-right: 1px solid var(--line-100); }
body.signed-in #tabs { z-index: 1; }
body.signed-out .shell, body:not(.signed-in) .shell { grid-template-columns: minmax(0, 1fr); }
main { padding: var(--space-40) var(--space-40) var(--space-80); width: 100%; max-width: 1160px; }
body.signed-out main { max-width: none; padding: 0; }

#tabs { position: sticky; top: var(--app-header); align-self: start; height: calc(100vh - var(--app-header)); overflow-y: auto; background: var(--white); border-right: 1px solid var(--line-100); padding: var(--space-24) var(--space-16) var(--space-40); display: flex; flex-direction: column; gap: 2px; }
#tabs .nav-group { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--steel-700); padding: var(--space-20) var(--space-12) var(--space-8); }
#tabs .nav-group:first-child { padding-top: 0; }
#tabs a, #tabs button { display: flex; align-items: center; min-height: 40px; padding: 0 var(--space-12); border: 0; border-radius: var(--radius-control); background: none; font: var(--text-nav); color: var(--ink-700); text-decoration: none; text-align: left; justify-content: flex-start; white-space: normal; cursor: pointer; position: relative; }
#tabs a:hover, #tabs button:hover { background: var(--mist-50); color: var(--navy); }
#tabs a[aria-current="page"], #tabs button[aria-current="page"] { background: var(--mist); color: var(--navy); font-weight: 600; }
#tabs a[aria-current="page"]::before, #tabs button[aria-current="page"]::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; background: var(--navy); }
#tabs .nav-foot { margin-top: auto; padding: var(--space-24) var(--space-12) 0; font-size: 12.5px; color: var(--ink-500); }
body.nav-open { overflow: hidden; }

/* ---------------------------------------------------------------- page head */
.page-head { display: flex; flex-direction: column; gap: var(--space-8); margin-bottom: var(--space-32); }
.page-head .eyebrow, .eyebrow { display: inline-flex; align-items: center; gap: var(--space-12); font: var(--text-eyebrow); letter-spacing: .1em; text-transform: uppercase; color: var(--steel-700); }
.eyebrow::before { content: ''; width: 24px; height: 1px; background: currentColor; }
.page-head h1, main > h1, #view > h1 { font-size: 40px; line-height: 1.08; }
.page-head .lede { font-size: 16.5px; line-height: 1.6; color: var(--ink-600); max-width: 640px; }
.page-head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-16) var(--space-24); flex-wrap: wrap; }
main > h1, #view > h1 { margin-bottom: var(--space-24); }
#view > h2 { font-size: 24px; margin: var(--space-32) 0 var(--space-14); }
#view > h2:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- cards */
.card { background: var(--white); border: 1px solid var(--line-150); border-radius: var(--radius-card); padding: var(--space-28); margin-bottom: var(--space-16); display: block; }
.card > * + * { margin-top: var(--space-12); }
.card h1 { font-size: 34px; line-height: 1.1; }
.card h2 { font-size: 24px; line-height: 1.15; }
.card h3 { font-size: 20px; line-height: 1.2; }
.card h2 + .meta, .card h1 + .meta { margin-top: var(--space-8); }
.card p { font-size: 15.5px; color: var(--ink-600); }
.card ul:not(.plain):not(.pillars), .card ol { padding-left: var(--space-20); color: var(--ink-600); font-size: 15px; display: flex; flex-direction: column; gap: var(--space-6); }
.card ol li::marker { color: var(--steel-700); font-variant-numeric: tabular-nums; }
.narrow { max-width: 440px; margin: var(--space-64) auto; display: grid; gap: var(--space-16); }
.narrow > * + * { margin-top: 0; }
.card.narrow { margin: 0 0 var(--space-16); max-width: 560px; }

.meta { font: var(--text-caption); color: var(--ink-500); display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-14); align-items: center; font-variant-numeric: tabular-nums; }
.meta > span + span::before { content: '·'; margin-right: var(--space-14); color: var(--line-500); }
span.meta { display: inline; }
.row { display: flex; flex-wrap: wrap; gap: var(--space-10); align-items: center; }
.card > .row { margin-top: var(--space-20); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-16) var(--space-24); }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-24); }
.pair > div { min-width: 0; }

/* Empty, loading and error states */
p.empty, div.empty { background: var(--white); border: 1px solid var(--line-150); border-radius: var(--radius-card); padding: var(--space-48) var(--space-28); text-align: center; color: var(--ink-500); font-size: 15px; }
.card p.empty, .card .empty { background: none; border: 0; padding: var(--space-8) 0; text-align: left; }
.empty-title { font-family: var(--font-serif); font-size: 24px; line-height: 1.2; color: var(--navy); margin-bottom: var(--space-8); }
.empty-state { background: var(--white); border: 1px solid var(--line-150); border-radius: var(--radius-card); padding: var(--space-48) var(--space-40); display: grid; gap: var(--space-12); justify-items: start; }
.empty-state p { color: var(--ink-600); max-width: 520px; }
.error { color: var(--cs-danger); font-size: 13.5px; font-weight: 600; min-height: 1em; }
.error:empty { min-height: 0; }
.notice { background: var(--white); border: 1px solid var(--line-150); border-left: 2px solid var(--navy); border-radius: var(--radius-card); color: var(--navy); font-size: 15px; font-weight: 500; padding: var(--space-16) var(--space-20); margin-bottom: var(--space-24); }
.skeleton { display: grid; gap: var(--space-16); }
.skeleton div { height: 148px; background: var(--white); border: 1px solid var(--line-150); border-radius: var(--radius-card); position: relative; overflow: hidden; }
.skeleton div::before, .skeleton div::after { content: ''; position: absolute; left: var(--space-28); height: 12px; border-radius: var(--radius-control); background: var(--mist); }
.skeleton div::before { top: var(--space-28); width: 22%; }
.skeleton div::after { top: 60px; width: 58%; height: 22px; }

/* ---------------------------------------------------------------- forms */
label { display: grid; gap: var(--space-6); font-size: 13.5px; font-weight: 600; color: var(--ink-700); }
label:has(> input[type="checkbox"]), label > span:has(> input[type="checkbox"]) { display: flex; align-items: center; gap: var(--space-10); font-weight: 500; }
input, select, textarea { font: 400 15px/1.4 var(--font-sans); color: var(--navy); background: var(--white); border: 1px solid var(--line-200); border-radius: var(--radius-control); padding: var(--space-10) var(--space-12); min-height: var(--control-height-sm); width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--ink-500); }
input:hover, select:hover, textarea:hover { border-color: var(--line-500); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-color: var(--navy); }
input[readonly] { background: var(--mist-50); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--navy); flex: none; }
input[type="date"], input[type="number"] { font-variant-numeric: tabular-nums; }
select { appearance: none; padding-right: var(--space-36); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%230B1B2E' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right var(--space-12) center; }
textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
form.card { display: grid; gap: var(--space-16); }
form.card > * + * { margin-top: 0; }
form.card > button[type="submit"] { justify-self: start; }
form .meta { font-size: 13px; }

/* Buttons: navy is the working button; signal orange marks the one main action on a screen. */
button { font: var(--text-button); font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-10); min-height: var(--control-height-sm); padding: 0 var(--space-18); border: 1px solid var(--navy); border-radius: var(--radius-control); background: var(--navy); color: var(--white); cursor: pointer; white-space: nowrap; transition: background-color .15s ease, color .15s ease, border-color .15s ease; }
button:active { transform: translateY(1px); }
button.primary { background: var(--signal); border-color: var(--signal); color: var(--navy); }
button.quiet { background: transparent; color: var(--navy); border-color: var(--line-500); }
button.danger { background: transparent; color: var(--cs-danger); border-color: var(--cs-danger); }
button:disabled, button[aria-busy="true"] { opacity: .5; cursor: default; transform: none; }
/* Hover fills only where there is a pointer: on a touch screen a tapped button would stay filled. */
@media (hover: hover) {
  button:hover { background: var(--navy-700); border-color: var(--navy-700); }
  button.primary:hover { background: var(--signal-hover); border-color: var(--signal-hover); }
  button.quiet:hover { background: var(--navy); border-color: var(--navy); color: var(--white); }
  button.danger:hover { background: var(--cs-danger); color: var(--white); }
  button.quiet:disabled:hover { background: transparent; color: var(--navy); border-color: var(--line-500); }
}
@media (hover: none) { button { transition: none; } }
button.small { min-height: 36px; padding: 0 var(--space-14); font-size: 13px; }
.textlink { font: var(--text-button); font-size: 14px; color: var(--navy); text-decoration: none; display: inline-flex; gap: var(--space-6); background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; padding-bottom: 2px; transition: background-size .25s ease; }
.textlink:hover { background-size: 100% 1px; color: var(--navy); }

.filters { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) auto; gap: var(--space-14) var(--space-16); align-items: end; }
.filters > * + * { margin-top: 0; }
.filters:has(> label:nth-of-type(5)) { grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr)) auto; }

/* ---------------------------------------------------------------- tags and chips */
.tag, .chip { display: inline-flex; align-items: center; gap: var(--space-6); font-size: 13px; font-weight: 500; line-height: 1.3; color: var(--ink-700); background: var(--mist); border-radius: var(--radius-control); padding: var(--space-4) var(--space-10); white-space: nowrap; }
.tag.warn { background: var(--white); color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); font-weight: 600; }
.label-tag { display: inline-block; font: var(--text-label); letter-spacing: .08em; text-transform: uppercase; padding: var(--space-4) var(--space-8); border: 1px solid var(--line-300); color: var(--ink-600); border-radius: var(--radius-control); }
.tags, .chips { display: flex; flex-wrap: wrap; gap: var(--space-8); }
.chip button { background: none; border: 0; color: inherit; min-height: 0; padding: 0 0 0 var(--space-4); font-size: 16px; line-height: 1; }
.chip button:hover { background: none; color: var(--navy); }

/* ---------------------------------------------------------------- lists and tables */
ul.plain { list-style: none; padding: 0; margin: 0; display: block; }
.card ul.plain { padding: 0; display: block; }
ul.plain > li { padding: var(--space-14) 0; border-bottom: 1px solid var(--line-100); font-size: 15px; color: var(--ink-600); }
ul.plain > li:first-child { padding-top: 0; }
ul.plain > li:last-child { border-bottom: 0; padding-bottom: 0; }
ul.plain > li > a:first-child { font-weight: 600; color: var(--navy); text-decoration: none; }
ul.plain > li > a:first-child:hover { text-decoration: underline; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.card > table { margin-top: var(--space-16); }
th { font: var(--text-label); letter-spacing: .08em; text-transform: uppercase; color: var(--steel-700); text-align: left; padding: 0 var(--space-12) var(--space-10) 0; border-bottom: 1px solid var(--line-500); white-space: nowrap; }
td { text-align: left; padding: var(--space-12) var(--space-12) var(--space-12) 0; border-bottom: 1px solid var(--line-100); color: var(--ink-600); vertical-align: top; }
td:first-child { color: var(--navy); font-weight: 500; }
tr:last-child td { border-bottom: 0; }
dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-6) var(--space-20); font-size: 14px; }
dt { color: var(--ink-500); }
dd { margin: 0; color: var(--navy); overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- record text */
blockquote { margin: 0; padding: var(--space-4) 0 var(--space-4) var(--space-20); border-left: 2px solid var(--navy); font-family: var(--font-serif); font-size: 19px; line-height: 1.45; color: var(--navy); }
.passage { white-space: pre-wrap; background: var(--mist-50); border: 1px solid var(--line-100); border-radius: var(--radius-card); padding: var(--space-16) var(--space-20); font-size: 14.5px; line-height: 1.6; color: var(--ink-600); max-height: 420px; overflow-y: auto; }
mark { background: var(--steel-200); color: var(--navy); padding: 1px 2px; border-radius: 1px; }
.fulltext { white-space: pre-wrap; font-size: 15.5px; line-height: 1.7; color: var(--ink-600); max-width: 720px; }
.rationale { font-size: 15.5px; color: var(--ink-600); }

/* ---------------------------------------------------------------- sign-in screens */
.auth { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); min-height: calc(100vh - var(--app-header)); }
.auth-intro { position: relative; overflow: hidden; background: var(--navy); color: var(--white); padding: var(--space-80) var(--space-64); display: flex; flex-direction: column; gap: var(--space-24); }
.auth-intro .eyebrow { color: var(--steel-200); }
.auth-intro h1 { color: var(--white); font-size: clamp(40px, 4vw, 60px); line-height: 1.04; letter-spacing: -0.02em; max-width: 560px; position: relative; }
.auth-intro p { color: var(--on-navy-muted); font-size: 17px; line-height: 1.6; max-width: 460px; position: relative; }
.auth-intro .pillars { list-style: none; padding: 0; margin-top: var(--space-16); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-24) var(--space-32); position: relative; max-width: 520px; }
.auth-intro .pillars li { border-top: 1px solid var(--rule-on-navy); padding-top: var(--space-14); color: var(--on-navy-soft); font-size: 14.5px; position: relative; }
.auth-intro .pillars li::before { content: ''; position: absolute; left: 0; top: -1px; width: 32px; height: 2px; background: var(--white); }
.auth-intro .pillars strong { display: block; font-family: var(--font-serif); font-weight: 400; font-size: 24px; color: var(--white); margin-bottom: var(--space-4); }
.auth-arcs { position: absolute; right: -120px; bottom: -160px; width: 640px; height: auto; pointer-events: none; }
.auth-arcs circle { stroke: var(--steel); }
.auth-forms { padding: var(--space-64) var(--space-64) var(--space-80); display: flex; flex-direction: column; gap: var(--space-16); max-width: 640px; }
.auth-forms .card { margin: 0; max-width: none; }
.auth-forms h1 { font-size: 32px; }
.auth-forms h2 { font-size: 22px; }
.auth-forms .or { display: flex; align-items: center; gap: var(--space-14); font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-500); margin: var(--space-8) 0; }
.auth-forms .or::before, .auth-forms .or::after { content: ''; flex: 1; height: 1px; background: var(--line-300); }
.auth-single { padding: var(--space-80) var(--space-24); display: grid; justify-items: center; }
.auth-single .card { width: 100%; max-width: 460px; margin: 0; }

/* ---------------------------------------------------------------- phone and tablet */
@media (max-width: 1100px) {
  main { padding: var(--space-32) var(--space-32) var(--space-64); }
  .filters, .filters:has(> label:nth-of-type(5)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters > label:first-child { grid-column: 1 / -1; }
  .filters > button { justify-self: start; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-intro { padding: var(--space-56) var(--gutter-tablet); }
  .auth-forms { padding: var(--space-40) var(--gutter-tablet) var(--space-64); max-width: 720px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); align-content: start; }
  body.signed-in .shell::before { display: none; }
  .menu-btn { display: inline-flex; background: var(--white); color: var(--navy); border-color: var(--line-200); padding: 0 var(--space-14); }
  .menu-btn:hover { background: var(--mist); color: var(--navy); border-color: var(--line-300); }
  body:not(.signed-in) .menu-btn { display: none; }
  #tabs { position: fixed; inset: var(--app-header) 0 0 0; z-index: 19; height: auto; border-right: 0; padding: var(--space-16) var(--gutter-phone) var(--space-40); background: var(--header-ground); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); display: none; }
  body.nav-open #tabs:not([hidden]) { display: flex; }
  #tabs a, #tabs button { min-height: 52px; font-size: 17px; border-bottom: 1px solid var(--line-100); border-radius: 0; }
  #tabs a[aria-current="page"]::before, #tabs button[aria-current="page"]::before { top: 14px; bottom: 14px; }
  #who .who-name { display: none; }
}
@media (max-width: 720px) {
  .bar { padding: 0 var(--gutter-phone); gap: var(--space-10); }
  .brand-name { font-size: 19px; }
  .brand-mark { width: 42px; }
  .brand-sub { display: none; }
  main { padding: var(--space-24) var(--gutter-phone) var(--space-56); }
  .page-head h1, main > h1, #view > h1 { font-size: 32px; }
  .card { padding: var(--space-20); }
  .card h1 { font-size: 28px; }
  .card h2 { font-size: 22px; }
  .grid2, .pair, .filters, .filters:has(> label:nth-of-type(5)) { grid-template-columns: minmax(0, 1fr); }
  .auth-intro { padding: var(--space-40) var(--gutter-phone) var(--space-48); }
  .auth-intro .pillars { grid-template-columns: minmax(0, 1fr); gap: var(--space-16); }
  .auth-forms { padding: var(--space-24) var(--gutter-phone) var(--space-56); }
  .table-wrap { overflow-x: auto; }
  table { min-width: 520px; }
  p.empty, div.empty { padding: var(--space-32) var(--space-20); }
}
@media (prefers-reduced-motion: reduce) {
  button, .textlink { transition: none; }
}
@media print {
  .bar, #tabs, .skip, .row button, .menu-btn { display: none !important; }
  body { background: var(--white); }
  .shell { display: block; }
  main { padding: 0; max-width: none; }
  .card { border-color: var(--line-300); break-inside: avoid; }
}
