/* The screen's own names for the brand tokens. This is the one place the
   two vocabularies meet; no rule below names an --aw-* token directly
   except through these. Light only, like Cabinet and Companion. */
:root {
  --bg: var(--aw-bg); --surface: var(--aw-surface); --surface-subtle: var(--aw-surface-subtle);
  --text: var(--aw-text); --muted: var(--aw-text-muted);
  --border: var(--aw-border); --border-control: var(--aw-border-control);
  --primary: var(--aw-primary); --primary-hover: var(--aw-primary-hover); --primary-soft: var(--aw-primary-soft);
  --on-primary: var(--aw-on-primary); --accent: var(--aw-accent);
  --warning: var(--aw-warning); --warning-soft: var(--aw-warning-soft);
  --danger: var(--aw-danger); --danger-soft: var(--aw-danger-soft);
  --success: var(--aw-success); --success-soft: var(--aw-success-soft);
  --display: var(--aw-font-display); --body: var(--aw-font-body);
  --r-sm: var(--aw-radius-sm); --r-md: var(--aw-radius-md); --r-lg: var(--aw-radius-lg); --r-pill: var(--aw-radius-pill);
  --shadow: var(--aw-shadow-sm); --focus: var(--aw-focus-outline);
  --s1: var(--aw-space-1); --s2: var(--aw-space-2); --s3: var(--aw-space-3); --s4: var(--aw-space-4);
  --s5: var(--aw-space-5); --s6: var(--aw-space-6); --s8: var(--aw-space-8); --s10: var(--aw-space-10);
  --control-h: var(--aw-control-h); --header-h: var(--aw-header); --content-max: var(--aw-content-max);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 0.9375rem; line-height: var(--aw-leading-normal); }
h1, h2, h3 { font-family: var(--display); line-height: var(--aw-leading-tight); margin: 0; text-wrap: balance; }
h1 { font-size: var(--aw-size-3xl); font-weight: var(--aw-weight-bold); }
h2 { font-size: var(--aw-size-lg); font-weight: var(--aw-weight-semibold); }
a { color: var(--primary); }
:focus-visible { outline: var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: var(--s2); background: var(--surface); padding: var(--s2) var(--s3); border-radius: var(--r-sm); }
.skip:focus { left: var(--s2); z-index: 10; }
.muted { color: var(--muted); }
.small { font-size: var(--aw-size-xs); }
.error-text { color: var(--danger); }

/* shell */
.shell-header { height: var(--header-h); display: flex; align-items: center; gap: var(--s6); padding: 0 var(--s6); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: var(--s4); text-decoration: none; color: inherit; }
.logo { height: 1.75rem; width: auto; display: block; }
.app-name { display: inline-flex; align-items: center; gap: var(--s2); font-family: var(--display); font-weight: var(--aw-weight-semibold); padding-left: var(--s4); border-left: 1px solid var(--border); }
.mark { width: 1.25rem; height: 1.25rem; }
#nav { display: flex; gap: var(--s1); margin-left: var(--s4); }
#nav a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 var(--s3); border-radius: var(--r-sm); color: var(--text); text-decoration: none; font-weight: var(--aw-weight-medium); border-bottom: 2px solid transparent; }
#nav a:hover { background: var(--surface-subtle); }
#nav a.active { color: var(--primary); border-bottom-color: var(--accent); }
.who { margin-left: auto; display: flex; gap: var(--s3); align-items: baseline; font-size: var(--aw-size-sm); }
.who-name { color: var(--muted); }
.who-logout { color: inherit; }
.proto { font-size: var(--aw-size-xs); color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.content { max-width: var(--content-max); margin: 0 auto; padding: var(--s8) var(--s6) var(--s10); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s6); margin-bottom: var(--s6); }
.lead { color: var(--muted); margin: var(--s2) 0 0; max-width: var(--aw-reading-max); }
.back { display: inline-block; margin-bottom: var(--s4); text-decoration: none; }

/* buttons – primary: accessible teal, secondary: surface with strong border, ghost: toolbar */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--control-h); padding: 0 var(--s4); border-radius: var(--r-md); font: inherit; font-weight: var(--aw-weight-medium); text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: background var(--aw-transition-fast), border-color var(--aw-transition-fast); }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-control); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.small { min-height: var(--aw-control-h-sm); padding: 0 var(--s3); font-size: var(--aw-size-sm); }

