/* ============================================================
   NODAVIO — PLATFORM PANEL
   The private admin panel. It used to run on a dark palette of its own,
   which made the one place the business is actually run look like a
   different product from the one it runs. It now uses the same tokens as
   the marketing site and signup: same teal, same paper, same IBM Plex.
   ============================================================ */

* { box-sizing: border-box; }

:root {
  --ink: 15 17 18;
  --ink-2: 43 48 51;
  --ink-muted: 100 106 110;
  --ink-faint: 150 155 158;
  --paper: 255 255 255;
  --paper-2: 247 246 244;
  --paper-3: 240 239 236;
  --border: 226 224 219;
  --border-strong: 200 197 190;
  --teal: 15 111 122;
  --teal-ink: 10 89 99;
  --healthy: 34 133 96;
  --caution: 178 108 42;
  --critical: 176 45 38;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --shadow-sm: 0 14px 30px -22px rgb(0 0 0 / 0.22);
  --shadow-md: 0 22px 44px -28px rgb(0 0 0 / 0.26);

  /* Chart colours are named by role, so a chart and a badge can't end up
     disagreeing about what "healthy" looks like. */
  --chart-bar: rgb(15 111 122);
  --chart-bar-empty: rgb(226 224 219);
  --chart-label: rgb(150 155 158);
}

body {
  margin: 0;
  color: rgb(var(--ink));
  font-family: 'IBM Plex Sans', ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px circle at 88% -12%, rgb(var(--teal) / 0.07), rgb(var(--teal) / 0) 55%),
    rgb(var(--paper-2));
  min-height: 100vh;
}

