/* ═══════════════════════════════════════════════════════════════════════════
   I.R.O.N. — Integrated Revenue & Outreach Network
   Industrial steel and ember fire. EmberNet · Fireball Industries

   Hand-written CSS, not a compiled framework. The predecessor pulled Tailwind
   v4 plus thirteen Radix packages to render nine tables and a launcher; this is
   one file, served from the binary, with the same tokens.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;

  --radius: 6px;
  --radius-sm: 4px;

  /* Background layers */
  --background: #0d1117;
  --surface: #141d27;
  --surface-elevated: #19232f;
  --card: #141d27;

  /* Text */
  --foreground: #c8dde9;
  --muted-foreground: #64748b;

  /* Borders */
  --border: #1e2a38;
  --border-strong: #253040;

  /* Ember — the accent */
  --ember-500: #f97316;
  --ember-400: #fb923c;
  --ember-300: #fdba74;
  --ember-subtle: rgba(249, 115, 22, 0.15);

  /* Status */
  --ok: #10b981;
  --warn: #f59e0b;
  --crit: #ef4444;
  --offline: #64748b;
  --info: #06b6d4;

  --sidebar-bg: #080b0e;
  --shadow-panel: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* Light mode. The palette inverts; the ember accent does not, because it is the
   brand rather than a shade. */
@media (prefers-color-scheme: light) {
  :root {
    --background: #f0f4f8;
    --surface: #e8eef4;
    --surface-elevated: #ffffff;
    --card: #ffffff;
    --foreground: #0f1923;
    --muted-foreground: #5b6b7c;
    --border: #d1dce8;
    --border-strong: #b8c8d8;
    --sidebar-bg: #1a2332;
    --shadow-panel: 0 2px 12px rgba(15, 25, 35, 0.08);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
p { margin: 0; }

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

.mono { font-family: var(--font-mono); font-size: 12px; }
.wrap { overflow-wrap: anywhere; }

::selection { background: rgba(249, 115, 22, 0.3); }

:focus-visible {
  outline: 2px solid var(--ember-500);
  outline-offset: 2px;
}

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

/* ── Icons ─────────────────────────────────────────────────────────────── */

.icon {
  width: 18px; height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Shell ─────────────────────────────────────────────────────────────── */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: none;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0 10px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  background: var(--ember-subtle);
  border: 1px solid rgba(249, 115, 22, 0.3);
  color: var(--ember-500);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }

.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2em;
  color: #e8f4fa;
  text-shadow: 0 0 18px rgba(249, 115, 22, 0.55);
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.nav-secondary {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: #93a7b8;
  font-weight: 500;
  text-decoration: none;
}

.nav-item:hover {
  background: #19232f;
  color: var(--foreground);
  text-decoration: none;
}

.nav-item-active {
  background: rgba(249, 115, 22, 0.16);
  border-color: rgba(249, 115, 22, 0.3);
  color: var(--ember-400);
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-title { font-size: 15px; }
.topbar-spacer { flex: 1; }

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

.user-initials {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ember-subtle);
  border: 1px solid rgba(249, 115, 22, 0.3);
  color: var(--ember-400);
  font-size: 11px;
  font-weight: 600;
}

.user-name { font-weight: 500; }

.btn-icon {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--muted-foreground);
  cursor: pointer;
}

.btn-icon:hover { color: var(--ember-400); background: var(--surface-elevated); }

.content {
  flex: 1;
  padding: 22px;
  max-width: 1500px;
  width: 100%;
}

.footer {
  display: flex;
  justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 12px;
}

/* ── Page furniture ────────────────────────────────────────────────────── */

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

.page-sub { color: var(--muted-foreground); margin-top: 4px; }

.section { margin-top: 30px; }

.group-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-bottom: 10px;
}

/* ── Alerts ────────────────────────────────────────────────────────────── */

.alert {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 18px;
  font-size: 13px;
}

.alert-error { border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.08); }
.alert-warn { border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.08); }

/* ── Stats ─────────────────────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 15px 17px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

.stat-degraded { border-color: rgba(245, 158, 11, 0.35); }

.stat-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.stat-value-muted { color: var(--muted-foreground); }

.stat-note {
  font-size: 11px;
  color: var(--muted-foreground);
  overflow-wrap: anywhere;
}

/* ── Panels ────────────────────────────────────────────────────────────── */

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 17px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

.panel-title { display: flex; align-items: center; gap: 8px; }
.panel-title .icon { color: var(--ember-500); }

.panel-body { color: var(--muted-foreground); font-size: 13px; }

.panel-link {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}

.panel-link .icon { width: 15px; height: 15px; }

