/* CarLog Control Panel — UI. One stylesheet, no build step.
   Visual language of the app and carlog.me (web/): Figtree, ink #111827 on
   soft surfaces #F4F5F7, white borderless cards (radii 14 / 20 / 28), pill
   buttons, uppercase eyebrows. The sidebar is the site's dark ink band. */

@font-face {
  font-family: Figtree;
  src: url("/static/font/figtree.ttf") format("truetype");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #111827;
  --body: #3f4654;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #eceef2;
  --border: #eceef1;
  --border-strong: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af; /* icons and rules only, never text */
  --placeholder: #5f6673;
  --accent: #346df1;
  --accent-strong: #111827;
  --accent-soft: rgba(52, 109, 241, 0.1);
  --green: #059669;
  --green-soft: rgba(16, 185, 129, 0.12);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.09);
  --amber: #b45309;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.1);
  --violet: #0d9488;
  --violet-soft: rgba(13, 148, 136, 0.12);
  --gray-soft: rgba(107, 114, 128, 0.11);
  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --radius: 20px;
  --radius-sm: 14px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --shadow-soft: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-hover: 0 18px 38px rgba(17, 24, 39, 0.09);
  --shadow: 0 24px 60px rgba(17, 24, 39, 0.18);
  --font: Figtree, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
/* Component display rules (e.g. .banner's flex) must not defeat the hidden attribute. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 500 14.5px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 8px; }

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

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

/* The site's dark ink band, as a sidebar. */
.sidebar {
  width: 252px; flex: none; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px; padding: 22px 14px;
  background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 24px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; flex: none; display: block; }
