/* Operator portal styles.
   Served as a static file so the Content-Security-Policy can forbid inline
   styles entirely (see src/app.ts). Light and dark are both selected sets —
   dark is not an automatic inversion. */

:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --plane: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px rgba(11, 11, 11, 0.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #1a1a19;
    --plane: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --accent: #3987e5;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #1a1a19;
  --plane: #0d0d0d;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --accent: #3987e5;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0 0 4px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

p {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}

.sub {
  color: var(--ink-2);
  margin: 0 0 20px;
}

/* --- Shell ------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  padding: 0 8px;
  color: var(--ink);
  text-decoration: none;
}

.brand-logo {
  height: 26px;
  max-width: 120px;
  object-fit: contain;
  flex: none;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  flex: none;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
}

.nav a:hover {
  background: var(--plane);
  color: var(--ink);
}

.nav a[aria-current="page"] {
  background: var(--plane);
  color: var(--ink);
  font-weight: 600;
}

.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 10px;
  margin-top: 8px;
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  font-size: 13px;
}

.who {
  padding: 0 10px 10px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.main {
  padding: 28px 32px 64px;
  max-width: 1180px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* --- Cards, tiles ------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* Several controls sharing the right-hand side of a card head. */
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.tile-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.tile-value {
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.tile-note {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 4px;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.client-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}

.client-card:hover {
  border-color: var(--accent);
}

.client-card h3 {
  margin-bottom: 8px;
}

.client-meta {
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.add-card {
  display: grid;
  place-items: center;
  border: 1px dashed var(--axis);
  border-radius: var(--radius);
  color: var(--ink-2);
  text-decoration: none;
  min-height: 108px;
  font-weight: 600;
}

.add-card:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--ink-2);
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.pill-good {
  color: var(--good);
}

.pill-warn {
  color: var(--warning);
}

.pill-bad {
  color: var(--critical);
}

.pill-idle {
  color: var(--muted);
}

/* --- Tables ------------------------------------------------------------ */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.empty {
  color: var(--muted);
  padding: 24px 10px;
  text-align: center;
}

/* --- Forms ------------------------------------------------------------- */

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--ink-2);
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--axis);
  background: var(--plane);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.field {
  margin-bottom: 14px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
  font-weight: 400;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.btn:hover {
  filter: brightness(1.06);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--axis);
}

.btn-danger {
  background: transparent;
  color: var(--critical);
  border-color: var(--border);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* --- Notices ----------------------------------------------------------- */

.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  padding: 11px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  background: var(--surface);
}

.notice-error {
  border-left-color: var(--critical);
}

.notice-ok {
  border-left-color: var(--good);
}

.notice-warn {
  border-left-color: var(--warning);
}

.notice strong {
  display: block;
  margin-bottom: 2px;
}

/* --- Auth pages -------------------------------------------------------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-weight: 650;
  font-size: 17px;
}

.auth-foot {
  margin-top: 16px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.auth button {
  width: 100%;
  margin-top: 4px;
}

/* --- Chart ------------------------------------------------------------- */

.chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-grid {
  stroke: var(--grid);
  stroke-width: 1;
}

.chart-axis {
  stroke: var(--axis);
  stroke-width: 1;
}

.chart-tick {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  r: 3;
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-label {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
}

.s1 {
  stroke: var(--series-1);
}

.s2 {
  stroke: var(--series-2);
}

.s3 {
  stroke: var(--series-3);
}

.f1 {
  fill: var(--series-1);
}

.f2 {
  fill: var(--series-2);
}

.f3 {
  fill: var(--series-3);
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink-2);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.swatch-1 {
  background: var(--series-1);
}

.swatch-2 {
  background: var(--series-2);
}

.swatch-3 {
  background: var(--series-3);
}

.preview-frame {
  width: 100%;
  height: 520px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

details.table-view summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 12px;
}

/* --- Misc -------------------------------------------------------------- */

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.secret {
  background: var(--plane);
  border: 1px solid var(--axis);
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.codes {
  columns: 2;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  margin: 0;
  padding-left: 18px;
}

.qr {
  width: 176px;
  height: 176px;
  background: #ffffff;
  border-radius: 8px;
  padding: 8px;
  border: 1px solid var(--border);
}

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 38px;
  margin-bottom: 16px;
}

.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px 6px;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main {
    padding: 20px 16px 48px;
  }
}