.data { font-variant-numeric: tabular-nums; }
a { color: rgb(var(--teal-ink)); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, p { margin: 0; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px; background: rgb(var(--paper));
  border-bottom: 1px solid rgb(var(--border));
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 20px; width: auto; display: block; }
.brand:hover { text-decoration: none; }
.brand-tag {
  font-size: 10.5px; letter-spacing: 0.07em;
  text-transform: uppercase; color: rgb(var(--teal-ink));
  background: rgb(var(--teal) / 0.09); padding: 3px 9px; border-radius: 999px;
}
.who { font-size: 12.5px; color: rgb(var(--ink-muted)); }

main { max-width: 1240px; margin: 0 auto; padding: 32px 32px 72px; }

.page-intro { margin-bottom: 26px; }
.page-intro h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-intro p { margin-top: 5px; font-size: 13.5px; color: rgb(var(--ink-muted)); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi {
  padding: 20px 22px; border-radius: var(--radius);
  background: rgb(var(--paper)); border: 1px solid rgb(var(--border)); box-shadow: var(--shadow-sm);
}
/* Only the revenue tile is lifted. If every tile is emphasised none is. */
.kpi-primary { background: rgb(var(--ink)); border-color: rgb(var(--ink)); }
.kpi-primary .kpi-label { color: rgb(255 255 255 / 0.6); }
.kpi-primary .kpi-value { color: rgb(var(--paper)); }
.kpi-primary .kpi-foot { color: rgb(255 255 255 / 0.5); }
.kpi-warn { border-color: rgb(var(--caution) / 0.5); background: rgb(var(--caution) / 0.05); }
.kpi-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: rgb(var(--ink-faint)); }
.kpi-value { display: block; margin-top: 9px; font-size: 27px; font-weight: 700; letter-spacing: -0.02em; }
.kpi-foot { display: block; margin-top: 5px; font-size: 12px; color: rgb(var(--ink-muted)); }
@media (max-width: 980px) { .kpis { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .kpis { grid-template-columns: 1fr; } }

/* ---------- Panels ---------- */
.panel {
  padding: 20px 22px; border-radius: var(--radius);
  background: rgb(var(--paper)); border: 1px solid rgb(var(--border)); box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.panel h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: rgb(var(--ink-faint)); margin-bottom: 16px; }
.panel-grid { display: grid; grid-template-columns: 1.3fr 1fr 1.2fr; gap: 14px; margin-bottom: 4px; }
.panel-grid .panel { margin-bottom: 14px; }
.panel-foot { margin-top: 14px; font-size: 12.5px; color: rgb(var(--ink-muted)); }
@media (max-width: 1080px) { .panel-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .panel-grid { grid-template-columns: 1fr; } }

.chart-wrap { height: 120px; }
.chart-svg { width: 100%; height: 100%; display: block; }
.chart-empty { font-size: 12.5px; color: rgb(var(--ink-faint)); }

/* Largest fleets */
.fleet-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.fleet-bars li { display: grid; grid-template-columns: minmax(0, 90px) 1fr auto; align-items: center; gap: 10px; }
.fleet-bar-name { font-size: 12.5px; color: rgb(var(--ink-2)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fleet-bar-track { height: 7px; border-radius: 999px; background: rgb(var(--paper-3)); overflow: hidden; }
.fleet-bar-fill { display: block; height: 100%; border-radius: 999px; background: rgb(var(--teal)); }
.fleet-bar-value { font-size: 12px; color: rgb(var(--ink-muted)); }

/* Customer base split */
.status-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: rgb(var(--paper-3)); }
.status-seg { display: block; height: 100%; }
.status-seg-active { background: rgb(var(--teal)); }
.status-seg-trial { background: rgb(var(--caution)); }
.status-seg-suspended { background: rgb(var(--ink-faint)); }
.status-key { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.status-key li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: rgb(var(--ink-2)); }
.status-key .data { margin-left: auto; color: rgb(var(--ink-muted)); }
.status-key-dot { width: 9px; height: 9px; border-radius: 999px; }

/* ---------- Needs attention ---------- */
.panel-attention { border-color: rgb(var(--caution) / 0.4); }
.attention-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.attention-list li { display: flex; align-items: center; gap: 11px; font-size: 13px; flex-wrap: wrap; }
.attention-dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; background: rgb(var(--caution)); }
.attention-suspended { background: rgb(var(--ink-faint)); }
.attention-backup { background: rgb(var(--critical)); }
.attention-no-subscription { background: rgb(var(--caution)); }
.attention-why { color: rgb(var(--ink-muted)); font-size: 12.5px; }

/* ---------- Table ---------- */
.panel-table { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px 14px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.sorts { display: flex; gap: 4px; }
.sorts a {
  font-size: 12px; padding: 5px 11px; border-radius: 999px; color: rgb(var(--ink-muted));
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.sorts a:hover { background: rgb(var(--paper-2)); text-decoration: none; }
.sorts a.is-active { background: rgb(var(--ink)); color: rgb(var(--paper)); }

table { width: 100%; border-collapse: separate; border-spacing: 0; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
  color: rgb(var(--ink-faint)); padding: 10px 16px; background: rgb(var(--paper-2));
  border-top: 1px solid rgb(var(--border)); border-bottom: 1px solid rgb(var(--border));
}
td { padding: 13px 16px; border-bottom: 1px solid rgb(var(--border)); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 120ms var(--ease); }
tbody tr:hover { background: rgb(var(--paper-2) / 0.7); }
th.num, td.num { text-align: right; }
.row-name { font-weight: 600; color: rgb(var(--ink)); }
.row-name:hover { color: rgb(var(--teal-ink)); }
.muted { display: block; color: rgb(var(--ink-muted)); font-size: 11.5px; margin-top: 1px; font-weight: 400; }
.muted-cell { color: rgb(var(--ink-muted)); font-size: 12px; }
.empty { text-align: center; color: rgb(var(--ink-faint)); padding: 40px; font-size: 12.5px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 999px; background: currentColor; flex-shrink: 0; }
.badge-active { background: rgb(var(--healthy) / 0.12); color: rgb(var(--healthy)); }
.badge-trial { background: rgb(var(--caution) / 0.13); color: rgb(var(--caution)); }
/* Paid but never activated: the only state where somebody is being charged
   for a workspace they cannot sign into, so it reads as critical. */
.attention-not-activated { background: rgb(var(--critical)); }
.badge-setup { background: rgb(var(--critical) / 0.1); color: rgb(var(--critical)); }

.badge-suspended { background: rgb(var(--ink-muted) / 0.13); color: rgb(var(--ink-muted)); }
.badge-backup-ok { background: rgb(var(--healthy) / 0.12); color: rgb(var(--healthy)); }
.badge-backup-stale { background: rgb(var(--caution) / 0.13); color: rgb(var(--caution)); }
.badge-backup-failed { background: rgb(var(--critical) / 0.1); color: rgb(var(--critical)); }
.badge-backup-none { background: rgb(var(--ink-muted) / 0.12); color: rgb(var(--ink-muted)); }

/* ---------- Notices ----------
   Shown after an action whose result the page cannot otherwise show. The
   only one so far is resending a setup link: nothing on the page changes
   either way, so without this the operator cannot tell a sent mail from a
   refused one. */
.notice {
  margin-bottom: 18px; padding: 12px 14px; border-radius: 8px;
  font-size: 13px; line-height: 1.55; border: 1px solid transparent;
}
.notice-ok { background: rgb(var(--healthy) / 0.08); border-color: rgb(var(--healthy) / 0.25); color: rgb(var(--ink)); }
.notice-bad { background: rgb(var(--critical) / 0.07); border-color: rgb(var(--critical) / 0.3); color: rgb(var(--ink)); }
.notice .muted { display: inline; font-size: 12.5px; }
/* The link is long and gets copied out of here by hand, so it wraps
   rather than overflowing the card. */
.notice-link {
  display: block; margin-top: 8px; padding: 7px 9px; border-radius: 6px;
  background: rgb(var(--ink) / 0.05); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; word-break: break-all; user-select: all;
}

/* ---------- Billing contact form ---------- */
.card { border: 1px solid rgb(var(--border)); border-radius: var(--radius); padding: 16px; background: rgb(var(--paper)); }
.card-hint { margin: 0 0 14px; font-size: 12.5px; line-height: 1.6; color: rgb(var(--ink-muted)); max-width: 62ch; }
.contact-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.contact-form label { display: flex; flex-direction: column; gap: 5px; flex: 1 1 240px; }
.contact-form label span { font-size: 11.5px; font-weight: 500; color: rgb(var(--ink-muted)); }
.contact-form input {
  padding: 7px 10px; border: 1px solid rgb(var(--border)); border-radius: var(--radius-sm);
  font: inherit; font-size: 13px; color: rgb(var(--ink)); background: rgb(var(--paper));
}
.contact-form input:focus { outline: 2px solid rgb(var(--teal-ink) / 0.35); outline-offset: 1px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 13px; border-radius: 999px; font-size: 12px; font-weight: 500; font-family: inherit;
  cursor: pointer; border: 1px solid rgb(var(--border-strong)); background: rgb(var(--paper)); color: rgb(var(--ink-2));
  transition: border-color 140ms var(--ease), background 140ms var(--ease), color 140ms var(--ease);
}
.btn:hover { border-color: rgb(var(--ink)); color: rgb(var(--ink)); text-decoration: none; }
.btn-danger { border-color: rgb(var(--critical) / 0.35); color: rgb(var(--critical)); }
.btn-danger:hover { background: rgb(var(--critical) / 0.07); border-color: rgb(var(--critical) / 0.6); color: rgb(var(--critical)); }
.btn-accent { border-color: transparent; background: rgb(var(--ink)); color: rgb(var(--paper)); font-weight: 600; }
.btn-accent:hover { background: rgb(var(--ink-2)); color: rgb(var(--paper)); }

/* ---------- Tenant detail ---------- */
.back-link {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px;
  color: rgb(var(--ink-muted)); margin-bottom: 18px;
}
.tenant-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.tenant-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 5px; }
.tenant-header-actions { display: flex; align-items: center; gap: 10px; }
.subtitle { font-size: 12.5px; color: rgb(var(--ink-muted)); }
.subtitle .muted { display: inline; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat {
  padding: 16px 18px; border-radius: var(--radius);
  background: rgb(var(--paper)); border: 1px solid rgb(var(--border)); box-shadow: var(--shadow-sm);
}
.stat-value { display: block; font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.stat-label { display: block; font-size: 10.5px; color: rgb(var(--ink-faint)); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: rgb(var(--ink-faint)); margin: 32px 0 12px; }
.section-title:first-of-type { margin-top: 8px; }
.panel-table table { background: rgb(var(--paper)); }

/* ---------- Login ---------- */
.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; padding: 34px 32px;
  border: 1px solid rgb(var(--border)); border-radius: var(--radius-lg);
  background: rgb(var(--paper)); box-shadow: var(--shadow-md);
}
.login-logo { height: 21px; width: auto; margin-bottom: 20px; display: block; }
.login-card h1 { font-size: 18px; margin: 0 0 5px; font-weight: 700; letter-spacing: -0.015em; }
.login-card label { display: block; font-size: 12.5px; color: rgb(var(--ink-2)); margin-bottom: 14px; font-weight: 500; }
.login-card input {
  display: block; width: 100%; margin-top: 6px; padding: 11px 13px;
  background: rgb(var(--paper)); border: 1.5px solid rgb(var(--border-strong)); border-radius: var(--radius-sm);
  color: rgb(var(--ink)); font-size: 14px; font-family: inherit;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.login-card input:focus { outline: none; border-color: rgb(var(--teal)); box-shadow: 0 0 0 4px rgb(var(--teal) / 0.13); }
.btn-primary {
  width: 100%; padding: 12px; margin-top: 6px;
  background: rgb(var(--ink)); color: rgb(var(--paper));
  border: none; border-radius: 999px; font-weight: 600; font-size: 14px; font-family: inherit; cursor: pointer;
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 26px -14px rgb(0 0 0 / 0.4); }
.error {
  background: rgb(var(--critical) / 0.07); border: 1px solid rgb(var(--critical) / 0.28);
  color: rgb(var(--critical)); padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; margin-bottom: 16px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

@media (max-width: 640px) {
  .topbar { padding: 12px 18px; }
  main { padding: 22px 18px 56px; }
  .panel-table { overflow-x: auto; }
}

.notice {
  margin: -8px 0 26px; padding: 11px 14px; border-radius: var(--radius-sm);
  background: rgb(var(--caution) / 0.07); border: 1px solid rgb(var(--caution) / 0.32);
  color: rgb(var(--ink-2)); font-size: 12.5px;
}