.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 14px;
  margin: 0;
}

.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; text-align: right; font-weight: 500; }

/* ── Tables ────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  font-weight: 600;
  background: var(--surface);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-elevated); }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--muted-foreground); }
.cell-action { text-align: right; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  margin-right: 4px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 11px;
}

/* ── Badges ────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-ok { color: var(--ok); border-color: rgba(16, 185, 129, 0.4); background: rgba(16, 185, 129, 0.1); }
.badge-warn { color: var(--warn); border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.1); }
.badge-crit { color: var(--crit); border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.1); }
.badge-info { color: var(--info); border-color: rgba(6, 182, 212, 0.4); background: rgba(6, 182, 212, 0.1); }
.badge-offline { color: var(--offline); border-color: var(--border-strong); background: var(--surface); }

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

/* ── Buttons and forms ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--foreground);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { border-color: var(--ember-500); color: var(--ember-400); text-decoration: none; }

.btn-primary {
  background: var(--ember-500);
  border-color: var(--ember-500);
  color: #fff;
}

.btn-primary:hover { background: var(--ember-400); border-color: var(--ember-400); color: #fff; }

.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-block { display: flex; justify-content: center; width: 100%; }

.btn-disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

input[type="search"], input[type="text"], select, textarea {
  padding: 7px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--foreground);
  font-family: inherit;
  font-size: 13px;
}

textarea { width: 100%; resize: vertical; }

.search { display: flex; gap: 8px; }

.checkbox { display: flex; align-items: center; gap: 7px; color: var(--muted-foreground); font-size: 13px; }

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.pager-page { color: var(--muted-foreground); font-size: 13px; }

.tabs { display: flex; gap: 4px; }

.tab {
  padding: 6px 13px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 500;
}

.tab:hover { background: var(--surface-elevated); text-decoration: none; }

.tab-active {
  background: rgba(249, 115, 22, 0.16);
  border-color: rgba(249, 115, 22, 0.3);
  color: var(--ember-400);
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted-foreground);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

/* ── Launcher ──────────────────────────────────────────────────────────── */

.tool-group { margin-bottom: 26px; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 12px;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  box-shadow: var(--shadow-panel);
}

.tool-card:hover {
  border-color: rgba(249, 115, 22, 0.45);
  text-decoration: none;
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  flex: none;
  border-radius: var(--radius);
  background: var(--ember-subtle);
  border: 1px solid rgba(249, 115, 22, 0.3);
  color: var(--ember-500);
}

.tool-icon .icon { width: 20px; height: 20px; }

.tool-text { display: flex; flex-direction: column; min-width: 0; }
.tool-name { font-weight: 600; }
.tool-desc { font-size: 12px; color: var(--muted-foreground); }

/* The sign-in warning on the two cards that do not use Vord. Ember rather than
   --warn, because it is a fact about the card and not a fault: amber next to a
   red status badge elsewhere on the page reads as something being wrong. */
.tool-note {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ember-400);
}

/* ── Inbox ─────────────────────────────────────────────────────────────── */

.thread-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}

.thread {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
  color: var(--foreground);
}

.thread-list li:last-child .thread { border-bottom: none; }
.thread:hover { background: var(--surface-elevated); text-decoration: none; }

.thread-avatar {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--muted-foreground);
}

.thread-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.thread-top { display: flex; justify-content: space-between; gap: 12px; }
.thread-name { font-weight: 600; }
.thread-time, .thread-meta { color: var(--muted-foreground); font-size: 12px; }

.messages { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 10px; }

.message {
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  max-width: 78%;
}

.message-in { margin-right: auto; }
.message-out { margin-left: auto; border-color: rgba(249, 115, 22, 0.3); }
.message-private { border-style: dashed; border-color: rgba(245, 158, 11, 0.5); }

.message-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 5px;
  font-size: 12px;
}

.message-sender { font-weight: 600; }
.message-time { color: var(--muted-foreground); }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }

.reply {
  display: grid;
  gap: 10px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

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

/* ── Login ─────────────────────────────────────────────────────────────── */

.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

.brand-login { height: auto; border-bottom: none; margin: 0; padding: 0; }
.brand-login .brand-sub { text-transform: none; letter-spacing: 0.02em; font-size: 11px; }

.login-text { color: var(--foreground); }
.login-note { color: var(--muted-foreground); font-size: 12px; }
.login-footer { color: var(--muted-foreground); }

/* ── Narrow screens ────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .nav-item span { display: none; }
  .nav-secondary { margin-top: 8px; padding-top: 8px; }
  .message { max-width: 100%; }
}