.brand-text strong { display: block; font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.brand-text span { font-size: 12.5px; color: #8b93a1; }
.env-chip {
  margin-left: auto; font-size: 11px; font-weight: 800; letter-spacing: 0.1em;
  padding: 4px 9px; border-radius: 999px; color: #d1d5db; background: rgba(255, 255, 255, 0.1);
}
/* The environment is the first thing to read: DEV yellow, STAGE orange, PROD red (admin-panel.md §2). */
[data-env="dev"] .env-chip { color: #fcd34d; background: rgba(252, 211, 77, 0.14); }
[data-env="stage"] .env-chip { color: #fdba74; background: rgba(251, 146, 60, 0.16); }
[data-env="prod"] .env-chip { color: #fff; background: #dc2626; }
.topbar .env-chip { margin-left: 0; }
[data-env="dev"] .topbar .env-chip { color: #92400e; background: #fef3c7; }
[data-env="stage"] .topbar .env-chip { color: #9a3412; background: #ffedd5; }
/* On production a red edge runs along the top of every screen. */
[data-env="prod"] body::before {
  content: ""; position: fixed; inset: 0 0 auto 0; height: 4px; background: #dc2626; z-index: 200; pointer-events: none;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 11px; font-weight: 700; color: #9aa1ae; text-transform: uppercase;
  letter-spacing: 0.14em; padding: 18px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 999px;
  color: #b6bcc8; font-weight: 600; font-size: 14.5px; cursor: pointer; border: 0; background: none;
  text-align: left; width: 100%; text-decoration: none !important;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.nav-item.active { color: #fff; background: rgba(255, 255, 255, 0.1); }
.nav-badge {
  margin-left: auto; min-width: 22px; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-align: center; background: #ef4444; color: #fff;
}
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 14px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; gap: 12px; padding: 12px 16px;
  background: rgba(255, 255, 255, 0.82); backdrop-filter: saturate(180%) blur(20px);
  position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 0 rgba(17, 24, 39, 0.07);
}
.content { padding: 34px 40px 80px; max-width: 1400px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: clamp(26px, 2.4vw, 32px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.view { display: none; }
.view.active { display: block; animation: fade-in 0.35s var(--ease); }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

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

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.015em; }
.card-head .sub { color: var(--muted); font-size: 13px; font-weight: 600; }
.card-body { padding: 18px 22px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* The site's calculator tiles. */
.kpi { padding: 22px 22px 24px; }
.kpi-label {
  color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
.kpi-value { font-size: clamp(30px, 2.6vw, 38px); font-weight: 700; letter-spacing: -0.04em; margin-top: 10px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 16px; color: var(--muted); font-weight: 600; letter-spacing: -0.01em; }
.kpi-foot { color: var(--muted); font-size: 13px; margin-top: 4px; }
.kpi-icon { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.kpi-icon svg { width: 16px; height: 16px; }

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

.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 21px;
  background: var(--gray-soft); color: var(--muted);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.violet { background: var(--violet-soft); color: var(--violet); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--faint); }
.dot.green { background: #10b981; box-shadow: 0 0 0 4px var(--green-soft); }
.dot.red { background: #ef4444; box-shadow: 0 0 0 4px var(--red-soft); }
.dot.amber { background: #f59e0b; box-shadow: 0 0 0 4px var(--amber-soft); }

.tag {
  font-family: var(--mono); font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink);
}

/* ------------------------------------------------- buttons (the app's pills) */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 20px; border-radius: 999px; cursor: pointer;
  font-weight: 700; font-size: 14px; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease), opacity 0.2s;
  text-decoration: none !important;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--faint); transform: translateY(-1px); box-shadow: 0 8px 18px rgba(17, 24, 39, 0.08); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #000; border-color: #000; box-shadow: 0 10px 22px rgba(17, 24, 39, 0.24); }
.btn.danger { background: var(--surface); border-color: rgba(220, 38, 38, 0.3); color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: rgba(220, 38, 38, 0.45); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger.solid:hover { background: #b91c1c; border-color: #b91c1c; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn.icon { width: 40px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn.block { width: 100%; }
.btn .spinner { width: 14px; height: 14px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; color: var(--body); }
.field .hint { font-size: 12px; color: var(--muted); }
.field.error .input { box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.45); }
.field .err { font-size: 12.5px; color: var(--red); font-weight: 600; }
.input, .select, textarea.input {
  height: 44px; padding: 0 16px; border-radius: var(--r-sm); width: 100%;
  background: var(--surface-2); color: var(--ink); border: 1px solid transparent;
  font: inherit; outline: none; transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.input:hover, .select:hover { background-color: var(--surface-3); }
.input:focus, .select:focus { background-color: var(--surface); box-shadow: 0 0 0 2px var(--ink); }
.input::placeholder { color: var(--placeholder); }
.select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.select.sm { height: 32px; font-size: 13px; padding: 0 30px 0 12px; border-radius: 999px; background-position: right 10px center; }
/* Inside a grey card or drawer panel, fields sit on white. */
.drawer .card .input, .drawer .card .select { background-color: var(--surface); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.search { position: relative; }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.search .input { padding-left: 40px; width: 300px; background-color: var(--surface); border-radius: 999px; box-shadow: var(--shadow-soft); }
.search .input:focus { box-shadow: 0 0 0 2px var(--ink); }

.segmented { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 4px; gap: 2px; box-shadow: var(--shadow-soft); }
.segmented button {
  border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 13px;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.segmented button:hover { color: var(--ink); background: var(--surface-2); }
.segmented button.active { background: var(--ink); color: #fff; }

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

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.12em; padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; transition: background 0.15s var(--ease); }
.table tbody tr.clickable:hover { background: #fafbfc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 700; letter-spacing: -0.005em; }
.cell-sub { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.faint { color: var(--muted); }
.nowrap { white-space: nowrap; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 700; color: var(--ink); background: var(--surface-3);
}
.avatar.lg { width: 52px; height: 52px; font-size: 17px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who > div { min-width: 0; }
.who .cell-main, .who .cell-sub { overflow-wrap: break-word; }

.meter { height: 6px; border-radius: 999px; background: #d7dae1; overflow: hidden; width: 90px; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--ink); }
.meter.amber > span { background: #f59e0b; }
.meter.red > span { background: var(--red); }

/* ------------------------------------------------------------ environments */

.env-group + .env-group { margin-top: 18px; }
.env-row {
  display: grid; align-items: center; gap: 18px; padding: 18px 22px;
  /* Fixed actions column, so rows with and without controls line up. */
  grid-template-columns: minmax(150px, 1.1fr) minmax(130px, 0.8fr) minmax(170px, 1.1fr) minmax(170px, 1fr) 300px;
  border-bottom: 1px solid var(--border);
}
.env-row:last-child { border-bottom: 0; }
.env-name { display: flex; align-items: center; gap: 12px; }
.env-name strong { display: block; font-weight: 700; }
.env-name a { color: var(--muted); font-size: 13px; }
.env-meta { color: var(--muted); font-size: 13px; }
.env-meta strong { color: var(--ink); font-weight: 700; }
.env-actions { display: flex; gap: 6px; justify-content: flex-end; }
.uptime-bar { display: flex; gap: 2px; height: 22px; align-items: stretch; }
.uptime-bar span { flex: 1; border-radius: 3px; background: var(--surface-3); min-width: 3px; }
.uptime-bar span.up { background: #34d399; }
.uptime-bar span.down { background: #ef4444; }
.uptime-bar span.mixed { background: #f59e0b; }
.containers { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* ------------------------------------------------------------- attention */

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 22px; border-bottom: 1px solid var(--border); transition: background 0.15s var(--ease); }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: #fafbfc; }
.list-item .grow { flex: 1; min-width: 0; }
.list-icon { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.list-icon svg { width: 16px; height: 16px; }

.banner {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--r-sm);
  font-size: 14px; color: var(--body);
}
.banner svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.banner .grow { flex: 1; }
.banner strong { color: var(--ink); }
.banner.info { background: var(--blue-soft); }
.banner.info svg { color: var(--blue); }
.banner.warn { background: var(--amber-soft); }
.banner.warn svg { color: var(--amber); }
.banner.danger { background: var(--red-soft); }
.banner.danger svg { color: var(--red); }
.banner + .banner, .banner + .card, .card + .banner { margin-top: 12px; }
.banner .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; color: var(--faint); margin-bottom: 10px; }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 15px; }

.skeleton {
  display: block; height: 14px; border-radius: 999px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ----------------------------------------------------------------- drawer */

.overlay {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.32); backdrop-filter: blur(3px);
  z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.25s var(--ease);
}
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 10px; right: 10px; bottom: 10px; width: min(640px, calc(100vw - 20px)); z-index: 60;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; transform: translateX(calc(100% + 20px));
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.drawer.open { transform: none; }
.drawer-head { padding: 24px 26px 0; border-bottom: 1px solid var(--border); }
.drawer-title { display: flex; align-items: flex-start; gap: 14px; }
.drawer-title h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; }
.drawer-title .sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.drawer-title .pills { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.drawer-close { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 26px 40px; }
.drawer .card { background: var(--surface-2); box-shadow: none; }
.drawer .card .table td { border-color: #e7e9ee; }
.tabs { display: flex; gap: 4px; margin-top: 18px; padding-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.tab { flex: none; }
.tab {
  border: 0; background: none; color: var(--muted); font-weight: 600; padding: 7px 14px;
  border-radius: 999px; cursor: pointer; transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.active { color: #fff; background: var(--ink); }

.dl { display: grid; grid-template-columns: 150px 1fr; gap: 12px 16px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 600; }
.section-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; margin: 26px 0 12px; }
.section-title:first-child { margin-top: 0; }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mini-stat { background: var(--surface-2); border-radius: var(--r-sm); padding: 14px 14px 16px; }
.mini-stat .v { font-size: 24px; font-weight: 700; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.mini-stat .l { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; margin-top: 2px; }

.action-row {
  display: flex; align-items: center; gap: 14px; padding: 15px 0; border-bottom: 1px solid #e7e9ee;
}
.action-row:last-child { border-bottom: 0; }
.action-row .grow { flex: 1; }
.action-row strong { display: block; font-size: 14px; font-weight: 700; }
.action-row span { color: var(--muted); font-size: 13px; }
.danger-zone { background: var(--red-soft); border-radius: var(--r-md); padding: 0 18px; }
.danger-zone .action-row { border-color: rgba(220, 38, 38, 0.12); }

/* ------------------------------------------------------------------ modal */

.modal-wrap {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: rgba(17, 24, 39, 0.36); backdrop-filter: blur(4px); animation: fade-in 0.2s var(--ease);
}
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow); animation: pop 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal.wide { width: min(1100px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 24px 26px 0; }
.modal-head h3 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.025em; }
.modal-body { padding: 14px 26px 4px; color: var(--body); }
.modal-body p { margin: 0 0 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 26px 24px; }
.modal-icon { width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; }
.modal-icon svg { width: 18px; height: 18px; }

.logs {
  background: var(--ink); border-radius: var(--r-md); margin: 0;
  font: 12px/1.65 var(--mono); color: #d7dce5; padding: 16px 18px; height: 60vh; overflow: auto;
  white-space: pre-wrap; word-break: break-all;
}
.logs .ts { color: #6b7383; }
.logs .lvl-error { color: #fca5a5; }
.logs .lvl-warn { color: #fcd34d; }
.logs mark { background: rgba(252, 211, 77, 0.35); color: inherit; border-radius: 3px; }
.logs .faint { color: #8b93a1; }
.logs-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 0 26px 14px; }

/* ----------------------------------------------------------------- toasts */

.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px;
  padding: 13px 18px; border-radius: 999px; background: var(--ink); color: #fff;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.28); font-weight: 600; font-size: 14px;
  animation: toast-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.ok svg { color: #34d399; }
.toast.err { background: #7f1d1d; }
.toast.err svg { color: #fca5a5; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  /* Tablets: the sidebar folds into the top bar's menu. */
  .sidebar { position: fixed; left: 0; z-index: 70; transform: translateX(-100%); transition: transform 0.25s var(--ease); }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .topbar { display: flex; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3-1 { grid-template-columns: 1fr; }
  .env-row { grid-template-columns: 1fr 1fr; }
  .env-actions { justify-content: flex-start; }
}
@media (max-width: 820px) {
  .content { padding: 22px 16px 60px; }
  .grid-4, .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3-1 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .activity { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .search, .search .input { width: 100%; }
  .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .segmented button { flex: none; }
  .env-row { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 10px; }
  .drawer { top: 0; right: 0; bottom: 0; width: 100vw; border-radius: 0; }
  .toast { border-radius: var(--r-sm); }
}

/* ------------------------------------------------------ overview: system */

.sys-grid { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 64px); align-items: center; }
.sys-grid > * { padding: 11px 0; border-bottom: 1px solid var(--border); }
.sys-grid > :nth-last-child(-n+4) { border-bottom: 0; }
.sys-grid .head { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; padding: 0 0 8px; text-align: center; }
.sys-grid .head:first-child { text-align: left; }
.sys-grid .app { font-weight: 700; font-size: 14px; }
.sys-grid .cell { display: grid; place-items: center; }
.sys-grid a.cell { text-decoration: none; }
.sys-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.sys-foot .line { display: flex; align-items: center; gap: 10px; }
.sys-foot strong { color: var(--ink); font-weight: 700; }

/* ---------------------------------------------------- overview: activity */

.activity { display: grid; grid-template-columns: minmax(0, 1fr) 260px; }
.activity-chart { padding: 18px 22px 16px; min-width: 0; }
.activity-side { border-left: 1px solid var(--border); padding: 6px 22px; display: flex; flex-direction: column; }
.stat { padding: 14px 0; border-bottom: 1px solid var(--border); }
.stat:last-child { border-bottom: 0; }
.stat .l { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat .v small { font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.stat .d { font-size: 13px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 22px; }

.chart { position: relative; }
.chart svg { display: block; max-width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { font-size: 11px; fill: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--ink); transition: opacity 0.15s var(--ease); }
.chart .bar.partial { fill: #9aa1ae; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hover { opacity: 0.78; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 168px;
  background: var(--ink); color: #fff; border-radius: var(--r-sm); padding: 10px 12px;
  font-size: 12.5px; line-height: 1.5; box-shadow: 0 12px 28px rgba(17, 24, 39, 0.24);
  opacity: 0; transform: translateY(4px); transition: opacity 0.12s var(--ease), transform 0.12s var(--ease);
}
.chart-tip.on { opacity: 1; transform: none; }
.chart-tip strong { display: block; font-size: 13px; margin-bottom: 4px; }
.chart-tip .row { display: flex; justify-content: space-between; gap: 16px; color: #d1d5db; font-variant-numeric: tabular-nums; }
.chart-tip .row b { color: #fff; font-weight: 700; }
.chart-caption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ------------------------------------------------- signals, deltas, sorts */

.delta { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--muted); }
.signals { display: flex; gap: 4px; flex-wrap: wrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th.sorted { color: var(--ink); }
.table th .arrow { display: inline-block; width: 10px; margin-left: 4px; }
.share { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.share .meter { width: 48px; }

/* -------------------------------------------------- reason & consequences */

.reason textarea.input { height: auto; min-height: 76px; padding: 12px 16px; resize: vertical; line-height: 1.45; }
.notice {
  display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 14px; padding: 12px 14px;
  border-radius: var(--r-sm); background: var(--surface-2); font-size: 13.5px; color: var(--body);
}
.notice svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--muted); }
.notice strong { color: var(--ink); }

/* --------------------------------------------------------------- audit log */

.audit-reason { color: var(--body); font-size: 13.5px; max-width: 46ch; }
.audit-reason.none { color: var(--muted); font-style: italic; }
.audit-action { font-weight: 700; }

/* ---------------------------------------------------- unavailable sources */

.na { color: var(--muted); font-weight: 600; }

@media (max-width: 1100px) {
  .activity { grid-template-columns: minmax(0, 1fr); }
  .activity-side { border-left: 0; border-top: 1px solid var(--border); }
}

::selection { background: rgba(17, 24, 39, 0.14); }

.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; }
#insight-table .table th, #insight-table .table td { padding-left: 12px; padding-right: 12px; }
#insight-table .meter { width: 56px; }
#insight-table .table th { white-space: normal; vertical-align: bottom; line-height: 1.35; }

/* ------------------------------------------------------- organization mark */

.org-mark {
  width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center; overflow: hidden;
  background: var(--surface-3); color: var(--ink); font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
}
.org-mark.lg { width: 72px; height: 72px; border-radius: 18px; font-size: 22px; }
.org-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.logo-row { display: flex; gap: 18px; align-items: flex-start; background: var(--surface-2); border-radius: var(--r-md); padding: 16px; }
.logo-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.logo-row strong { font-size: 14px; }
.logo-row span { color: var(--muted); font-size: 13px; }
.logo-row .err { color: var(--red); font-weight: 600; }
.logo-row .err:empty { display: none; }
.logo-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.logo-actions label.btn { cursor: pointer; }
.btn.is-disabled { opacity: 0.4; pointer-events: none; }

/* Members in the organization drawer: on a phone the person takes the
   first line; role, state and actions share the second. */
.member-table td { padding-left: 12px; padding-right: 12px; }
.member-table td:first-child { width: 100%; }
@media (max-width: 820px) {
  .member-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid #e7e9ee; }
  .member-table tr:last-child { border-bottom: 0; }
  .member-table td { padding: 0; border: 0; }
  .member-table td:first-child { flex: 1 0 100%; }
  .member-table td:last-child { margin-left: auto; }
}

/* Phones: a list table becomes one card per row; each value carries its
   column heading (data-label, set in app.js). */
@media (max-width: 820px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: block; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: block; padding: 3px 0; border: 0; text-align: right; white-space: normal; }
  table.stack td::after { content: ""; display: block; clear: both; }
  table.stack td::before {
    content: attr(data-label); float: left; margin-right: 16px; text-align: left;
    color: var(--muted); font-size: 12.5px; font-weight: 600;
  }
  table.stack td > div { display: inline-block; margin-left: 8px; }
  table.stack td:first-child { display: block; text-align: left; padding-bottom: 8px; }
  table.stack td:first-child::before { display: none; }
  table.stack td:not([data-label])::before { display: none; }
  table.stack .signals { justify-content: flex-end; }
  table.stack td:first-child > div { display: block; margin-left: 0; }
  table.stack td:first-child > .who { display: flex; }
  table.stack.recent td { display: block; text-align: left; padding: 2px 0; }
  table.stack.recent td:empty { display: none; }
}

/* Touchscreens: every control is at least 40px tall to tap. */
@media (pointer: coarse) {
  .btn.sm, .select.sm { height: 40px; }
  .btn.sm.icon { width: 40px; }
  .segmented button, .tab { padding: 11px 16px; }
  .nav-item { padding: 12px; }
}

.env-incidents { grid-column: 1 / -1; padding: 2px 0 4px; }
.env-incidents ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.env-incidents li { display: flex; gap: 8px; align-items: baseline; }
.env-incidents li strong { color: var(--text); font-weight: 600; }
