/* CAPAM Query Generator — Framed sheet style
   Grid arithmetic (1440px viewport):
   - Shell: 228px sidebar + 1fr right column (top bar 48px, sheet inset 8px right/bottom)
   - White sheet width: 1440 - 228 - 8 = 1204px; inner content (24px padding + 1px border x2) = 1154px
   - Summary strip: 4 equal columns x 288.5px = 1154px (1 container, 1px vertical dividers)
   - Workspace split: 5fr (470.8px) + 24px gap + 7fr (659.2px) = 1154px
   - One gutter (--gap: 24px) horizontally and vertically. Zero shadows on resting surfaces. */

:root {
  /* Framed sheet tokens with low-chroma slate-teal chrome (CyberArk PAM world) */
  --ground: #f3f6f8;
  --surface: #ffffff;
  --raised: #f4f6f8;
  --active: #e4eaee;
  --border: #e5eaee;
  --rule: #eef2f5;
  --control: #c7d0d6;
  --text: #131416;
  --muted: #52575c;
  --faint: #5f656b;
  --accent: #1b6c80;
  --accent-tint: #e8f3f6;
  --primary: #131416;
  --primary-ink: #ffffff;
  --positive: #1e7b4f;
  --negative: #c4242a;
  --warning: #92400e;
  --pill-positive-bg: #dcfae5;
  --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea;
  --pill-negative-ink: #831c1e;
  --pill-warning-bg: #fffbeb;
  --pill-warning-ink: #92400e;
  --pill-neutral-bg: #ebeff2;
  --pill-neutral-ink: #353a3e;

  --font: "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --fs-title: 22px;
  --fs-section: 16px;
  --fs-kpi-lead: 28px;
  --fs-kpi: 22px;
  --fs-body: 14px;
  --fs-small: 12px;

  --sidebar-width: 228px;
  --topbar-height: 48px;
  --sheet-inset: 8px;
  --pad: 24px;
  --card-pad: 20px;
  --gap: 24px;
  --radius-sheet: 16px;
  --radius-card: 8px;
  --radius-control: 6px;
  --control-height: 32px;
  --nav-row: 34px;
  --row-height: 44px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms;
  --t-hover: 150ms;
  --t-ui: 200ms;
}

/* Dark theme: true neutral darks, lightness elevation, lifted contrast >= 4.5:1 */
:root[data-theme="dark"] {
  --ground: #111111;
  --surface: #171719;
  --raised: #202023;
  --active: #27272b;
  --border: #2a2a2d;
  --rule: #222225;
  --control: #3f3f44;
  --text: #ffffff;
  --muted: #b4b4b4;
  --faint: #949494;
  --accent: #4fb3c8;
  --accent-tint: #152a30;
  --primary: #ffffff;
  --primary-ink: #111111;
  --positive: #3fc07a;
  --negative: #e5566f;
  --warning: #e5a93b;
  --pill-positive-bg: #172a1d;
  --pill-positive-ink: #3fc07a;
  --pill-negative-bg: #2c1a20;
  --pill-negative-ink: #e5566f;
  --pill-warning-bg: #2b2414;
  --pill-warning-ink: #e5a93b;
  --pill-neutral-bg: #27272b;
  --pill-neutral-ink: #e5e5e5;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, ol, pre {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

svg {
  display: block;
  flex-shrink: 0;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.num, table, .kpi-value {
  font-variant-numeric: tabular-nums;
}

.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;
}

.hidden {
  display: none !important;
}

/* ---------- Shell: Tinted L-frame + Inset White Sheet ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  min-height: 100svh;
  background: var(--ground);
}

/* Sidebar sits on tinted ground with NO border against topbar */
.sidebar {
  grid-column: 1;
  grid-row: 1 / -1;
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 16px;
  overflow-y: auto;
  background: var(--ground);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 16px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: none;
}

.brand-mark-bg {
  fill: var(--accent-tint);
  stroke: var(--accent);
}

.brand-mark-stroke {
  stroke: var(--accent);
}

.brand-text {
  min-width: 0;
}

.brand-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 18px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-scope {
  display: block;
  font-size: var(--fs-small);
  line-height: 16px;
  color: var(--muted);
}

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

.nav-group-label {
  margin: 18px 8px 6px;
  font-size: var(--fs-small);
  line-height: 16px;
  font-weight: 500;
  color: var(--faint);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: var(--nav-row);
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-card);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-body);
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease;
}

