/* SmartSupport console
   One stylesheet, no framework, no build step: the console has to be
   inspectable by whoever operates it. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dcdfe4;
  --border-strong: #c2c7cf;
  --text: #16191d;
  --text-dim: #5d6470;
  --text-faint: #8a919e;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e8efff;
  --ok: #14804a;
  --ok-soft: #e3f4ec;
  --warn: #a15c07;
  --warn-soft: #fdf1dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.06);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f39;
    --border-strong: #3a414d;
    --text: #e8eaed;
    --text-dim: #a2a9b5;
    --text-faint: #737b88;
    --accent: #5b8dff;
    --accent-text: #0b1020;
    --accent-soft: #1b2540;
    --ok: #4ade80;
    --ok-soft: #14281d;
    --warn: #fbbf24;
    --warn-soft: #2a2110;
    --danger: #f87171;
    --danger-soft: #2c1618;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }

/* ---------------------------------------------------------------- boot */
.app-loading { display: grid; place-items: center; height: 100%; }
.boot { text-align: center; }
.boot-mark { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.boot-note { color: var(--text-faint); margin-top: 6px; }

/* ---------------------------------------------------------------- auth */
.auth-wrap { display: grid; place-items: center; min-height: 100%; padding: 24px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 28px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.015em; }
.auth-card .sub { color: var(--text-dim); margin: 0 0 22px; }
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.brand-dot {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
}
.brand-name { font-weight: 650; letter-spacing: -.01em; }

label { display: block; font-weight: 550; margin: 14px 0 5px; font-size: 13px; }
label .hint { font-weight: 400; color: var(--text-faint); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--surface); color: var(--text);
  font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input.code-input {
  font-family: var(--mono); font-size: 22px; letter-spacing: .3em; text-align: center;
}

button {
  font: inherit; font-weight: 550; padding: 9px 15px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); cursor: pointer;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.danger:hover:not(:disabled) { background: var(--danger-soft); }
button.block { width: 100%; }
button.small { padding: 5px 10px; font-size: 13px; }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover:not(:disabled) { background: var(--surface-2); }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: grid; gap: 10px; }

