/* ============================================================================
   Report Studio — HubEurope internal report builder
   Design: slate operational console. Orange = action, blue = query/data.
   Semaphore guardrail states. Monospace as a first-class citizen.
   ========================================================================== */

/* ---- Theme tokens -------------------------------------------------------- */
:root {
  color-scheme: light dark;

  --orange: #FF4400;
  --orange-ink: #ffffff;
  --blue: #1E7BB0;
  --green: #1E9E63;
  --amber: #B7791F;
  --red: #D6383D;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Menlo", "Cascadia Code", "Roboto Mono", monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --dur: 160ms;
  --ease: cubic-bezier(.2, .7, .3, 1);

  --shadow-1: 0 1px 2px rgba(10, 14, 20, .06), 0 2px 8px rgba(10, 14, 20, .05);
  --shadow-2: 0 8px 28px rgba(10, 14, 20, .16);
}

/* Light (paper) */
:root, :root[data-theme="light"] {
  --ground: #F7F8FA;
  --panel: #FFFFFF;
  --panel-2: #F1F3F6;
  --sunken: #EDEFF3;
  --line: #E1E5EB;
  --line-strong: #CBD2DB;
  --ink: #1A1E26;
  --ink-2: #545C6B;
  --ink-3: #8A93A3;
  --accent-soft: rgba(255, 68, 0, .10);
  --blue-soft: rgba(30, 123, 176, .10);
  --green-soft: rgba(30, 158, 99, .13);
  --amber-soft: rgba(183, 121, 31, .14);
  --red-soft: rgba(214, 56, 61, .12);
  --code-bg: #F4F6F9;
  --overlay: rgba(20, 26, 34, .34);
}

/* Dark (slate) */
:root[data-theme="dark"] {
  --ground: #0E1116;
  --panel: #161B22;
  --panel-2: #1B222B;
  --sunken: #10151C;
  --line: #262E39;
  --line-strong: #333D4A;
  --ink: #E7ECF2;
  --ink-2: #A5B0BE;
  --ink-3: #6E7A89;
  --accent-soft: rgba(255, 68, 0, .16);
  --blue-soft: rgba(30, 123, 176, .20);
  --green-soft: rgba(30, 158, 99, .20);
  --amber-soft: rgba(183, 121, 31, .22);
  --red-soft: rgba(214, 56, 61, .20);
  --code-bg: #0C1015;
  --overlay: rgba(4, 7, 11, .58);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 10px rgba(0, 0, 0, .3);
  --shadow-2: 0 10px 34px rgba(0, 0, 0, .55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0E1116;
    --panel: #161B22;
    --panel-2: #1B222B;
    --sunken: #10151C;
    --line: #262E39;
    --line-strong: #333D4A;
    --ink: #E7ECF2;
    --ink-2: #A5B0BE;
    --ink-3: #6E7A89;
    --accent-soft: rgba(255, 68, 0, .16);
    --blue-soft: rgba(30, 123, 176, .20);
    --green-soft: rgba(30, 158, 99, .20);
    --amber-soft: rgba(183, 121, 31, .22);
    --red-soft: rgba(214, 56, 61, .20);
    --code-bg: #0C1015;
    --overlay: rgba(4, 7, 11, .58);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 10px rgba(0, 0, 0, .3);
    --shadow-2: 0 10px 34px rgba(0, 0, 0, .55);
  }
}

/* ---- Reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ============================================================================
   Login
   ========================================================================== */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: var(--sp-5);
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--accent-soft), transparent 60%),
    var(--ground);
}
.login-shell { width: 100%; max-width: 380px; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: var(--sp-6);
}
.login-brand { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--sp-3); }
.login-lede { color: var(--ink-2); margin-bottom: var(--sp-5); }
.login-error {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid color-mix(in srgb, var(--red) 40%, transparent);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-weight: 600;
}
.login-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.login-foot { text-align: center; color: var(--ink-3); font-size: 12px; margin-top: var(--sp-5); }

/* ---- Wordmark ------------------------------------------------------------ */
.wordmark { font-weight: 800; font-size: 19px; letter-spacing: -.02em; line-height: 1; }
.wordmark-hub { color: var(--ink); }
.wordmark-europe { color: var(--orange); }
.wordmark-studio {
  font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3);
}

/* ============================================================================
   App shell
   ========================================================================== */
.app { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }

.sidebar {
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: var(--sp-5) var(--sp-4);
}
.sidebar-brand { display: flex; flex-direction: column; gap: 3px; padding: 0 var(--sp-2) var(--sp-6); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3);
  background: transparent;
  border: 0;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-weight: 600;
  text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item:hover { background: var(--panel-2); color: var(--ink); }