.nav-btn:hover {
  background: var(--raised);
  color: var(--text);
}

.nav-btn[aria-current="page"] {
  background: var(--active);
  color: var(--text);
  font-weight: 500;
}

.nav-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
  color: currentColor;
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  flex: none;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
}

.nav-count {
  flex: none;
  font-size: var(--fs-small);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.sidebar-apps {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
}

.app-filter-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease;
}

.app-filter-btn:hover {
  background: var(--raised);
  color: var(--text);
}

.app-filter-btn[aria-pressed="true"] {
  background: var(--active);
  color: var(--text);
  font-weight: 500;
}

.app-filter-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-filter-meta {
  flex: none;
  font-size: var(--fs-small);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.app-filter-meta.done {
  color: var(--positive);
  font-weight: 500;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 8px 0;
  border-top: 1px solid var(--border);
  font-size: var(--fs-small);
  line-height: 18px;
  color: var(--muted);
}

.sidebar-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
}

.sidebar-footer-val {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.sidebar-close {
  display: none;
}

/* Top bar: 48px on tinted ground, centered search + right offline indicator */
.topbar {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: 1fr minmax(220px, 520px) 1fr;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  padding: 0 24px 0 8px;
  background: var(--ground);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.topbar-brand-mobile {
  display: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 11px;
  width: 14px;
  height: 14px;
  color: var(--faint);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: var(--control-height);
  padding: 0 58px 0 34px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color var(--t-hover) ease;
}

.search-input::placeholder {
  color: var(--faint);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-clear {
  position: absolute;
  right: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.search-clear:hover {
  background: var(--raised);
  color: var(--text);
}

.search-kbd {
  position: absolute;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--raised);
  color: var(--faint);
  font-size: 11px;
  font-weight: 500;
  pointer-events: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.privacy-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-small);
  color: var(--muted);
  white-space: nowrap;
}

.privacy-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--positive);
  flex: none;
}

/* Inset White Sheet: 8px right & bottom inset, 16px corners, 1px hairline, flat surface */
.sheet-wrap {
  grid-column: 2;
  grid-row: 2;
  padding: 0 var(--sheet-inset) var(--sheet-inset) 0;
  min-width: 0;
}

.sheet {
  min-height: calc(100svh - var(--topbar-height) - var(--sheet-inset));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  padding: var(--pad);
  min-width: 0;
}

/* ---------- View Container & Title Row ---------- */
.view {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.title-block {
  min-width: 0;
  flex: 1 1 320px;
}

.title-block h1 {
  font-size: var(--fs-title);
  line-height: 28px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}

.title-sub {
  margin-top: 4px;
  font-size: var(--fs-body);
  line-height: 20px;
  color: var(--muted);
}

.title-sub.has-alert {
  color: var(--negative);
}

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

/* ---------- Buttons & Controls (uniform 32px height) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-height);
  padding: 0 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}

.btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.75;
}

.btn:hover:not(:disabled) {
  background: var(--raised);
  border-color: var(--muted);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  background: var(--raised);
  border-color: var(--border);
  color: var(--faint);
  cursor: not-allowed;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}

.btn.primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn.primary:disabled {
  background: var(--active);
  border-color: var(--border);
  color: var(--faint);
}

.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-small);
}

.btn.copied-flash {
  background: var(--pill-positive-bg);
  border-color: var(--positive);
  color: var(--pill-positive-ink);
}

.theme-toggle {
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-small);
}

.text-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: var(--fs-small);
  font-weight: 500;
  cursor: pointer;
  text-underline-offset: 3px;
}

.text-action:hover {
  text-decoration: underline;
}

.text-action.is-alert {
  color: var(--negative);
}

/* ---------- Summary KPI Strip (one divided container, no icons, lead figure largest) ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.kpi {
  padding: 14px var(--card-pad);
  min-width: 0;
}

.kpi + .kpi {
  border-left: 1px solid var(--border);
}

.kpi-label {
  display: block;
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
}

.kpi-value {
  display: block;
  margin-top: 4px;
  font-size: var(--fs-kpi);
  line-height: 28px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
}

.kpi-lead .kpi-value {
  font-size: var(--fs-kpi-lead);
  line-height: 32px;
  font-weight: 600;
  color: var(--accent);
}

.kpi-value.is-alert {
  color: var(--negative);
}

.kpi-meta {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-small);
  line-height: 16px;
  color: var(--faint);
}

.kpi-link {
  margin-top: 2px;
}

/* ---------- Main Workspace Split (Input 5fr | Output 7fr, shared edges) ---------- */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--gap);
  align-items: stretch;
  min-width: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--card-pad);
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.panel-header h2 {
  font-size: var(--fs-section);
  line-height: 22px;
  font-weight: 600;
  color: var(--text);
}

