@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --cyan:       #1CC8EE;
  --cyan-dark:  #0f9fc4;
  --violet:     #8E7CFB;
  --violet-dark:#7668e0;
  --navy:       #0B1D34;
  --navy-2:     #102844;
  --graphite:   #212833;
  --muted:      #5A6B82;
  /* Dual-tone surface model: mist canvas, white panels.
     --bg   = app canvas / page background + subtle insets-on-white
     --surface = cards, panels, modals (white) */
  --bg:         #EEF2F7;
  --surface:    #ffffff;
  --border:     #E2E8F0;
  --border-2:   #D3DCE7;
  --text:       #0B1D34;
  --success:    #1EE6A1;
  --warning:    #FFB44E;
  --error:      #E74260;
  --radius:     8px;
  --shadow:     0 1px 2px rgba(11,29,52,0.05), 0 8px 24px rgba(11,29,52,0.06);
  --shadow-sm:  0 1px 2px rgba(11,29,52,0.06);
  --font:       'Inter', 'Segoe UI', 'Helvetica Neue', sans-serif;
  --gradient:   linear-gradient(40deg, #1CC8EE, #8E7CFB);
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #0d2240, #0B1D34);
  border-right: 1px solid rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 100;
}

/* ── Page wrapper ── */
.page-wrapper {
  margin-left: 220px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 6px;
  overflow: hidden;
}
.sidebar-brand .brand-logo {
  width: 100%;
  max-width: 160px;
  height: auto;
  display: block;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}
.sidebar-nav-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.30);
  padding: 16px 12px 6px;
}
.sidebar-nav-label .cognis-brand { color: #ffffff; font-weight: 700; text-transform: none; font-size: 12px; letter-spacing: 0; }
.sidebar-nav-label .cognis-accent { color: #1ee6a1; font-weight: 400; text-transform: none; font-size: 12px; letter-spacing: 0; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin: 1px 0;
  color: rgba(255,255,255,0.64);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.06);
}
.nav-link.active {
  color: #ffffff;
  background: rgba(28,200,238,0.14);
  font-weight: 600;
}
.nav-link.active .nav-icon { color: var(--cyan); }
.nav-icon {
  font-size: 13px;
  width: 17px;
  text-align: center;
  flex-shrink: 0;
  color: rgba(255,255,255,0.55);
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-footer form { margin: 0; }
.sidebar-footer .btn-link {
  color: rgba(255,255,255,0.40);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
}
.sidebar-footer .btn-link:hover { color: var(--cyan); }
.sidebar-username {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Top bar (dual-tone chrome) ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 40px;
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.topbar-crumb {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-tagline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--cyan);
  white-space: nowrap;
}

/* hamburger lives in the topbar; desktop hides it */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: rgba(255,255,255,0.78);
  border-radius: 2px;
  transition: background 0.15s;
}
.hamburger:hover span { background: #fff; }

/* ── Main ── */
main {
  flex: 1;
  padding: 36px 40px;
  max-width: 1120px;
  width: 100%;
}

/* ── Login ── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 130% 70% at -10% 115%, rgba(30,230,161,0.22) 0%, transparent 50%),
    radial-gradient(ellipse 90% 70% at 112% -10%, rgba(99,102,241,0.18) 0%, transparent 48%),
    radial-gradient(ellipse 60% 50% at 50% 50%, rgba(11,40,80,0.6) 0%, transparent 70%),
    linear-gradient(150deg, #0e2240 0%, #050f1c 45%, #091830 100%);
}
.login-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  width: 180px;
  height: auto;
  margin-bottom: 24px;
}
.login-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.login-card h1 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.login-card label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.login-card input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  margin-bottom: 20px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.login-card input:focus { border-color: var(--cyan); background: #fff; }
.login-card button {
  width: 100%;
  padding: 12px;
  background: var(--gradient);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: filter 0.15s, box-shadow 0.15s;
}
.login-card button:hover { filter: brightness(1.06); box-shadow: 0 6px 20px rgba(28,200,238,0.3); }
/* SSO button */
.btn-sso {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 4px;
}
.btn-sso:hover { background: rgba(28,200,238,0.08); border-color: var(--cyan); color: var(--navy); opacity: 1; }
.sso-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sso-divider::before,
.sso-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Honeypot — moved off-screen, not display:none (bots detect that) */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.login-footer a { color: var(--text); font-weight: 600; text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }
.login-notice {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  color: #15803d;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  margin-bottom: 16px;
  text-align: center;
}

/* ── Dashboard / section header ── */
.dashboard { }
.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--navy);
  padding-bottom: 16px;
}
.section-header h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