.nav-item[aria-current="true"] { background: var(--accent-soft); color: var(--ink); }
.nav-item[aria-current="true"] .nav-glyph { color: var(--orange); }
.nav-glyph {
  width: 20px; text-align: center;
  font-family: var(--mono); font-size: 13px; color: var(--ink-3);
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-2); padding-top: var(--sp-4); }
.theme-toggle {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink-2); font-weight: 600;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.theme-toggle:hover { border-color: var(--line-strong); color: var(--ink); }
.theme-icon { font-size: 15px; }
.signout { color: var(--ink-3); font-size: 12px; padding: var(--sp-1) var(--sp-3); }

/* ---- Main scroll region -------------------------------------------------- */
.main { overflow: auto; height: 100vh; }

/* ---- Generic view scaffolding ------------------------------------------- */
.view { padding: var(--sp-6) var(--sp-7); max-width: 1240px; margin: 0 auto; }
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.view-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.view-sub { color: var(--ink-2); margin-top: 4px; }
.eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 6px;
}

/* ============================================================================
   Buttons / inputs / chips
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 9px var(--sp-4);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--ink); font-weight: 600;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: var(--orange-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--orange) 88%, #000); }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { background: color-mix(in srgb, var(--blue) 86%, #000); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--panel-2); color: var(--ink); }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); background: transparent; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 11.5px; color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%;
  padding: 9px var(--sp-3);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--ink);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input.is-invalid { border-color: var(--red); }
.input.is-valid { border-color: var(--green); }
.select { appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 30px;
}
.textarea { resize: vertical; min-height: 84px; }
.mono { font-family: var(--mono); font-size: 13px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill-draft   { color: var(--amber); background: var(--amber-soft); }
.pill-active  { color: var(--green); background: var(--green-soft); }
.pill-archived{ color: var(--ink-3); background: var(--panel-2); }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--r-sm);
  font-size: 11px; font-weight: 600;
  background: var(--panel-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.badge-blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }

/* ============================================================================
   Reports list
   ========================================================================== */
.card-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.report-card {
  display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.report-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.report-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.report-card-name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.report-card-slug { font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.report-card-meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.report-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  margin-top: auto; padding-top: var(--sp-3); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3);
}
.report-card-actions { display: flex; gap: 2px; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============================================================================
   Editor
   ========================================================================== */
.editor { display: flex; flex-direction: column; height: 100vh; }
.editor-bar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.editor-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-2); font-weight: 600; background: transparent; border: 0;
  padding: 6px 8px; border-radius: var(--r-sm);
}
.editor-back:hover { background: var(--panel-2); color: var(--ink); }
.editor-title-wrap { min-width: 0; }
.editor-title-in {
  font-size: 17px; font-weight: 700; letter-spacing: -.01em;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 3px 6px; width: 320px; max-width: 40vw; color: var(--ink);
}
.editor-title-in:hover { border-color: var(--line); }
.editor-title-in:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor-slug { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); padding-left: 6px; }
.editor-bar-spacer { flex: 1; }
.editor-bar-actions { display: flex; align-items: center; gap: var(--sp-2); }

.editor-panes { display: grid; grid-template-columns: 1fr 1fr; flex: 1; min-height: 0; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pane + .pane { border-left: 1px solid var(--line); }
.pane-head {
  display: flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}
.pane-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); margin-right: var(--sp-3);
}
.pane-body { flex: 1; overflow: auto; min-height: 0; }