.panel-meta {
  font-size: var(--fs-small);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.panel-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Input Editor Pane */
.input-hint {
  margin-bottom: 10px;
  font-size: var(--fs-small);
  line-height: 18px;
  color: var(--muted);
}

.code-input {
  flex: 1 1 auto;
  width: 100%;
  min-height: 272px;
  padding: 12px 14px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-family: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 20px;
  resize: vertical;
  tab-size: 4;
  transition: border-color var(--t-hover) ease;
}

.code-input::placeholder {
  color: var(--faint);
}

.code-input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.input-status {
  font-size: var(--fs-small);
  color: var(--muted);
}

.input-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Output Pane & Mode Switcher Tabs (framed-sheet 2px underline move) */
.output-panel {
  min-width: 0;
}

.mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 20px;
}

.mode-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--t-hover) ease;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab[aria-selected="true"] {
  color: var(--text);
  font-weight: 600;
}

.mode-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
}

.mode-tab[aria-selected="true"] .tab-count {
  background: var(--accent-tint);
  color: var(--accent);
}

.mode-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 6px;
}

.global-summary-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--raised);
  font-size: var(--fs-small);
  color: var(--muted);
  flex-wrap: wrap;
}

.global-summary-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

.global-summary-stats strong {
  color: var(--text);
  font-weight: 600;
}

.global-batch-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  padding: 12px 16px;
  min-width: 0;
}

.global-batch-card.is-copied {
  border-color: var(--positive);
}

.output-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 14px;
  border-radius: var(--radius-control);
  background: var(--accent-tint);
  color: var(--text);
  font-size: 13px;
}

.output-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Empty State inside Output Pane (no dead void, useful preview + 1-click samples) */
.output-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-callout {
  padding: 18px 20px;
  border: 1px dashed var(--control);
  border-radius: var(--radius-control);
  background: var(--raised);
}

.empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.empty-desc {
  margin-top: 4px;
  font-size: 13px;
  line-height: 19px;
  color: var(--muted);
}

.empty-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.syntax-preview {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 14px 16px;
  background: var(--surface);
  gap: 10px;
}

.syntax-preview-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-small);
  color: var(--muted);
}

.syntax-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.syntax-preview-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.syntax-rules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 16px;
  margin-top: 10px;
  font-size: var(--fs-small);
  color: var(--muted);
}

/* Application Output Card */
.app-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  overflow: hidden;
  min-width: 0;
}

