/* console.css -- InternetAccelerator management console.
 *
 * Hand-written, no framework, no imported stylesheets, no web fonts: a strict
 * default-src 'self' CSP is applied and a font or stylesheet fetched from
 * anywhere else would simply be blocked. Every family below is a local system
 * font.
 *
 * Design intent: a control-plane tool. Dense, legible, dark, no decoration that
 * does not carry information. Identifiers, versions, hashes, timestamps and
 * policy values are monospaced so they can be compared by eye.
 */

/* ------------------------------------------------------------------ tokens */

:root {
  --bg:            #0d1117;
  --bg-raised:     #151b23;
  --bg-sunken:     #0a0e14;
  --bg-input:      #0f151d;

  --line:          #2a3441;
  --line-strong:   #3b4757;

  --fg:            #e6edf3;   /* 14.6:1 on --bg */
  --fg-dim:        #b3c0cd;   /*  9.4:1 on --bg */
  --fg-muted:      #8b98a5;   /*  5.8:1 on --bg */

  --accent:        #6cb6ff;
  --accent-dim:    #1f6feb;
  --ok:            #4ac26b;
  --warn:          #e3a008;
  --danger:        #ff7b72;
  --danger-dim:    #a5321f;

  --focus:         #ffd33d;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "Segoe UI Mono",
          Consolas, "Liberation Mono", Menlo, monospace;

  --r: 4px;
}

/* ------------------------------------------------------------------- reset */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 14px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { font-weight: 600; line-height: 1.25; margin: 0 0 .4rem; }
h1 { font-size: 1.35rem; letter-spacing: .01em; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }

p { margin: 0 0 .6rem; }
ul, dl { margin: 0 0 .6rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: var(--mono); font-size: .86em; }

/* Focus must always be visible. This rule is load-bearing for keyboard use;
 * do not replace it with `outline: none` anywhere. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent-dim);
  color: #fff;
  padding: .5rem .8rem;
}
.skip-link:focus { left: .5rem; top: .5rem; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: .55rem 1rem;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: .55rem; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  font: 600 11px/1 var(--mono);
  color: var(--accent);
  background: var(--bg-sunken);
}

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 600; letter-spacing: .01em; }
.brand-sub { font-size: .72rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .08em; }

.nav { display: flex; gap: .15rem; margin-left: .75rem; }
.nav a {
  padding: .35rem .7rem;
  border-radius: var(--r);
  color: var(--fg-dim);
  border: 1px solid transparent;
}
.nav a:hover { background: var(--bg-sunken); color: var(--fg); text-decoration: none; }
.nav a[aria-current="page"] {
  color: var(--fg);
  background: var(--bg-sunken);
  border-color: var(--line-strong);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.session { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.who-name { font-weight: 600; }
.who-role { font-size: .72rem; color: var(--fg-muted); }
.logout { margin: 0; }

.plane-note {
  margin: 0;
  padding: .35rem 1rem;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--line);
  color: var(--fg-muted);
  font-size: .78rem;
}

/* ------------------------------------------------------------------ layout */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.1rem 1rem 3rem;
}

.page-title { margin-bottom: .9rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: .9rem;
}

.foot {
  max-width: 1400px;
  margin: 0 auto;
  padding: .8rem 1rem 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--fg-muted);
  font-size: .78rem;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.sep { color: var(--line-strong); }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: .9rem 1rem;
  margin: 0 0 .9rem;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.card-head h2 { margin-bottom: .2rem; }

.card-hero { border-left: 3px solid var(--accent-dim); }
.card-warn { border-left: 3px solid var(--warn); }
.card-danger { border-left: 3px solid var(--danger-dim); }

.lede { color: var(--fg-dim); max-width: 78ch; }
.meta { color: var(--fg-muted); font-size: .8rem; margin: 0; }

.note {
  color: var(--fg-muted);
  font-size: .82rem;
  max-width: 88ch;
  margin: .5rem 0 0;
}
.hint {
  display: block;
  color: var(--fg-muted);
  font-size: .78rem;
  margin: .25rem 0 0;
}
.muted { color: var(--fg-muted); }
.sub {
  display: block;
  color: var(--fg-muted);
  font-size: .74rem;
  font-weight: 400;
}
.nowrap { white-space: nowrap; }
.wrap { word-break: break-word; }
.num { text-align: right; }

/* ---------------------------------------------------------------- banners */