.tab {
  padding: 6px 12px; border-radius: var(--r-sm);
  background: transparent; border: 0; color: var(--ink-2); font-weight: 600; font-size: 13px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab:hover { background: var(--panel-2); color: var(--ink); }
.tab[aria-selected="true"] { background: var(--panel-2); color: var(--ink); }
.tab-blue[aria-selected="true"] { color: var(--blue); box-shadow: inset 0 -2px 0 var(--blue); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.tabpanel { display: none; height: 100%; }
.tabpanel.is-active { display: flex; flex-direction: column; }

/* ---- SQL tab ------------------------------------------------------------- */
.sql-wrap { display: flex; flex-direction: column; height: 100%; }
.sql-toolbar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sql-toolbar .grow { flex: 1; }
.sql-editor {
  flex: 1; min-height: 140px;
  width: 100%; resize: none;
  padding: var(--sp-4);
  background: var(--code-bg);
  border: 0; color: var(--ink);
  font-family: var(--mono); font-size: 13px; line-height: 1.7;
  tab-size: 2;
}
.sql-editor:focus { outline: none; }

.result-panel { border-top: 1px solid var(--line); display: flex; flex-direction: column; max-height: 46%; }
.status-bar {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px;
}
.stat { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.stat strong { color: var(--ink); font-weight: 700; }
.status-bar-spacer { flex: 1; }
.guard {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  border: 1px solid transparent;
}
.guard::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.guard-ok    { color: var(--green); background: var(--green-soft); }
.guard-warn  { color: var(--amber); background: var(--amber-soft); }
.guard-bad   { color: var(--red);   background: var(--red-soft); }

.result-scroll { overflow: auto; flex: 1; }
.data-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.data-table th, .data-table td {
  text-align: left; padding: 7px 12px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.data-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-2); color: var(--ink-2);
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
}
.data-table td { font-variant-numeric: tabular-nums; color: var(--ink); }
.data-table tr:hover td { background: var(--panel-2); }
.data-null { color: var(--ink-3); font-style: italic; }

.run-error {
  margin: var(--sp-4);
  padding: var(--sp-4);
  background: var(--red-soft);
  border: 1px solid color-mix(in srgb, var(--red) 34%, transparent);
  border-radius: var(--r-md);
  color: var(--ink);
}
.run-error strong { color: var(--red); }
.run-error ul { margin: var(--sp-2) 0 0; padding-left: var(--sp-5); }

/* ---- Visual builder ------------------------------------------------------ */
.builder { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }
.builder-group { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
.builder-group > summary,
.builder-group-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
  cursor: default;
}
.builder-group-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.builder-rows { padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.br-row { display: grid; gap: var(--sp-2); align-items: center; }
.br-select-row { grid-template-columns: 1fr 120px 1fr auto; }
.br-where-row { grid-template-columns: 1fr 90px 140px 1fr auto; }
.br-order-row { grid-template-columns: 1fr 110px auto; }
.br-join-row { grid-template-columns: 1fr 90px 1.4fr auto; }
.icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center;
  background: transparent; border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: var(--panel-2); color: var(--ink); border-color: var(--line-strong); }
.icon-btn.danger:hover { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); background: var(--red-soft); }
.builder-empty { color: var(--ink-3); font-size: 12.5px; font-style: italic; }
.compile-bar { display: flex; align-items: center; gap: var(--sp-3); }
.compile-bar .grow { flex: 1; }
.limit-input { width: 96px; }
.chip-multi { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle {
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2);
}
.chip-toggle[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue); border-color: transparent; }

/* ============================================================================
   Template pane
   ========================================================================== */
.tpl-blocks { display: grid; grid-template-columns: 168px 1fr; height: 100%; min-height: 0; }
.palette {
  border-right: 1px solid var(--line); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-2);
  overflow: auto;
}
.palette-title { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 2px; }
.palette-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--panel); border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  font-weight: 600; font-size: 13px; color: var(--ink);
  cursor: grab;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.palette-item:hover { border-color: var(--orange); background: var(--accent-soft); }
.palette-item:active { cursor: grabbing; }
.palette-glyph { font-family: var(--mono); color: var(--ink-3); width: 18px; text-align: center; }
.palette-hint { font-size: 11px; color: var(--ink-3); margin-top: var(--sp-2); line-height: 1.5; }

.canvas {
  padding: var(--sp-4); overflow: auto;
  display: flex; flex-direction: column; gap: var(--sp-3);
  background:
    repeating-linear-gradient(var(--ground) 0 23px, transparent 23px 24px);
}
.canvas.is-dropzone { box-shadow: inset 0 0 0 2px var(--orange); border-radius: var(--r-md); }
.canvas-empty {
  border: 2px dashed var(--line-strong); border-radius: var(--r-md);
  padding: var(--sp-7) var(--sp-4); text-align: center; color: var(--ink-3);
}
.block {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-3);
  cursor: grab; box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.block:hover { border-color: var(--line-strong); }
.block.is-selected { border-color: var(--orange); box-shadow: 0 0 0 3px var(--accent-soft); }
.block.is-dragging { opacity: .4; }
.block.drop-before { box-shadow: inset 0 3px 0 var(--orange); }
.block.drop-after { box-shadow: inset 0 -3px 0 var(--orange); }
.block-grip { font-family: var(--mono); color: var(--ink-3); cursor: grab; user-select: none; }
.block-type { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--blue); }
.block-desc { color: var(--ink-2); font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.block-del { margin-left: auto; }

.inspector {
  border-top: 1px solid var(--line);
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--panel);
  max-height: 42%; overflow: auto; flex-shrink: 0;
}
.inspector-title { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.metric-row, .col-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: var(--sp-2); align-items: center; }
.metric-row { grid-template-columns: 1fr 1fr 110px auto; }
.inspector-empty { color: var(--ink-3); font-style: italic; padding: var(--sp-6) 0; text-align: center; }

/* ---- Jinja + Preview ----------------------------------------------------- */
.jinja-wrap { display: flex; flex-direction: column; height: 100%; }
.jinja-toolbar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); }
.jinja-code {
  flex: 1; width: 100%; resize: none; padding: var(--sp-4);
  background: var(--code-bg); border: 0; color: var(--ink);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65; tab-size: 2;
}
.jinja-code[readonly] { color: var(--ink-2); }
.jinja-code:focus { outline: none; }
.switch { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.switch input { accent-color: var(--orange); }

.preview-wrap { display: flex; flex-direction: column; height: 100%; }
.preview-toolbar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); }
.preview-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.preview-error { margin: var(--sp-4); }

