/* Agency Console. Served as a static stylesheet; the CSP allows no inline styles or scripts. */
.onboarding { border-left: 4px solid #3154b8; }
.onboarding-checks { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 20px 0 12px; }
#client-subscription, #client-credential { scroll-margin-top: 24px; }
:root {
  --ink: #17233a; --muted: #5a6880; --line: #e1e6ee; --soft: #f5f7fb; --surface: #fff;
  --brand: #2855c6; --brand-ink: #1e429e; --side: #101d35; --side-ink: #c9d3e6;
  --ok: #156a42; --ok-bg: #e4f5eb; --warn: #7c5200; --warn-bg: #fff3d6; --bad: #a12a2a; --bad-bg: #fdeceb;
  --neutral: #44536d; --neutral-bg: #edf0f5; --focus: #b54708; --radius: 12px;
  color-scheme: light; font: 15px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--soft);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--soft); }
a { color: var(--brand); }
a:hover { color: var(--brand-ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.5px; font-weight: 650; }
h2 { margin: 0 0 12px; font-size: 18px; line-height: 1.3; letter-spacing: -.2px; }
h3 { margin: 18px 0 6px; font-size: 15px; }
code { font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--neutral); overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.muted { color: var(--muted); }
.note { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.text-bad { color: var(--bad); font-weight: 600; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 10; padding: 10px 14px; background: #fff; border-radius: 8px; }
.skip:focus { top: 12px; }

/* Buttons: primary (default), secondary, danger, link */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 9px 16px;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  color: #fff; background: var(--brand); border: 1px solid var(--brand); border-radius: 9px;
}
button:hover, .button:hover { color: #fff; background: var(--brand-ink); border-color: var(--brand-ink); }
.secondary, .button.secondary { color: var(--brand-ink); background: #fff; border-color: #c8d3e6; }
.secondary:hover, .button.secondary:hover { color: var(--brand-ink); background: #eef3fd; border-color: var(--brand); }
button.danger, .button.danger { color: #fff; background: var(--bad); border-color: var(--bad); }
button.danger:hover, .button.danger:hover { color: #fff; background: #7f1d1d; border-color: #7f1d1d; }
.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.link { min-height: 0; padding: 4px 0; color: var(--side-ink); background: none; border: 0; text-decoration: underline; font-weight: 500; }
.link:hover { color: #fff; background: none; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
form.inline { display: inline-block; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 28px 18px; background: var(--side); color: var(--side-ink); }
.brand { display: flex; gap: 12px; align-items: center; color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; }
.brand:hover { color: #fff; }
.brand small { display: block; font-size: 11px; font-weight: 500; letter-spacing: .6px; text-transform: uppercase; color: #9fb0cc; }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: #4871df; font-size: 20px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { padding: 10px 12px; border-radius: 8px; color: var(--side-ink); font-weight: 550; text-decoration: none; }
.sidebar nav a:hover { color: #fff; background: #1c2c4b; }
.sidebar nav a[aria-current="page"] { color: #fff; background: #26385c; box-shadow: inset 3px 0 0 #7d9cf0; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #93a4c0; }
.sidebar-foot p { margin: 8px 0 0; }
.bare .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
.bare .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 18px 28px; }
.bare .sidebar-foot { margin: 0 0 0 auto; }
main { width: 100%; max-width: 1480px; margin: 0 auto; padding: 36px clamp(16px, 3vw, 48px) 56px; }
main:focus { outline: none; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -12px 0 20px; color: var(--muted); overflow-wrap: anywhere; }
.sep { color: #a5b0c2; }

/* Cards, alerts, badges */
.card { margin-bottom: 24px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card > h2:not(:first-child) { margin-top: 28px; }
.card.flush { padding: 0; overflow: hidden; }
.card.subtle { background: #f9fbfe; }
.card.narrow { max-width: 760px; }
.card.danger { border-color: #f0c9c6; }
.card.danger h2 { color: var(--bad); }
.login { max-width: 460px; margin: 40px auto; }
.alert { margin: 0 0 20px; padding: 12px 16px; border-radius: 10px; border: 1px solid; }
.alert.info { color: #1f3f86; background: #eef3fd; border-color: #cbd8f5; }
.alert.warn { color: var(--warn); background: var(--warn-bg); border-color: #edd492; }
.alert.error, .alert.bad { color: var(--bad); background: var(--bad-bg); border-color: #f0c2bf; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 13px; font-weight: 650; line-height: 1.4; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.neutral { color: var(--neutral); background: var(--neutral-bg); }

/* Metrics */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric { padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.metric h2 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.metric > strong { display: block; font-size: 30px; line-height: 1.15; letter-spacing: -.8px; }
.metric > strong.small-strong { font-size: 20px; letter-spacing: -.2px; }

/* Toolbar, search and filter chips */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.toolbar h2 { margin: 0; }
.search { flex: 1 1 340px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search input { flex: 1 1 200px; width: auto; max-width: 360px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; color: var(--neutral); font-size: 14px; font-weight: 550; text-decoration: none; }
.chips a:hover { border-color: var(--brand); color: var(--brand-ink); }
.chips a[aria-current="true"] { color: #fff; background: var(--brand); border-color: var(--brand); }
.chips .count { min-width: 22px; padding: 0 6px; border-radius: 99px; background: rgba(23, 35, 58, .08); text-align: center; font-size: 12px; }
.chips a[aria-current="true"] .count { background: rgba(255, 255, 255, .22); }

/* Tables */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
th { padding: 12px 16px; background: #f8fafd; color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .4px; text-transform: uppercase; white-space: nowrap; }
th .muted { text-transform: none; letter-spacing: 0; }
td { padding: 16px; border-top: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #fafbfe; }
.client-name { font-weight: 650; font-size: 15px; text-decoration: none; overflow-wrap: anywhere; }
.client-name:hover { text-decoration: underline; }
td .note { overflow-wrap: anywhere; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { margin-left: 6px; }
meter { display: block; width: 100%; max-width: 160px; height: 8px; margin: 6px 0 2px; border: 0; border-radius: 4px; background: var(--neutral-bg); }
meter::-webkit-meter-bar { height: 8px; border: 0; border-radius: 4px; background: var(--neutral-bg); }
meter::-webkit-meter-optimum-value { background: var(--brand); border-radius: 4px; }
meter::-webkit-meter-suboptimum-value { background: #d59a10; border-radius: 4px; }
meter::-webkit-meter-even-less-good-value { background: var(--bad); border-radius: 4px; }
meter:-moz-meter-optimum::-moz-meter-bar { background: var(--brand); }
meter:-moz-meter-sub-optimum::-moz-meter-bar { background: #d59a10; }
meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--bad); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 17px; }
.empty-inline { margin: 0; color: var(--muted); }
.empty-inline.pad { padding: 20px 24px; }
.footnote { padding: 14px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.footnote summary { cursor: pointer; font-weight: 550; }
.footnote p { margin: 8px 0 0; max-width: 900px; }

/* Forms */
.field { margin: 0 0 16px; }
label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.strong { margin-top: 18px; }
input, select, textarea { display: block; width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--ink); background: #fff; border: 1px solid #c4cfe0; border-radius: 9px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
.help { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: 20px; min-height: 20px; height: 20px; margin: 0; }
.checkbox label { margin: 0; }
fieldset { margin: 0 0 20px; padding: 0; border: 0; }
legend { margin-bottom: 12px; padding: 0; font-size: 13px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 10px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.secret { margin-top: 0; font: 14px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; background: #f0f4fc; word-break: break-all; resize: vertical; }
.technical { margin-top: 16px; color: var(--muted); font-size: 14px; }
.technical summary { cursor: pointer; }
.technical p { margin: 6px 0; }

/* Audit trail */
.audit { margin: 0; padding: 0; list-style: none; }
.audit li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.audit li:last-child { border-bottom: 0; }
.audit li.flag strong { color: var(--bad); }
.audit time { flex-shrink: 0; color: var(--muted); font-size: 13px; white-space: nowrap; }

@media (max-width: 1200px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 16px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .sidebar nav a { padding: 8px 10px; }
  .sidebar nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 #7d9cf0; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .sidebar-foot p { display: none; }
  h1 { font-size: 24px; }
  main { padding-top: 24px; }
}
/* Phones: table rows become labelled cards, so nothing scrolls sideways. */
@media (max-width: 760px) {
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { padding: 14px; }
  .metric > strong { font-size: 24px; }
  .card { padding: 18px; }
  .toolbar { padding: 16px; }
  table.clients thead, table.records thead { display: none; }
  table.clients, table.clients tbody, table.clients tr, table.clients td,
  table.records, table.records tbody, table.records tr, table.records td { display: block; width: 100%; }
  table.clients tr, table.records tr { padding: 14px 16px; border-top: 1px solid var(--line); }
  table.clients td, table.records td { padding: 6px 0; border: 0; }
  table.clients td::before, table.records td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .3px; text-transform: uppercase; }
  table.clients td:first-child::before { display: none; }
  td.actions { text-align: left; white-space: normal; }
  td.actions::before { display: none !important; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
  .audit li { flex-direction: column; gap: 4px; }
  .pager { padding: 12px 16px; }
}
@media (max-width: 420px) { .metrics { grid-template-columns: 1fr; } }
