/* SolidShield BP — web interface */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e2e6ee;
  --text: #172033;
  --muted: #667085;
  --accent: #1f5eff;
  --accent-soft: #e8efff;
  --ok: #12805c;   --ok-soft: #e3f5ee;
  --warn: #b25e09; --warn-soft: #fdf0e1;
  --bad: #c4321c;  --bad-soft: #fde8e5;
  --info: #2459c7; --info-soft: #e7eefc;
  --s1: #c4321c; --s2: #e8862a; --s3: #3d7be8; --s4: #9aa6bd;
  --t1: #1f5eff; --t2: #13a3a3; --t3: #9b51e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131c; --surface: #161d2a; --surface-2: #1b2433; --border: #2a3446;
    --text: #e6eaf2; --muted: #98a2b8; --accent: #6f9bff; --accent-soft: #1d2c4d;
    --ok: #4cc79a; --ok-soft: #133528; --warn: #f0a656; --warn-soft: #3a2a14;
    --bad: #ff7b66; --bad-soft: #401c17; --info: #82a8ff; --info-soft: #1b2948;
    --s1: #ff6a52; --s2: #f29d4b; --s3: #6f9bff; --s4: #59657d;
    --t1: #6f9bff; --t2: #3cc9c9; --t3: #b78af0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
}
a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
h1 { font-size: 22px; margin: 2px 0 2px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 13px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.pre { white-space: pre-wrap; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { color: var(--accent); }
.link:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px;
  display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 11px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a { padding: 7px 10px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 10px 4px; }
.sidebar-foot { display: flex; flex-direction: column; gap: 10px; }
.sidebar-sep { border-top: 1px solid var(--border); }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 4px 6px 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 650; font-size: 13px; flex: none; }
.user-id { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.user-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--muted); }
.logout { margin: 0; flex: none; }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--bad-soft); color: var(--bad); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.version { font-size: 11px; color: var(--muted); text-align: center; }
.content { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; min-width: 0; overflow-x: auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
section.grid-2 { margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; transition: border-color .15s; }
.kpi:hover { border-color: var(--accent); }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-value.kpi-small { font-size: 18px; padding: 5px 0 3px; }
.kpi-sub { color: var(--muted); font-size: 12px; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table-compact td { padding: 6px 8px; }
.table a.mono { white-space: nowrap; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
tr.is-deleted td { opacity: .55; }
.thumb { width: 52px; }
.thumb img { width: 40px; height: 40px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; display: block; }

/* badges & chips */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.brand-block { padding: 12px 0; border-top: 1px solid var(--border); }
.brand-block:first-of-type { border-top: 0; padding-top: 0; }
.brand-block.is-deleted { opacity: .6; }
.asset-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 7px; padding: 3px 8px; font-size: 12.5px; }
.chip-domain { font-family: var(--mono); }
.chip-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-family: system-ui, sans-serif; }
.chip-logo img { width: 26px; height: 26px; object-fit: contain; background: #fff; border-radius: 4px; }
.chip-logo:hover { border-color: var(--accent); }

/* key/value */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-xs { padding: 2px 8px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; font-family: var(--mono); font-size: 13px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 550; margin-bottom: 12px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; margin: 0; }
label.check input { width: auto; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px 2px; margin: 0 0 12px; }
legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { width: 220px; }
.form-error { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; font-size: 13px; white-space: pre-line; }

/* alerts, empty, pager, tabs */
.alert { border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.alert-bad { background: var(--bad-soft); color: var(--bad); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 8px 0 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
details.history { margin-top: 14px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
ul.errors { margin: 6px 0 0; padding-left: 18px; font-size: 12px; max-height: 260px; overflow: auto; }
pre.json { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 0; font-family: var(--mono); font-size: 12.5px; overflow: auto; max-height: 520px; }

/* dialogs */
.dialog { border: 1px solid var(--border); border-radius: 14px; padding: 22px; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.dialog::backdrop { background: rgba(10, 15, 25, .45); }
.dialog h2 { font-size: 18px; margin-bottom: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.token-box { background: var(--surface-2); border: 1px dashed var(--accent); border-radius: 8px; padding: 12px; margin: 12px 0; word-break: break-all; }
.token-box code { border: 0; background: none; font-size: 13.5px; user-select: all; }

/* login & errors */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: center; }
.login-card h1 { justify-content: center; margin: 0; }
.login-card p { margin: 0; }
.login-card .btn-block { margin-top: 6px; }
.hint { font-size: 12px; color: var(--muted); }
.error-page { text-align: center; padding: 60px 0; }
.error-page h1 { justify-content: center; }
.error-code { font-size: 54px; font-weight: 700; color: var(--accent); line-height: 1; }

/* charts */
.chart { width: 100%; min-height: 220px; position: relative; }
.chart svg { width: 100%; height: 220px; display: block; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 10px; }
.chart .grid line { stroke: var(--border); }
.chart .bar:hover { opacity: .8; }
.chart .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart .tip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -100%); z-index: 2; }
.fill-s1 { fill: var(--s1); background: var(--s1); } .fill-s2 { fill: var(--s2); background: var(--s2); }
.fill-s3 { fill: var(--s3); background: var(--s3); } .fill-s4 { fill: var(--s4); background: var(--s4); }
.fill-ok { fill: var(--ok); background: var(--ok); } .fill-warn { fill: var(--warn); background: var(--warn); }
.fill-bad { fill: var(--bad); background: var(--bad); }
.fill-t1 { fill: var(--t1); background: var(--t1); } .fill-t2 { fill: var(--t2); background: var(--t2); }
.fill-t3 { fill: var(--t3); background: var(--t3); }
.breakdowns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.hbars { display: flex; flex-direction: column; gap: 7px; }
.hbar { font-size: 12px; }
.hbar-top { display: flex; justify-content: space-between; gap: 8px; }
.hbar-track { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 3px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 3px; }

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav-title { display: none; }
  .content { padding: 16px; }
  .row-2, .breakdowns { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

/* help page */
.help { max-width: 980px; }
.help h2 { font-size: 16px; margin: 0 0 6px; }
.help h3 { font-size: 14px; margin: 18px 0 6px; }
.help p, .help li { line-height: 1.6; }
.help ol, .help ul { padding-left: 20px; margin: 6px 0 10px; }
.help .step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; margin-right: 8px; }
.code { position: relative; margin: 8px 0 12px; }
.code pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px;
  margin: 0; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; overflow-x: auto; white-space: pre; }
.code .btn { position: absolute; top: 6px; right: 6px; }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 8px 12px; border-radius: 0 8px 8px 0; margin: 10px 0; }
.ref { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 12px; }
.ref td, .ref th { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.ref th { color: var(--muted); font-size: 12px; }

/* dashboard refresh */
.dash-body { position: relative; }
.dash-body > section { transition: filter .25s ease, opacity .25s ease; }
.dash-overlay { position: absolute; inset: 0; z-index: 10; display: flex; justify-content: center; align-items: flex-start;
  padding-top: 140px; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.dash-body.is-loading > section { filter: blur(3px) saturate(.8); opacity: .55; pointer-events: none; user-select: none; }
.dash-body.is-loading .dash-overlay { opacity: 1; pointer-events: auto; }
.dash-loader { position: sticky; top: 40vh; display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: 0 10px 30px rgba(16, 24, 40, .18);
  font-weight: 600; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
.refresh-icon { transition: transform .2s; }
.is-refreshing .refresh-icon { animation: spin .8s linear infinite; }
.kpi-value.flash, .chart.flash { animation: flash .9s ease; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flash { 0% { opacity: .35; } 100% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .spinner, .is-refreshing .refresh-icon { animation-duration: 2.4s; }
  .dash-body > section, .dash-overlay { transition: none; }
  .kpi-value.flash, .chart.flash { animation: none; }
}
