/* AdvisorSecurity dashboard. Valmark brand tokens (Brand Guide v2.0); status colours are a functional exception. */
:root {
  --night: #002436; --night-700: #295A6C; --night-500: #829CAA;
  --sand: #DAC9A2; --sand-100: #EAE2CE; --sea: #62C9DF; --sea-700: #37C2DA; --sea-100: #C4E7F0;
  --gray-900: #404445; --gray-600: #707171; --gray-300: #ACABAB;
  --bg: #FFFFFF; --bg-muted: #FAF7F0; --border: #E6E3DA;
  --pass: #3A7D5C; --fail: #B04A3A; --unknown: #C9A23A;
  --pass-bg: #E6F1EB; --fail-bg: #F6E4E0; --unknown-bg: #F6EED8;
  --font: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --shadow: 0 1px 2px rgba(0,36,54,.06), 0 1px 1px rgba(0,36,54,.04);
  --shadow-2: 0 8px 24px rgba(0,36,54,.14);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/24px var(--font); color: var(--gray-900); background: var(--bg-muted); }
h1, h2, h3 { color: var(--night); margin: 0; font-weight: 700; }
h1 { font-size: 28px; line-height: 36px; }
h2 { font-size: 18px; line-height: 28px; }
h3 { font-size: 14px; line-height: 20px; margin: 24px 0 8px; text-transform: none; color: var(--night-700); }
p { margin: 8px 0; }
.muted { color: var(--gray-600); }
.small { font-size: 14px; line-height: 20px; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--sea-700); outline-offset: 2px; }