/* ── Table ── */
.branch-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.branch-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--navy);
  color: rgba(255,255,255,0.88);
}
.branch-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.branch-table tr:last-child td { border-bottom: none; }
.branch-table tr:hover td { background: var(--bg); }
.branch-table td.actions { text-align: right; white-space: nowrap; }
.branch-table td.actions .row-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.branch-name { font-family: 'Courier New', monospace; font-size: 13px; font-weight: 600; }
.branch-name a:visited { color: inherit; }
.last-sync { color: var(--muted); font-size: 13px; }
.cost-cell { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.default-cell { text-align: center; }
.default-star { color: var(--warning); font-size: 18px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-idle    { background: #E6ECF4; color: var(--muted); }
.badge-running { background: rgba(255,180,78,0.18); color: #9a6700; }
.badge-done    { background: rgba(30,230,161,0.16); color: #0e7a58; }
.badge-error   { background: rgba(231,66,96,0.13); color: #b8234a; }

/* ── Buttons ── */
.btn-primary {
  padding: 8px 16px;
  background: var(--cyan);
  color: #06202a;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); box-shadow: 0 4px 14px rgba(28,200,238,0.28); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  padding: 8px 16px;
  background: var(--surface);
  color: var(--violet-dark);
  border: 1.5px solid rgba(142,124,251,0.55);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-secondary:hover:not(:disabled) { background: rgba(142,124,251,0.10); }
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-danger {
  padding: 8px 16px;
  background: var(--surface);
  color: #c02947;
  border: 1.5px solid rgba(231,66,96,0.45);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  margin-left: 6px;
  transition: background 0.15s, color 0.15s;
}
.btn-danger:hover:not(:disabled) { background: var(--error); color: #fff; border-color: var(--error); }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-link {
  background: none;
  border: none;
  color: var(--cyan-dark);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover { color: var(--violet-dark); }

/* ── Query page ── */
.query-page h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--navy);
  padding-bottom: 16px;
}

.query-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.query-controls select,
.query-controls input[type="text"] {
  padding: 9px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.query-controls select:focus,
.query-controls input[type="text"]:focus { border-color: var(--cyan); }
.query-controls input[type="text"] { flex: 1; min-width: 260px; }
.query-controls select { min-width: 140px; }

/* ── Result cards ── */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--cyan);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-left-color 0.15s, box-shadow 0.15s;
}
.result-card:hover { border-left-color: var(--violet); box-shadow: var(--shadow); }
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  gap: 12px;
}
.result-title { font-weight: 700; font-size: 14px; }
.result-score { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.04em; }
.result-url {
  display: block;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 10px;
  word-break: break-all;
  font-weight: 500;
}
.result-url:hover { color: var(--navy); text-decoration: underline; }
.result-body { font-size: 13px; color: var(--muted); line-height: 1.65; white-space: pre-wrap; }

/* ── Progress bar ── */
.progress-wrap {
  height: 5px;
  background: var(--border);
  border-radius: 999px;
  margin-top: 6px;
  overflow: hidden;
  width: 160px;
}
.progress-bar {
  height: 100%;
  background: var(--gradient);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.progress-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Page headings ── */
.page-header {
  margin-bottom: 32px;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.page-header p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ── Misc ── */
.muted { color: var(--muted); }
.error { color: var(--error); margin-bottom: 12px; font-size: 13px; font-weight: 600; }

/* ── Analytics / stats cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient);
}
.stat-card .stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--cyan);
  line-height: 1;
}
.stat-card .stat-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  margin-top: 4px;
}

/* ── Accent strip ── */
.accent-strip {
  height: 4px;
  background: var(--gradient);
  border-radius: 2px;
  margin-bottom: 24px;
  width: 48px;
}

/* ── Browse pages (master-detail) ── */
.browse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--navy);
}
.back-link {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.back-link:hover { color: var(--navy); }
.browse-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.browse-title span { color: var(--muted); font-weight: 600; }
.browse-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.browse-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  height: calc(100vh - 200px);
  min-height: 500px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.browse-list-panel {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.browse-search-wrap {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.browse-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  background: var(--surface);
  transition: border-color 0.15s;
}
.browse-search:focus { border-color: var(--cyan); }

.browse-filters {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.browse-filter-row {
  display: flex;
  gap: 6px;
}
.browse-filter-input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 11px;
  outline: none;
  background: var(--surface);
  min-width: 0;
}
.browse-filter-input:focus { border-color: var(--cyan); }
.browse-filter-select {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 11px;
  outline: none;
  background: var(--surface);
  min-width: 0;
  cursor: pointer;
}
.browse-filter-select:focus { border-color: var(--cyan); }
.browse-filter-checkboxes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.browse-filter-checkboxes label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.btn-bulk-delete {
  display: none;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--error);
  border-radius: var(--radius);
  color: var(--error);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.btn-bulk-delete:hover { background: var(--error); color: #fff; }
.btn-bulk-delete.visible { display: inline-flex; align-items: center; gap: 5px; }

.browse-list {
  flex: 1;
  overflow-y: auto;
}
.browse-list-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.browse-list-item:hover { background: #E3E9F1; }
.browse-list-item.active {
  background: var(--navy);
}
.browse-list-item.active .bli-name { color: var(--cyan); }
.browse-list-item.active .bli-meta { color: rgba(255,255,255,0.38); }

.bli-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bli-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.browse-empty { padding: 20px 14px; color: var(--muted); font-size: 13px; }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--border-2); }

/* Detail panel */
.browse-detail-panel {
  overflow-y: auto;
  background: var(--surface);
}
.browse-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 2px solid var(--navy);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}
.detail-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  word-break: break-word;
}
.detail-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  font-weight: 500;
}

.detail-body {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.detail-row {
  display: flex;
  gap: 12px;
  font-size: 12px;
  align-items: baseline;
}
.dr-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  color: var(--muted);
  width: 90px;
  flex-shrink: 0;
}
.dr-val {
  color: var(--text);
  word-break: break-word;
}

.detail-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.5);
  background: var(--navy);
  padding: 6px 24px;
}

.detail-fields-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 24px;
}
.field-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
}
.fc-name { font-weight: 600; color: var(--text); }
.fc-type { color: var(--muted); font-size: 10px; }