.msg { padding: 10px 12px; border-radius: 8px; margin: 14px 0; font-size: 13px; }
.msg.error { background: var(--danger-soft); color: var(--danger); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.info { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar .brand-row { padding: 0 6px; }
.nav { display: grid; gap: 2px; }
.nav button {
  text-align: left; border: none; background: transparent; padding: 8px 10px;
  border-radius: 8px; color: var(--text-dim); font-weight: 550; width: 100%;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; padding: 10px 6px 0; border-top: 1px solid var(--border); }
.who { font-size: 12px; color: var(--text-faint); margin-bottom: 8px; word-break: break-all; }

.main { overflow: auto; padding: 24px 28px 60px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 19px; letter-spacing: -.015em; }
.page-head p { margin: 3px 0 0; color: var(--text-dim); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .sub { color: var(--text-dim); margin: 0 0 14px; font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 600; color: var(--text-dim); padding: 8px 10px;
  border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap;
}
.pill.on { background: var(--ok-soft); color: var(--ok); }
.pill.off { background: var(--surface-2); color: var(--text-faint); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

code, .mono { font-family: var(--mono); font-size: 12.5px; }
pre.snippet {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px;
  margin: 0; white-space: pre-wrap; word-break: break-all;
}
.recovery-codes {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px;
  font-family: var(--mono); margin: 12px 0;
}
.recovery-codes span {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 7px 10px; border-radius: 6px; text-align: center;
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; word-break: break-word; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-faint); }

.toggle-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .label { flex: 1; }
.toggle-row .label b { display: block; font-weight: 550; }
.toggle-row .label span { color: var(--text-faint); font-size: 12.5px; }

/* ------------------------------------------------------------- session */
.session-root {
  position: fixed; inset: 0; background: #0b0d10; color: #e8eaed;
  display: grid; grid-template-rows: auto 1fr; z-index: 50;
}
.session-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: #14171c; border-bottom: 1px solid #262b33; flex-wrap: wrap;
}
.session-bar .title { font-weight: 600; }
.session-bar .meta { color: #8a919e; font-size: 12.5px; }
.session-bar button {
  background: #1e232b; border-color: #333a45; color: #e8eaed;
  padding: 5px 10px; font-size: 13px;
}
.session-bar button:hover:not(:disabled) { background: #262c36; }
.session-bar button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.session-bar select {
  background: #1e232b; border-color: #333a45; color: #e8eaed;
  padding: 5px 8px; width: auto; font-size: 13px;
}
.session-body { position: relative; overflow: hidden; display: grid; }
.screen-wrap {
  position: relative; display: grid; place-items: center;
  background: #000; overflow: hidden; height: 100%;
}
#screen { max-width: 100%; max-height: 100%; display: block; cursor: crosshair; }
#screen.controlling { cursor: none; }

.session-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(11,13,16,.92); text-align: center; padding: 24px; z-index: 5;
}
.session-overlay .inner { max-width: 460px; }
.session-overlay h3 { margin: 0 0 8px; font-size: 18px; }
.session-overlay p { color: #a2a9b5; margin: 0 0 16px; }
.spinner {
  width: 26px; height: 26px; border: 2.5px solid #333a45; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 800ms linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.side-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 90vw);
  background: #14171c; border-left: 1px solid #262b33; display: grid;
  grid-template-rows: auto 1fr; z-index: 10;
}
.side-panel header {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid #262b33; font-weight: 600;
}
.side-panel .body { overflow: auto; padding: 12px; }
.side-panel button { background: #1e232b; border-color: #333a45; color: #e8eaed; }
#terminal-host { height: 100%; padding: 6px; }
.file-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  border-radius: 6px; cursor: default; font-size: 13px;
}
.file-row:hover { background: #1e232b; }
.file-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row.dir .name { color: #93b4ff; cursor: pointer; }
.file-row .size { color: #737b88; font-family: var(--mono); font-size: 12px; }
.path-bar {
  display: flex; gap: 6px; margin-bottom: 10px; align-items: center;
}
.path-bar input { background: #1e232b; border-color: #333a45; color: #e8eaed; }

.banner-consent {
  background: var(--warn-soft); color: var(--warn); padding: 8px 12px;
  font-size: 13px; text-align: center;
}

/* ------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,12,16,.55);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; width: 100%; max-width: 520px; box-shadow: var(--shadow);
  max-height: 88vh; overflow: auto;
}
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal .sub { color: var(--text-dim); margin: 0 0 16px; font-size: 13px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.toast-host {
  position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 200;
}
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left-width: 3px;
  border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow);
  max-width: 360px; font-size: 13px;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
.toast.info { border-left-color: var(--accent); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { flex-direction: row; align-items: center; padding: 10px; overflow-x: auto; }
  .sidebar .brand-row { margin: 0 12px 0 0; }
  .nav { display: flex; gap: 4px; }
  .sidebar-foot { margin: 0 0 0 auto; border: none; padding: 0; }
  .who { display: none; }
  .main { padding: 16px; }
}

/* ------------------------------------------------------ usage meters */
.meter { display: flex; align-items: center; gap: 7px; }
.meter-track {
  flex: 1; height: 6px; min-width: 42px; border-radius: 3px;
  background: var(--surface-2); overflow: hidden;
}
.meter-fill { height: 100%; border-radius: 3px; transition: width .4s ease, background .4s ease; }
.meter-label { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 30px; }

/* ------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 4px 0 16px; }
.tab {
  border: none; background: transparent; padding: 8px 12px; border-radius: 8px 8px 0 0;
  color: var(--text-dim); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { background: var(--surface-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); background: transparent; }

.cmd-label { font-size: 12.5px; font-weight: 550; color: var(--text-dim); margin-bottom: 5px; }

/* ------------------------- focused sessions (files / terminal only) */
.panel-host {
  height: 100%; overflow: auto; padding: 16px 18px;
  background: #14171c; color: #e8eaed;
}
.panel-host input, .panel-host textarea, .panel-host select {
  background: #1e232b; border-color: #333a45; color: #e8eaed;
}
.panel-host button { background: #1e232b; border-color: #333a45; color: #e8eaed; }
.panel-host button:hover:not(:disabled) { background: #262c36; }
.panel-host button.danger { color: #f87171; border-color: #4a2427; background: transparent; }
.panel-host #terminal-host { height: calc(100vh - 90px); padding: 0; }
.fill-host { height: 100%; }
.side-panel .fill-host { padding: 0; }

.session-bar .pill { font-size: 11.5px; }

/* ------------------------------------------------------ rollout summary */
.stat-row { display: flex; gap: 22px; margin: 12px 0 14px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 22px; font-weight: 620; letter-spacing: -.02em; line-height: 1.15; }
.stat b.bad { color: var(--danger); }
.stat span { font-size: 12px; color: var(--text-dim); }
.version-row { display: flex; align-items: center; margin: 7px 0; font-size: 13px; }
.version-row .mono { min-width: 74px; }