.banner {
  padding: .5rem .75rem;
  border-radius: var(--r);
  border: 1px solid;
  margin: 0 0 .9rem;
}
.banner.flash { background: rgba(74,194,107,.08); border-color: #2e6f42; color: #b6f0c7; }
.banner.err   { background: rgba(255,123,114,.09); border-color: var(--danger-dim); color: #ffc7c2; }

.warn-strong {
  background: rgba(227,160,8,.10);
  border: 1px solid #7a5a06;
  border-radius: var(--r);
  padding: .6rem .75rem;
  color: #f5d98a;
  max-width: 90ch;
}
.warn-inline { color: var(--warn); }

/* --------------------------------------------------- "not measured" blocks */

/* The product's core honesty affordance: these list items must never be
 * mistaken for a metric tile, so they carry words and no digits. */
.not-measured-h { margin-top: .8rem; color: var(--fg-dim); }

ul.not-measured {
  list-style: none;
  padding: 0;
  margin: .4rem 0 0;
  display: grid;
  gap: .35rem;
  max-width: 92ch;
}
ul.not-measured li {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .6rem;
  align-items: baseline;
  padding: .45rem .6rem;
  background: var(--bg-sunken);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
}
.nm-name { color: var(--fg); }
.nm-state {
  color: var(--warn);
  font-size: .8rem;
  font-family: var(--mono);
}

ul.plain { padding-left: 1.1rem; color: var(--fg-dim); }
ul.plain li { margin-bottom: .3rem; }

/* --------------------------------------------------------------- stat rows */

/* Used only for counts that are real database facts (devices enrolled,
 * devices online). Never for acceleration figures. */
.stat-row { display: flex; gap: 1.6rem; margin: .5rem 0 .2rem; }
.stat { display: flex; flex-direction: column; }
.stat-num { font: 600 1.9rem/1.1 var(--mono); color: var(--fg); }
.stat-lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-muted); }

/* ------------------------------------------------------------ live region */

.live {
  min-height: 7rem;
  max-height: 16rem;
  overflow-y: auto;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: .5rem .6rem;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.45;
  margin-top: .5rem;
}
.live p { margin: 0 0 .2rem; }
.live > * + * { border-top: 1px solid rgba(255,255,255,.04); padding-top: .2rem; }

.live-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  margin: 0 .3rem 0 .35rem;
  vertical-align: middle;
}
.up-txt { color: var(--ok); font-size: .78rem; }

/* ------------------------------------------------------------------ tables */

.tbl-scroll { overflow-x: auto; }

table.tbl {
  width: 100%;
  border-collapse: collapse;
  margin-top: .5rem;
  font-size: .86rem;
}
table.tbl caption {
  caption-side: top;
  text-align: left;
  color: var(--fg-muted);
  font-size: .8rem;
  padding: .2rem 0 .45rem;
}
table.tbl th, table.tbl td {
  text-align: left;
  vertical-align: top;
  padding: .4rem .55rem;
  border-bottom: 1px solid var(--line);
}
table.tbl thead th {
  position: sticky;
  top: 0;
  background: var(--bg-sunken);
  color: var(--fg-dim);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}
table.tbl tbody tr:hover { background: rgba(255,255,255,.025); }
table.tbl tbody th[scope="row"] { font-weight: 600; }

table.tbl-kv th[scope="row"] {
  width: 14rem;
  color: var(--fg-dim);
  font-weight: 500;
}
table.tbl-audit td.before { color: var(--fg-muted); }
table.tbl-audit td.after  { color: var(--fg); }
table.tbl-audit td.act    { color: var(--accent); }

td.empty, p.empty {
  color: var(--fg-muted);
  padding: 1rem .55rem;
  font-style: italic;
}

/* ---------------------------------------------------------------- pills */