/* cards, notices, flags */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5) var(--s6); box-shadow: var(--shadow); }
.card.empty { text-align: center; color: var(--muted); padding: var(--s10); }
.card.error { border-color: var(--danger); }
.notice { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s4) var(--s5); border-radius: var(--r-md); margin-bottom: var(--s6); }
.notice.warn { background: var(--warning-soft); border-left: 4px solid var(--warning); }
.notice.ok { background: var(--success-soft); border-left: 4px solid var(--success); }
.notice p { margin: 0; }
.flags { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.flag { font-size: var(--aw-size-xs); font-weight: var(--aw-weight-medium); padding: 2px var(--s2); border-radius: var(--r-sm); background: var(--surface-subtle); border: 1px solid var(--border); }
.flag.warn { background: var(--warning-soft); border-color: transparent; color: var(--warning); font-weight: var(--aw-weight-semibold); }
.kind { font-size: var(--aw-size-xs); font-weight: var(--aw-weight-semibold); letter-spacing: .05em; text-transform: uppercase; padding: 2px var(--s2); border-radius: var(--r-pill); background: var(--surface-subtle); color: var(--muted); white-space: nowrap; }
.kind-notice { background: var(--primary-soft); color: var(--primary); }
.kind-renewal { background: var(--warning-soft); color: var(--warning); }
.status { font-size: var(--aw-size-xs); font-weight: var(--aw-weight-semibold); padding: var(--s1) var(--s3); border-radius: var(--r-pill); background: var(--surface-subtle); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.status-active { background: var(--success-soft); color: var(--success); }

/* horizon */
.bucket { margin-bottom: var(--s8); }
.bucket-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 2px solid var(--text); padding-bottom: var(--s2); margin-bottom: var(--s2); }
.bucket-overdue .bucket-head { border-color: var(--danger); }
.bucket-overdue h2 { color: var(--danger); }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr) auto; gap: var(--s5); align-items: start; padding: var(--s4) 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.bucket-overdue .row { background: var(--danger-soft); border-radius: var(--r-md); padding: var(--s4); margin: var(--s2) 0; }
.row-when { display: flex; flex-direction: column; }
.days { font-family: var(--display); font-weight: var(--aw-weight-bold); font-variant-numeric: tabular-nums; }
.bucket-overdue .days { color: var(--danger); }
.date { font-size: var(--aw-size-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.row-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.title { font-weight: var(--aw-weight-semibold); color: var(--text); text-decoration: none; }
.title:hover { text-decoration: underline; }
.meta { margin: var(--s1) 0 0; font-size: var(--aw-size-sm); color: var(--muted); }
.quote { margin: var(--s2) 0 0; font-size: var(--aw-size-sm); font-style: italic; max-width: 64ch; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2); }
.value { font-family: var(--display); font-weight: var(--aw-weight-semibold); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* contracts list */
.search { display: flex; flex-direction: column; gap: var(--s1); margin-bottom: var(--s5); max-width: 32rem; }
label { font-size: var(--aw-size-sm); font-weight: var(--aw-weight-medium); }
input[type=text], input[type=search], select { min-height: var(--control-h); padding: 0 var(--s3); font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--r-md); }
input[type=file] { font: inherit; padding: var(--s2) 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: var(--aw-size-xs); font-weight: var(--aw-weight-semibold); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* contract */
.groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); margin-bottom: var(--s5); }
.card.group h2, .card h2 { margin-bottom: var(--s4); }
.fields { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: var(--s2) var(--s4); margin: 0; }
.fields dt { font-size: var(--aw-size-sm); color: var(--muted); padding-top: 2px; }
.fields dd { margin: 0; }
.field-line { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.field-value.empty { color: var(--muted); }
.correct { display: grid; grid-template-columns: 1fr; gap: var(--s1); margin: var(--s2) 0; padding: var(--s3); background: var(--surface-subtle); border-radius: var(--r-md); }
.actions { display: flex; gap: var(--s2); margin-top: var(--s2); }
.deadlines, .corrections, .messages { list-style: none; margin: 0; padding: 0; }
.deadlines li { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.deadlines li:last-child { border-bottom: 0; }
.deadlines li.done { text-decoration: line-through; color: var(--muted); }
.corrections li, .messages li { padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.card + .card { margin-top: var(--s5); }

/* assessment */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s3); }
.card-head h2 { margin: 0; }
.findings { list-style: none; margin: var(--s3) 0 0; padding: 0; }
.finding { padding: var(--s3) 0 var(--s3) var(--s4); border-left: 4px solid var(--border); border-bottom: 1px solid var(--border); }
.finding:last-child { border-bottom: 0; }
.finding.sev-critical, .finding.sev-high { border-left-color: var(--danger); }
.finding.sev-medium { border-left-color: var(--warning); }
.finding.acked { opacity: .6; }
.finding-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.finding-desc { margin: var(--s1) 0 0; max-width: 70ch; }
.sev { font-size: var(--aw-size-xs); font-weight: var(--aw-weight-semibold); letter-spacing: .05em; text-transform: uppercase; padding: 2px var(--s2); border-radius: var(--r-pill); background: var(--surface-subtle); color: var(--muted); }
.sev-critical, .sev-high { background: var(--danger-soft); color: var(--danger); }
.sev-medium { background: var(--warning-soft); color: var(--warning); }

/* outbound notices */
.notices { list-style: none; margin: var(--s3) 0 0; padding: 0; }
.notice-item { padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.notice-item:last-child { border-bottom: 0; }
.letter { white-space: pre-wrap; font-family: var(--body); font-size: var(--aw-size-sm); background: var(--surface-subtle); border-radius: var(--r-md); padding: var(--s4); margin: var(--s2) 0 0; max-width: 70ch; }

.parties { list-style: none; margin: var(--s2) 0; padding: 0; font-size: var(--aw-size-sm); }
.parties li { padding: 2px 0; }

/* intake */
.form { display: grid; gap: var(--s2); max-width: 32rem; }
.result { margin-top: var(--s5); }
.result h2 { margin-bottom: var(--s3); }
.result .btn { margin-top: var(--s4); }

@media (max-width: 1024px) {
  .groups { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell-header { gap: var(--s3); padding: 0 var(--s4); }
  .logo { display: none; }
  .content { padding: var(--s5) var(--s4) var(--s8); }
  .row { grid-template-columns: 1fr; gap: var(--s2); }
  .row-end { flex-direction: row; align-items: center; justify-content: space-between; }
  .fields { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* settings */
.settings-group + .settings-group { margin-top: var(--s5); }
.setting { padding: var(--s4) 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: 0; padding-top: 0; }
.setting-head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.setting-label { font-weight: var(--aw-weight-semibold); }
.setting-key { font-size: var(--aw-size-xs); color: var(--muted); }
.setting-now { margin: var(--s2) 0 0; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.setting-editors { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--s4); margin-top: var(--s3); }
.setting-editor { display: flex; flex-direction: column; gap: var(--s1); }
.setting-inputs { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.setting-inputs input, .setting-inputs select { flex: 1 1 12rem; min-width: 0; }
.setting-status { margin: 0; font-size: var(--aw-size-sm); min-height: 1.2em; }
.flag.source-tenant { background: var(--primary-soft); border-color: transparent; }
input[type=password], input[type=number], input[type=email], input[type=url] { min-height: var(--control-h); padding: 0 var(--s3); font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--r-md); }

/* users */
.users tr.inactive td { color: var(--muted); }
.users .user-edit-row > td { background: var(--surface-subtle); }
.user-form { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s5); }
.user-edit-row .user-form { margin: 0; box-shadow: none; }
.form-grid { display: grid; grid-template-columns: max-content minmax(0, 24rem); gap: var(--s2) var(--s4); align-items: center; }
.companies { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s3) var(--s4); display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin: 0; }
.companies:disabled { opacity: .5; }
.companies legend { font-size: var(--aw-size-sm); font-weight: var(--aw-weight-medium); padding: 0 var(--s1); }
label.check { display: inline-flex; gap: var(--s2); align-items: center; font-weight: var(--aw-weight-regular); }
.warn-text { color: var(--warning); }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* contract page: documents, deadlines, status */
.documents { list-style: none; margin: 0 0 var(--s3); padding: 0; }
.documents li { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.documents li:last-child { border-bottom: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s3); }
.inline-form input[type=text] { flex: 1 1 12rem; min-width: 0; }
input[type=date] { min-height: var(--control-h); padding: 0 var(--s3); font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--r-md); }
.spacer { flex: 1; }
.quote-source { font-style: normal; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.notice.info { background: var(--surface-subtle); border-left: 3px solid var(--primary); }
.flag.role-amendment { background: var(--warning-soft); border-color: transparent; }