/* Top bar */
.topbar { background: var(--night); color: #fff; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.logo { height: 28px; width: auto; display: block; }
.brand-divider { width: 1px; height: 24px; background: rgba(255,255,255,.3); }
.brand-title { font-size: 16px; color: var(--sand-100); white-space: nowrap; }
.user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--sand-100); min-width: 0; }
.user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Buttons */
.btn { border-radius: 4px; padding: 8px 16px; font-size: 14px; line-height: 20px; border: 1px solid transparent; transition: background .15s, color .15s, border-color .15s; white-space: nowrap; }
.btn-primary { background: var(--night); color: #fff; }
.btn-primary:hover { background: var(--night-700); }
.btn-secondary { background: #fff; color: var(--night); border-color: var(--gray-300); }
.btn-secondary:hover { border-color: var(--night); }
.btn-ghost { background: transparent; color: var(--night-700); }
.btn-ghost:hover { color: var(--night); background: var(--bg-muted); }
.btn-ghost-inverse { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn-ghost-inverse:hover { border-color: #fff; }

/* Layout */
.page { max-width: 1280px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 24px; margin-bottom: 24px; }
.panel.center { max-width: 560px; margin: 64px auto; text-align: center; padding: 48px 32px; }
.panel.center .btn { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.tile { background: #fff; border: 1px solid var(--border); border-top: 3px solid var(--sand); border-radius: 8px; box-shadow: var(--shadow); padding: 16px 20px; }
.tile-label { font-size: 14px; color: var(--gray-600); }
.tile-value { font-size: 32px; line-height: 40px; font-weight: 700; color: var(--night); font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; line-height: 16px; color: var(--gray-600); }

/* Check bars */
.legend { display: flex; gap: 16px; color: var(--gray-600); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.sw.pass, .seg-bar .pass { background: var(--pass); }
.sw.fail, .seg-bar .fail { background: var(--fail); }
.sw.unknown, .seg-bar .unknown { background: var(--unknown); }
/* Risk accepted: not passing, but IT accepted it, so it counts as passing. Slate, and a ring rather than a dot, so it isn't colour alone. */
.sw.accepted, .seg-bar .accepted { background: var(--night-500); }
.check-bars { display: grid; gap: 12px; }
.check-row { display: grid; grid-template-columns: minmax(180px, 280px) 1fr 170px; align-items: center; gap: 16px; }
.check-name { font-size: 14px; color: var(--night); }
button.check-row { width: 100%; background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 6px 8px; margin: -6px -8px; box-sizing: content-box; text-align: left; font: inherit; cursor: pointer; }
button.check-row:hover:not(:disabled) { background: var(--bg-muted); }
button.check-row.on { border-color: var(--night); background: var(--bg-muted); }
button.check-row:disabled { cursor: default; }
.hint { margin: -8px 0 16px; }

/* Fleet trend (admin) */
.trend { position: relative; min-height: 200px; }
.trend svg { display: block; max-width: 100%; height: auto; }
.trend .grid { stroke: var(--border); stroke-width: 1; }
.trend .axis { stroke: var(--gray-300); stroke-width: 1; }
.trend .tick { font-size: 12px; fill: var(--gray-600); font-family: var(--font); }
.trend .trend-line { fill: none; stroke: var(--night-700); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend .trend-dot { fill: var(--night-700); }
.trend .crosshair { stroke: var(--gray-300); stroke-width: 1; }
.trend .trend-marker { fill: var(--night-700); stroke: #fff; stroke-width: 2; }
.chart-tip { position: absolute; top: 0; transform: translateX(-50%); background: #fff; border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 13px; line-height: 18px; color: var(--gray-900); pointer-events: none; white-space: nowrap; }
.chart-tip .tip-title { font-weight: 700; color: var(--night); }
.trend-table { margin-top: 12px; }
.trend-table summary { cursor: pointer; color: var(--night-700); }
.trend-table .table-wrap { max-height: 320px; overflow-y: auto; margin-top: 8px; }

/* Device list toolbar (admin) */
.list-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; min-height: 36px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; background: var(--sea-100); color: var(--night); border-radius: 2px; padding: 3px 4px 3px 10px; }
.chip button { background: transparent; border: 0; font-size: 16px; line-height: 16px; padding: 0 6px; color: var(--night-700); cursor: pointer; }
.stale-tag.retired { background: var(--bg-muted); color: var(--gray-600); }
.retired-note { background: var(--bg-muted); border-left: 3px solid var(--gray-300); padding: 8px 12px; margin: 16px 0 0; color: var(--gray-900); }
.d-admin { margin-top: 24px; padding-top: 8px; border-top: 1px solid var(--border); }
.d-admin .btn { margin-top: 4px; }
.seg-bar { display: flex; height: 12px; border-radius: 2px; overflow: hidden; background: var(--bg-muted); }
.seg-bar span { display: block; height: 100%; }
.check-counts { font-size: 13px; color: var(--gray-600); text-align: right; font-variant-numeric: tabular-nums; }

/* Filters */
.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
input[type=search] { font: inherit; font-size: 14px; padding: 7px 12px; border: 1px solid var(--gray-300); border-radius: 2px; width: 240px; max-width: 100%; color: var(--night); }
input[type=search]:focus, select:focus { border-color: var(--night-700); outline: none; box-shadow: 0 0 0 2px var(--sea-100); }
select { font: inherit; font-size: 14px; padding: 7px 8px; border: 1px solid var(--gray-300); border-radius: 2px; max-width: 100%; color: var(--night); background: #fff; }
.detail-row .device-card + .device-card { margin-top: 12px; }
.table-wrap.capped { max-height: 420px; overflow-y: auto; }
tr.selected > td { background: var(--sea-100); }
.seg { display: inline-flex; border: 1px solid var(--gray-300); border-radius: 4px; overflow: hidden; }
.seg button { background: #fff; border: 0; padding: 7px 12px; font-size: 14px; color: var(--night-700); }
.seg button + button { border-left: 1px solid var(--gray-300); }
.seg button.on { background: var(--night); color: #fff; }

/* Device table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
th { text-align: left; font-weight: 700; color: var(--night-700); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
th[data-sort] { cursor: pointer; }
th[data-sort]:hover { color: var(--night); }
th.sorted::after { content: " \25B2"; font-size: 10px; }
th.sorted.desc::after { content: " \25BC"; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--bg-muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.email { color: var(--night); }
.stale-tag { display: inline-block; font-size: 12px; line-height: 16px; padding: 1px 6px; border-radius: 2px; background: var(--unknown-bg); color: #7A5E12; margin-left: 6px; }
.score-pill { display: inline-block; min-width: 44px; text-align: center; padding: 2px 8px; border-radius: 2px; font-weight: 700; }
.score-pill.good { background: var(--pass-bg); color: var(--pass); }
.score-pill.mid { background: var(--unknown-bg); color: #7A5E12; }
.score-pill.bad { background: var(--fail-bg); color: var(--fail); }
.dots { display: inline-flex; gap: 4px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.Pass { background: var(--pass); }
.dot.Fail { background: var(--fail); }
.dot.Unknown, .dot.Missing { background: var(--unknown); }
.dot.Accepted { background: transparent; box-shadow: inset 0 0 0 3px var(--night-500); }
.empty { text-align: center; padding: 24px; }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgba(0,36,54,.35); z-index: 10; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 100%); background: #fff; box-shadow: var(--shadow-2); z-index: 11; transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 24px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { word-break: break-all; }
.drawer-body { padding: 8px 24px 32px; overflow-y: auto; }
.d-score { display: flex; align-items: baseline; gap: 8px; margin-top: 16px; }
.d-score #dScore { font-size: 32px; line-height: 40px; font-weight: 700; color: var(--night); }
.check-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 4px; }
.check-list li { display: grid; grid-template-columns: 70px 1fr; gap: 12px; padding: 10px 12px; font-size: 14px; line-height: 20px; }
.check-list li + li { border-top: 1px solid var(--border); }
.status { font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 2px; text-align: center; align-self: start; }
.status.Pass { background: var(--pass-bg); color: var(--pass); }
.status.Fail { background: var(--fail-bg); color: var(--fail); }
.status.Unknown, .status.Missing { background: var(--unknown-bg); color: #7A5E12; }
.status.Accepted { background: #E8EEF1; color: var(--night-700); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--night-700); text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--night); }
.link-btn:disabled { color: var(--gray-300); cursor: default; }
.accept-risk { margin-top: 6px; }
.accept-form { display: grid; gap: 6px; margin-top: 4px; }
.accept-form textarea { font: inherit; font-size: 14px; padding: 6px 8px; border: 1px solid var(--gray-300); border-radius: 2px; resize: vertical; color: var(--night); }
.accept-form input[type="search"], .accept-form select[size] { font: inherit; font-size: 14px; padding: 6px 8px; border: 1px solid var(--gray-300); border-radius: 2px; color: var(--night); background: var(--bg, #fff); width: 100%; }
.accept-form select[size] { padding: 2px; }
.d-owner { margin-bottom: 16px; }
.d-owner p { margin: 4px 0; word-break: break-word; }
.accept-form textarea:focus { border-color: var(--night-700); outline: none; box-shadow: 0 0 0 2px var(--sea-100); }
.accept-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.accepted-note { margin-top: 6px; font-size: 13px; line-height: 18px; color: var(--gray-900); background: var(--bg-muted); border-left: 3px solid var(--night-500); padding: 6px 10px; word-break: break-word; }
.accepted-note .accepted-head { color: var(--night-700); font-weight: 700; }
.accepted-note .link-btn { margin-top: 4px; margin-right: 8px; }
.check-title { color: var(--night); }
.check-detail { color: var(--gray-600); font-size: 13px; word-break: break-word; }
.spark { height: 64px; margin-bottom: 8px; }
.spark svg { width: 100%; height: 100%; display: block; }
.history td, .history th { padding: 6px 8px; }

/* Invite email (admin "No agent installed") */
th.pick, td.pick { width: 28px; padding-right: 0; }
.invite-failed { color: var(--fail); }
.modal { width: min(720px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 0; border: 0; border-radius: 4px; box-shadow: var(--shadow-2); color: var(--gray-900); }
.modal::backdrop { background: rgba(0,36,54,.35); }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 12px 24px; overflow-y: auto; display: grid; gap: 8px; }
.modal-body p { margin: 0; }
.check-label { display: flex; gap: 8px; align-items: flex-start; }
.preview-head { margin-top: 8px; }
.email-preview { width: 100%; height: 420px; border: 1px solid var(--border); background: #fff; }
.modal-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 24px; border-top: 1px solid var(--border); }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .check-row { grid-template-columns: 1fr; gap: 4px; }
  .check-counts { text-align: left; }
}
@media (max-width: 560px) {
  .page { padding: 24px 16px 48px; }
  .topbar-inner { padding: 12px 16px; }
  .brand-divider, .brand-title { display: none; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 12px; }
  input[type=search] { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }

/* Header nav */
.nav-link { color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.4); white-space: nowrap; }
.nav-link:hover { border-bottom-color: #fff; }

/* Individual portal */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 24px; margin-bottom: 24px; }
.device-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.device-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.device-head h2 { word-break: break-word; }
.device-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--gray-600); margin-top: 4px; }
.device-score { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; white-space: nowrap; }
.score-pill.large { font-size: 24px; line-height: 32px; padding: 4px 12px; min-width: 64px; }
.fix { margin-top: 6px; font-size: 13px; line-height: 18px; color: var(--gray-900); background: var(--bg-muted); border-left: 3px solid var(--sand); padding: 6px 10px; }
.device-foot { display: flex; justify-content: flex-start; margin-top: -8px; }
.device-history .spark { margin: 0 0 8px; }
.empty-state { text-align: center; padding: 40px 32px; }
.install { display: grid; grid-template-columns: minmax(260px, 1fr) 1.4fr; gap: 32px; align-items: start; }
.download-list { display: flex; flex-direction: column; gap: 12px; }
.download { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.steps { margin: 0; padding-left: 20px; font-size: 14px; line-height: 22px; color: var(--gray-900); }
.steps li + li { margin-top: 10px; }
.steps strong { color: var(--night); }
.install-note { margin: 6px 0 0; padding: 6px 10px; line-height: 18px; color: var(--gray-900); background: var(--bg-muted); border-left: 3px solid var(--night-500); }
@media (max-width: 900px) {
  .device-grid { grid-template-columns: 1fr; }
  .install { grid-template-columns: 1fr; gap: 24px; }
}

/* ---------- Portal: domain view ---------- */
.view-tabs { margin-bottom: 24px; }
.detail-row > td { background: var(--bg-muted); padding: 16px; }
.detail-row .device-card { box-shadow: none; }
tbody tr.clickable:focus-visible { outline: 2px solid var(--sea); outline-offset: -2px; }
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .device-grid { grid-template-columns: 1fr; } }