.pill {
  display: inline-block;
  padding: .05rem .4rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-sunken);
  font: 600 .72rem/1.5 var(--mono);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--fg-dim);
  white-space: nowrap;
}
.pill.s-active  { border-color: #2e6f42; color: #8ce0a4; }
.pill.s-pending { border-color: #7a5a06; color: #f5d98a; }
.pill.s-revoked { border-color: var(--danger-dim); color: #ffb3ad; }

.approx {
  font-family: var(--mono);
  color: var(--warn);
  border-bottom: 1px dotted var(--warn);
}

/* ----------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .6rem; }
.field > label { color: var(--fg-dim); font-size: .8rem; font-weight: 600; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
  align-items: flex-end;
  margin-top: .6rem;
}
.form-row .field { margin-bottom: 0; }
.field-action { justify-content: flex-end; }

.dials {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .9rem;
  margin-top: .4rem;
}

.check-field {
  flex-direction: row;
  align-items: center;
  gap: .45rem;
}
.check-field > label { font-weight: 400; }

/* A value the console derives rather than lets the operator choose. Styled
 * unmistakably as output, never as a disabled input: a greyed-out control
 * invites the reader to look for the way to enable it. */
.pseudo-label { color: var(--fg-dim); font-size: .8rem; font-weight: 600; }
.derived {
  margin: 0;
  padding: .3rem .5rem;
  background: var(--bg-sunken);
  border-left: 2px solid var(--line-strong);
  border-radius: 0 var(--r) var(--r) 0;
}

input[type="text"], input[type="password"], input[type="number"], select {
  background: var(--bg-input);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: .35rem .5rem;
  font: inherit;
  min-width: 0;
}
input[type="text"], input[type="password"] { font-family: var(--mono); font-size: .86em; }
input[type="number"] { font-family: var(--mono); max-width: 12rem; }
select { font-size: .88em; }

input::placeholder { color: #5c6875; }

input[readonly] { background: var(--bg-sunken); color: var(--ok); }

input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent-dim); }

fieldset.video-set {
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: .7rem .85rem .85rem;
  margin: .8rem 0 0;
}
fieldset.video-set legend {
  padding: 0 .4rem;
  color: var(--fg-dim);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.inline-form { display: flex; gap: .3rem; align-items: center; margin: 0; }
.inline-form select { max-width: 12rem; }

.policy-form { margin-top: .5rem; }
.actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .9rem; }

.token { width: 100%; font-size: 1rem; letter-spacing: .02em; padding: .5rem .6rem; }

pre.cmd {
  margin: 0;
  padding: .6rem .7rem;
  background: var(--bg-sunken);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  overflow-x: auto;
  color: #d7e3f0;
  white-space: pre;
}

dl.kv {
  display: grid;
  grid-template-columns: minmax(9rem, max-content) 1fr;
  gap: .3rem .9rem;
  margin: .7rem 0 0;
  font-size: .86rem;
}
dl.kv dt { color: var(--fg-muted); }
dl.kv dd { margin: 0; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-block;
  padding: .35rem .75rem;
  border-radius: var(--r);
  border: 1px solid var(--line-strong);
  background: var(--bg-sunken);
  color: var(--fg);
  font: 600 .84rem/1.4 var(--sans);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #1c2530; text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent-dim); border-color: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2f81f7; }

.btn-quiet { color: var(--fg-dim); font-weight: 500; }

.btn-danger { border-color: var(--danger-dim); color: #ffb3ad; }
.btn-danger:hover { background: rgba(255,123,114,.12); }

.btn-block { width: 100%; text-align: center; }

/* ------------------------------------------------------------------ login */

.login-page { background: var(--bg-sunken); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1rem;
}

.login-card {
  width: 100%;
  max-width: 22rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.2rem 1.25rem 1.35rem;
}
.brand-login { margin-bottom: 1rem; }
.login-title { font-size: 1.05rem; margin-bottom: .9rem; }
.login-form .field { margin-bottom: .8rem; }
.login-form input { width: 100%; }
.login-note { color: var(--fg-muted); font-size: .78rem; margin: .9rem 0 0; }
.login-foot { color: var(--fg-muted); font-size: .75rem; display: flex; gap: .5rem; }

/* ------------------------------------------------------- narrow viewports */

@media (max-width: 780px) {
  .topbar { flex-wrap: wrap; gap: .5rem; }
  .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .session { margin-left: auto; }
  .stat-row { gap: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .btn:active { transform: none; }
}

/* --- live device stream (#live, fed by console.js over SSE) --- */
.live-head { margin: 0 0 .5rem; }
.live-list { list-style: none; margin: 0; padding: 0; }
.live-item {
  display: grid;
  grid-template-columns: .75rem minmax(8rem, 1fr) auto auto auto auto auto;
  gap: .6rem;
  align-items: center;
  padding: .35rem 0;
  border-bottom: 1px solid var(--rule, #23262d);
}
.live-item:last-child { border-bottom: 0; }
.live-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-item.is-offline { opacity: .55; }
.live-item.is-online .live-dot { background: var(--ok, #3fb950); }
.live-item.is-offline .live-dot { background: var(--muted-fg, #6e7681); }
.live-item .live-dot {
  width: .55rem; height: .55rem; border-radius: 50%; display: inline-block;
}
.live-item .status-revoked { color: var(--bad, #f85149); }
.live-item .status-pending { color: var(--warn, #d29922); }

/* --- public setup page (setup.html) ------------------------------------- */
.doc-wrap { max-width: 62rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.doc-wrap h1 { margin: .25rem 0 .5rem; }
.doc-wrap .card { margin: 1.25rem 0; }
.doc-wrap .card h2 { margin-top: 0; }
.doc-wrap .btn { display: inline-block; text-decoration: none; }
.wrap { overflow-wrap: anywhere; word-break: break-all; }
.faq dt { margin-top: .75rem; font-weight: 600; }
.faq dd { margin: .2rem 0 0 1.25rem; }
.doc-foot { max-width: 62rem; margin: 0 auto; padding: 0 1.25rem 2rem; opacity: .6; font-size: .85rem; }

/* --- measured traffic on the overview ----------------------------------- */
.stats { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0 1.25rem; }
.stat { flex: 1 1 10rem; padding: .75rem .9rem; border: 1px solid var(--line, #2a2f3a);
        border-radius: .5rem; background: var(--panel, rgba(255,255,255,.02)); }
.stat-num { display: block; font-size: 1.5rem; line-height: 1.2; }
.stat-label { display: block; font-size: .8rem; opacity: .7; margin-top: .2rem; }
.tbl .num { text-align: right; }
/* <progress> rather than a div with an inline width: the console's CSP is
   style-src 'self', which forbids style= attributes, so a width set inline
   would be dropped and every bar would render empty. */
progress.meter { -webkit-appearance: none; appearance: none; width: 7rem; height: .55rem;
                 vertical-align: middle; margin-right: .4rem; border: 0; }
progress.meter::-webkit-progress-bar { background: rgba(127,127,127,.25); border-radius: .3rem; }
progress.meter::-webkit-progress-value { background: currentColor; opacity: .75; border-radius: .3rem; }
progress.meter::-moz-progress-bar { background: currentColor; opacity: .75; border-radius: .3rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
           overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