.app-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--raised);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.app-card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.app-card-name {
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.app-card-stats {
  font-size: var(--fs-small);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.app-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* Signature Element: 8-Slot Batch Rows */
.batch-list {
  display: flex;
  flex-direction: column;
}

.batch-row {
  padding: 12px 16px;
  min-width: 0;
}

.batch-row + .batch-row {
  border-top: 1px solid var(--rule);
}

.batch-row.is-copied {
  background: var(--raised);
}

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

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

.batch-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* 8-slot PVWA batch meter: visual signature of the max-8 Address rule */
.slot-meter {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.slot-cell {
  width: 8px;
  height: 6px;
  border-radius: 1px;
  background: var(--border);
}

.slot-cell.filled {
  background: var(--accent);
}

.batch-count {
  font-size: var(--fs-small);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.query-code {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--raised);
  color: var(--text);
  font-family: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Liberation Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 19px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  user-select: all;
}

.query-code-inline {
  font-family: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Liberation Mono", Menlo, monospace;
  font-size: 12.5px;
  color: var(--text);
}

/* Status Pills (pale tint + dark ink of same hue, never squeezed) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  flex: none;
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
}

.pill.pos {
  background: var(--pill-positive-bg);
  color: var(--pill-positive-ink);
}

.pill.neg {
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
}

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

/* Empty Groups Notice inside Generator */
.empty-groups-notice {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--warning);
  border-radius: var(--radius-control);
  background: var(--pill-warning-bg);
  color: var(--pill-warning-ink);
  font-size: 13px;
  line-height: 19px;
}

/* ---------- Audit & Validasi View ---------- */
.audit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th {
  height: 36px;
  padding: 0 12px;
  text-align: left;
  font-size: var(--fs-small);
  font-weight: 400;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
  font-size: var(--fs-body);
}

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

th.n, td.n {
  text-align: right;
  white-space: nowrap;
}

th.col-line, td.col-line {
  width: 68px;
}

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

.table-empty {
  padding: 20px 14px;
  border: 1px dashed var(--control);
  border-radius: var(--radius-control);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- Panduan Format View ---------- */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  align-items: stretch;
}

.guide-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: var(--card-pad);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

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

.guide-card-head h2 {
  font-size: var(--fs-section);
  line-height: 22px;
  font-weight: 600;
}

.guide-card p {
  font-size: 13px;
  line-height: 19px;
  color: var(--muted);
}

pre.guide-sample-code {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--raised);
  font-family: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Liberation Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 19px;
  white-space: pre-wrap;
  tab-size: 4;
  overflow-x: auto;
}

.rules-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px;
}

.rules-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  line-height: 20px;
  color: var(--text);
}

.rule-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  flex: none;
  transform: translateY(-2px);
}

/* ---------- Floating Toast Notification (only floating UI element) ---------- */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 380px;
  padding: 10px 14px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity var(--t-ui) var(--ease-out), transform var(--t-ui) var(--ease-out);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  background: var(--negative);
  border-color: var(--negative);
  color: #ffffff;
}

/* Mobile backdrop when drawer open */
.drawer-backdrop {
  display: none;
}

/* ---------- Responsive: Tablet (<= 1040px) & Phone (<= 640px) ---------- */
@media (max-width: 1040px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .code-input {
    min-height: 240px;
  }

  .audit-grid,
  .guide-grid,
  .rules-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 30;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform var(--t-ui) var(--ease-out);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--control);
    border-radius: var(--radius-control);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
  }

  .drawer-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(19, 20, 22, 0.32);
  }

  .topbar {
    grid-column: 1;
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 0 16px;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .topbar-brand-mobile {
    display: inline-block;
  }

  .privacy-indicator {
    display: none;
  }

  .sheet-wrap {
    grid-column: 1;
    padding: 0;
  }

  .sheet {
    min-height: calc(100svh - var(--topbar-height));
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0;
    padding: 16px;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi + .kpi {
    border-left: 0;
  }

  .kpi:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

  .kpi:nth-child(2n) {
    border-left: 1px solid var(--border);
  }
}

@media (max-width: 540px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
  }

  .topbar-brand-mobile {
    display: none;
  }

  .theme-toggle-label {
    display: none;
  }

  .theme-toggle {
    width: 34px;
    height: 34px;
    padding: 0;
  }

  .search-kbd {
    display: none;
  }

  .search-input {
    padding-right: 34px;
  }

  .search-clear {
    right: 6px;
  }

  .title-actions {
    width: 100%;
  }

  .title-actions .btn {
    flex: 1 1 auto;
    min-height: 40px;
  }

  .btn.sm {
    min-height: 36px;
  }

  .syntax-rules {
    grid-template-columns: minmax(0, 1fr);
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

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