/* ============================================================================
   Subscriptions
   ========================================================================== */
.subs-toolbar { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; margin-bottom: var(--sp-5); }
.subs-table-wrap { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--panel); box-shadow: var(--shadow-1); }
.subs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.subs-table th {
  text-align: left; padding: var(--sp-3) var(--sp-4);
  background: var(--panel-2); color: var(--ink-2);
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.subs-table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.subs-table tr:last-child td { border-bottom: 0; }
.subs-table tr:hover td { background: var(--panel-2); }
.sub-company { font-weight: 600; }
.sub-email { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.dow-cell { display: flex; gap: 3px; }
.dow-dot { width: 20px; height: 20px; display: grid; place-items: center; border-radius: var(--r-sm); font-size: 10px; font-weight: 700; background: var(--panel-2); color: var(--ink-3); }
.dow-dot.on { background: var(--blue-soft); color: var(--blue); }

.toggle {
  --w: 40px; --h: 22px;
  position: relative; width: var(--w); height: var(--h); flex-shrink: 0;
  background: var(--line-strong); border-radius: 999px; border: 0; padding: 0;
  transition: background var(--dur) var(--ease);
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform var(--dur) var(--ease);
}
.toggle[aria-pressed="true"] { background: var(--green); }
.toggle[aria-pressed="true"]::after { transform: translateX(18px); }

.dow-group { display: flex; gap: 4px; flex-wrap: wrap; }
.dow-btn {
  min-width: 42px; padding: 6px 8px; border-radius: var(--r-sm);
  background: var(--panel); border: 1px solid var(--line-strong); color: var(--ink-2);
  font-weight: 600; font-size: 12px;
}
.dow-btn[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.dow-btn.every[aria-pressed="true"] { background: var(--orange); border-color: var(--orange); }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 2px; }
.seg button {
  padding: 5px 12px; border-radius: var(--r-sm); background: transparent; border: 0;
  color: var(--ink-2); font-weight: 600; font-size: 12.5px;
}
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-1); }

/* ============================================================================
   Modal
   ========================================================================== */
.modal-host { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: var(--sp-5); background: var(--overlay); }
.modal-host[hidden] { display: none; }
.modal {
  width: 100%; max-width: 520px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  max-height: 88vh; display: flex; flex-direction: column;
  animation: pop var(--dur) var(--ease);
}
.modal.modal-wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-3); }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body { padding: var(--sp-3) var(--sp-5); overflow: auto; display: flex; flex-direction: column; gap: var(--sp-4); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.modal-x { width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r-sm); background: transparent; border: 0; color: var(--ink-3); font-size: 18px; }
.modal-x:hover { background: var(--panel-2); color: var(--ink); }

.versions-list { display: flex; flex-direction: column; gap: 0; }
.version-row { display: flex; align-items: baseline; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.version-num { font-family: var(--mono); font-weight: 700; color: var(--blue); }
.version-note { flex: 1; color: var(--ink); }
.version-meta { font-size: 12px; color: var(--ink-3); }

/* ============================================================================
   Toasts
   ========================================================================== */
.toast-host { position: fixed; bottom: var(--sp-5); right: var(--sp-5); z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2); }
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  min-width: 240px; max-width: 400px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--ink-3);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  animation: slide-in var(--dur) var(--ease);
}
.toast.leaving { animation: slide-out var(--dur) var(--ease) forwards; }
.toast-ok { border-left-color: var(--green); }
.toast-err { border-left-color: var(--red); }
.toast-info { border-left-color: var(--blue); }
.toast-msg { font-weight: 600; font-size: 13px; }

/* ============================================================================
   Utility / states
   ========================================================================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.muted { color: var(--ink-3); }
.hidden { display: none !important; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--orange);
  animation: spin .6s linear infinite; display: inline-block;
}
.loading-block { display: flex; align-items: center; gap: var(--sp-3); color: var(--ink-2); padding: var(--sp-6); justify-content: center; }
.empty-state { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--ink-3); }
.empty-state h3 { color: var(--ink); font-size: 17px; margin-bottom: var(--sp-2); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } }
@keyframes slide-out { to { transform: translateX(20px); opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

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

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1000px) {
  .editor-panes { grid-template-columns: 1fr; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 64px 1fr; }
  .nav-label, .theme-label, .wordmark-studio, .signout { display: none; }
  .sidebar-brand { align-items: center; }
  .view { padding: var(--sp-5) var(--sp-4); }
  .grid-2 { grid-template-columns: 1fr; }
}