.detail-methods { padding: 12px 24px; display: flex; flex-direction: column; gap: 10px; }
.method-row { font-size: 12px; }
.method-name { font-weight: 700; color: var(--text); font-family: 'Courier New', monospace; }
.method-params { color: var(--muted); font-family: 'Courier New', monospace; }
.method-summary { color: var(--graphite); margin-top: 2px; font-size: 11px; }

.detail-script {
  margin: 0;
  padding: 16px 24px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  line-height: 1.6;
  color: var(--graphite);
  background: var(--bg);
  white-space: pre-wrap;
  word-break: break-word;
  border-bottom: 1px solid var(--border);
  max-height: 400px;
  overflow-y: auto;
}

/* Browse links in instances table */
.browse-links { display: flex; gap: 6px; flex-wrap: wrap; }
.browse-count-link {
  color: var(--navy);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 2px solid var(--cyan);
}
.browse-count-link:hover { border-bottom-color: var(--violet); }

/* ── Shared panel shadow (template-defined panels) ── */
.card,
.detail-card,
.danger-card,
.nav-panel,
.doc-panel,
.runner-card { box-shadow: var(--shadow); }

/* ── Sidebar overlay backdrop ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11,29,52,0.5);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* legacy mobile topbar (superseded by .topbar) */
.mobile-topbar { display: none; }

/* ── Mobile styles ── */
@media (max-width: 767px) {
  .topbar {
    padding: 0 16px;
    height: 54px;
  }
  .topbar-tagline { display: none; }
  .hamburger { display: flex; }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    box-shadow: 0 0 40px rgba(0,0,0,0.4);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .page-wrapper {
    margin-left: 0;
  }

  main {
    padding: 24px 16px;
  }

  /* Tables scroll horizontally */
  .branch-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Stat grid two columns */
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Section headers stack */
  .section-header {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Query controls stack */
  .query-controls {
    flex-direction: column;
  }
  .query-controls input[type="text"],
  .query-controls select {
    width: 100%;
    min-width: 0;
  }

  /* Browse layout stacks vertically */
  .browse-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .browse-list-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
  }

  /* Login card full-width with less padding */
  .login-card {
    padding: 32px 20px;
    border-radius: 0;
    max-width: 100%;
    min-height: 100vh;
  }
  body.login-page {
    align-items: flex-start;
  }
}
