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

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

[v-cloak] { display: none; }

:root {
  /* UP3 brand palette (.claude/DESIGN.md) */
  --up3-green:      #B7FF00;
  --up3-black:      #000000;
  --up3-dark-grey:  #4B4B4B;
  --up3-light-grey: #C5C5C5;
  --up3-grey-50:    #F7F7F7;
  --up3-grey-100:   #EDEDED;
  --up3-grey-200:   #DCDCDC;

  /* Legacy variable names kept as aliases onto the brand palette so
     templates outside the centralization pass (which still reference
     var(--cyan)/var(--navy)/var(--violet) directly) re-theme for free. */
  --cyan:       var(--up3-green);
  --cyan-dark:  var(--up3-green);
  --violet:     var(--up3-dark-grey);
  --violet-dark:var(--up3-dark-grey);
  --navy:       var(--up3-black);
  --navy-2:     #1a1a1a;
  --graphite:   var(--up3-dark-grey);
  --muted:      var(--up3-dark-grey);
  /* Dual-tone surface model: mist canvas, white panels.
     --bg   = app canvas / page background + subtle insets-on-white
     --surface = cards, panels, modals (white) */
  --bg:         var(--up3-grey-50);
  --surface:    #ffffff;
  --border:     var(--up3-grey-200);
  --border-2:   var(--up3-light-grey);
  --text:       var(--up3-black);
  --success:    #2E7D32;
  --warning:    #B8860B;
  --error:      #C62828;
  --info:       var(--up3-dark-grey);
  /* Referenced by several templates but previously undefined anywhere
     (a pre-existing bug — those elements rendered with no color at all). */
  --accent:     var(--up3-green);
  --accent-rgb: 183, 255, 0;
  --hover:      var(--up3-grey-100);
  --chrome-gradient:
    linear-gradient(180deg, rgba(183,255,0,0.05), transparent 40%),
    linear-gradient(180deg, #1c2216 0%, #0a0c08 100%);
  --sidebar-body-bg: #F2F2F0;
  /* Referenced by .stat-card::before / .ds-card::before but previously
     undefined anywhere (a pre-existing bug — those top accent bars
     rendered with no color at all). */
  --gradient:   linear-gradient(90deg, var(--up3-green), transparent);
  --radius:     var(--radius-md);
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  16px;
  --radius-pill: 999px;
  --shadow:     0 1px 2px rgba(0,0,0,0.05), 0 8px 24px rgba(0,0,0,0.06);
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.06);
  --font:       'Montserrat', 'Segoe UI', 'Helvetica Neue', sans-serif;
}

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: var(--sidebar-body-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 100;
}

/* ── Page wrapper ──
   height:100vh + overflow:hidden makes this the outer shell; the topbar
   sits outside the scrolling region (main scrolls on its own), so it's
   structurally un-scrollable rather than merely sticky — sticky elements
   stop sticking once you scroll past the end of their containing block,
   which a tall <main> would otherwise trigger. */
.page-wrapper {
  margin-left: 220px;
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  background: var(--chrome-gradient);
  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;
  border-right: 1px solid var(--up3-grey-200);
}
.sidebar-nav-label {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--up3-dark-grey);
  padding: 16px 12px 6px;
}
.sidebar-nav-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--up3-green);
  flex-shrink: 0;
  margin-right: 7px;
}
.sidebar-nav-label .cognis-brand { color: var(--up3-black); font-weight: 400; text-transform: none; letter-spacing: 0; }
.sidebar-nav-label .cognis-accent { color: var(--up3-dark-grey); font-weight: 700; text-transform: none; letter-spacing: 0; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin: 1px 0;
  color: rgba(0,0,0,0.72);
  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: var(--up3-black);
  background: rgba(0,0,0,0.045);
}
.nav-link.active {
  color: var(--up3-black);
  background: var(--up3-green);
  font-weight: 700;
}
.nav-link.active .nav-icon { color: var(--up3-black); }
.nav-icon {
  font-size: 17px;
  width: 17px;
  text-align: center;
  flex-shrink: 0;
  color: rgba(0,0,0,0.55);
}
.ph-spin {
  animation: ph-spin 1s linear infinite;
}
@keyframes ph-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.nav-badge {
  margin-left: auto;
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 7px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

/* ── Top bar (light chrome, matches the sidebar body) ── */
.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(--sidebar-body-bg);
  border-bottom: 1px solid var(--up3-grey-200);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.topbar-crumb {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--up3-black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-crumb i {
  margin-right: 10px;
  color: var(--up3-dark-grey);
}
.topbar-tagline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--up3-dark-grey);
  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(0,0,0,0.55);
  border-radius: 2px;
  transition: background 0.15s;
}
.hamburger:hover span { background: var(--up3-black); }

/* ── Top bar: user menu ── */
.topbar-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.user-menu { position: relative; }
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--up3-black);
  transition: background 0.15s;
}
.user-menu-trigger:hover { background: rgba(0,0,0,0.05); }
.user-menu-trigger i.fa-circle-user { font-size: 18px; color: var(--up3-dark-grey); }
.user-menu-caret { font-size: 10px; color: var(--up3-dark-grey); transition: transform 0.15s; }
.user-menu.open .user-menu-caret { transform: rotate(180deg); }
.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 60;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-dropdown form { margin: 0; }
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--hover); }
.user-menu-item i { width: 14px; text-align: center; color: var(--up3-dark-grey); }

.project-switcher { position: relative; }
.project-switcher-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--up3-black);
  transition: background 0.15s;
}
.project-switcher-trigger:hover { background: rgba(0,0,0,0.05); }
.project-switcher-trigger i.fa-diagram-project { color: var(--up3-dark-grey); }
.project-switcher.open .user-menu-caret { transform: rotate(180deg); }
.project-switcher-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-switcher-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 60;
}
.project-switcher.open .project-switcher-dropdown { display: block; }
.project-switcher-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.project-switcher-item:hover { background: var(--hover); }
.project-switcher-item.active { color: var(--up3-black); font-weight: 700; }
.project-switcher-item.active::after { content: " ✓"; }
.project-switcher-row { position: relative; }
.project-switcher-row .project-switcher-item { padding-left: 10px; }
.project-switcher-noaccess {
  padding: 8px 10px;
  font-size: 12px;
  font-style: italic;
  color: var(--up3-dark-grey);
}
.project-switcher-manage { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; color: var(--up3-dark-grey); }
.project-switcher-loading { padding: 8px 10px; font-size: 13px; color: var(--up3-dark-grey); }

/* ── Modal (shared) ──
   Reused/promoted from the per-template modal-overlay/modal-box/row-list
   patterns already duplicated across project_detail.html, admin_settings.html
   and instance_manage.html, so base.html (loaded on every page) can use the
   same modal styling without a 5th copy-pasted <style> block. */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200; align-items: center; justify-content: center; }
.modal-backdrop.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: 420px; max-width: 90%; box-shadow: var(--shadow); }
.modal-box h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.modal-subtitle { font-size: 12px; color: var(--muted); margin: -4px 0 14px; }
.modal-search-wrap { position: relative; margin-bottom: 14px; }
.modal-search-wrap i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }
.modal-search-wrap .form-input { padding-left: 34px; margin-bottom: 0; }
/* .form-input:focus (below) resets padding via shorthand and has equal
   specificity, so without this override typing into a modal search box
   loses the left inset and the icon overlaps the text/caret. */
.modal-search-wrap .form-input:focus { padding-left: 33px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.row-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; max-height: 280px; overflow-y: auto; }
/* For a .row-list that should grow with its content instead of scrolling
   internally -- e.g. a project's Data Sources tab, where the tab/card itself
   already scrolls with the page. */
.row-list--unbounded { max-height: none; overflow: visible; }
.row-item { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; }
.row-item.clickable { cursor: pointer; transition: background 0.1s, border-color 0.1s; }
.row-item.clickable:hover { background: var(--bg); border-color: var(--border-2); }
.row-item .owner-tag { font-size: 11px; color: var(--muted); margin-left: 8px; }
.row-list-empty { font-size: 12px; color: var(--muted); padding: 4px 2px; }
.row-list-heading { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin: 12px 0 6px; }
.row-list-heading:first-child { margin-top: 0; }

/* Floating autocomplete/quick-pick panel anchored below a
   .modal-search-wrap input, instead of results pushing the modal's own
   layout around (see the impersonate-user modal in base.html). */
.impersonate-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: 10;
  max-height: 260px;
  overflow-y: auto;
  padding: 8px;
}
.impersonate-dropdown.open { display: flex; flex-direction: column; gap: 8px; }
#impersonateRecent { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
#impersonateRecent:empty { display: none; margin-bottom: 0; }
/* gap already spaces flex children -- the heading's own margin (meant for
   block-flow .row-list) would otherwise double up on top of it. */
.impersonate-dropdown .row-list-heading, #impersonateRecent .row-list-heading { margin: 0; }

/* ── Impersonation banner ── */
.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--warning);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
}
.impersonation-banner a, .impersonation-banner button {
  color: #fff;
  text-decoration: underline;
  background: none;
  border: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

/* ── Main ── */
main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 36px 40px;
  width: 100%;
}

/* ── Page shell: fixed header/filter + scrollable middle + fixed footer ──
   Opt-in layout for pages with a long/filterable list (e.g. App Logs)
   where the header, filter panel, and footer should never scroll away.
   Unlike `position: sticky`, these regions sit structurally outside the
   scrolling area, so they can't be scrolled past even at the very end of
   a long list — sticky only holds within the bounds of its containing
   block and would otherwise leave a gap there.

   Usage — give the Vue mount point (normally just `#app`) the
   `page-shell` class as well, and lay out its direct children as:
     <div id="app" v-cloak class="page-shell">
       <div class="page-shell-header">...title / actions...</div>
       <div class="page-shell-filter" v-show="...">...filter UI...</div>
       <div class="page-shell-scroll">...scrollable content...</div>
       <div class="page-shell-footer" v-if="...">...pagination...</div>
     </div>
   `main:has(.page-shell)` switches <main> itself from normal document
   flow to the flex column the shell needs — pages that don't use
   `.page-shell` are completely unaffected. */
main:has(.page-shell) {
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.page-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.page-shell-header { flex-shrink: 0; padding: 10px; }
.page-shell-header .section-header { border-bottom: none; padding-bottom: 0; justify-content: space-between; }
.page-shell-filter { flex-shrink: 0; }
.page-shell-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.page-shell-footer {
  flex-shrink: 0;
  padding: 10px 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.header-title-group { display: flex; align-items: center; gap: 12px; }
.header-title-group h2 { margin: 0; }
.filter-toggle-btn, .icon-btn {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 6px;
  cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 10px; line-height: 1;
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
}
.filter-toggle-btn:hover, .icon-btn:hover { color: var(--text); border-color: var(--cyan-dark); }
.filter-toggle-btn.active { background: rgba(183,255,0,0.12); color: var(--up3-black); border-color: var(--cyan-dark); }
.icon-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; width: 100%; font-size: 13px; }

/* ── Login ── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 130% 70% at -10% 115%, rgba(183,255,0,0.12) 0%, transparent 50%),
    var(--bg);
}
.login-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 400px;
}
.login-logo-badge {
  display: inline-flex;
  background: var(--chrome-gradient);
  border-radius: var(--radius-lg);
  padding: 22px 32px;
  margin-bottom: 24px;
}
.login-logo {
  width: 180px;
  height: auto;
}
.login-card {
  background: #ffffff;
  border-radius: 30px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow: var(--shadow);
}
.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: #f5f8fa;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  margin-bottom: 20px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}
.login-card input:focus { border: 2px solid var(--up3-green); background: #fff; padding: 9px 13px; }
/* 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-sm);
  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(183,255,0,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: rgba(46,125,50,0.08);
  border: 1px solid rgba(46,125,50,0.3);
  border-radius: var(--radius);
  color: var(--success);
  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: var(--up3-grey-100); color: var(--muted); }
.badge-running { background: rgba(184,134,11,0.18); color: var(--warning); }
.badge-done    { background: rgba(46,125,50,0.16); color: var(--success); }
.badge-error   { background: rgba(198,40,40,0.13); color: var(--error); }

/* ── Buttons ── */
.btn-primary {
  padding: 8px 16px;
  background: var(--up3-green);
  color: var(--up3-black);
  border: none;
  border-radius: 15px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.3s ease-in-out, color 0.3s ease-in-out, opacity 0.3s ease-in-out;
}
.btn-primary:hover:not(:disabled) { background: var(--up3-black); color: #fff; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  padding: 8px 16px;
  background: var(--up3-black);
  color: #fff;
  border: 1.5px solid var(--up3-black);
  border-radius: 15px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.3s ease-in-out, color 0.3s ease-in-out;
}
.btn-secondary:hover:not(:disabled) { background: #fff; color: var(--up3-black); }
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-danger {
  padding: 8px 16px;
  background: var(--surface);
  color: var(--error);
  border: 1.5px solid rgba(198,40,40,0.45);
  border-radius: 15px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  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; }

/* Row-scale modifier for btn-primary/btn-secondary/btn-danger, e.g. table row actions. */
.btn-sm { padding: 4px 12px; }
a.btn-primary, a.btn-secondary, a.btn-danger { text-decoration: none; display: inline-block; }

/* ── Data source list table header row (add/manage actions) ── */
.table-toolbar { display: flex; justify-content: flex-end; gap: 8px; }

/* ── In-table name filter row, directly under the column headers ── */
.branch-table .table-filter-row th {
  background: var(--surface);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.name-filter-input {
  width: 100%;
  max-width: 240px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 15px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: #f5f8fa;
  outline: none;
  box-sizing: border-box;
}
.name-filter-input:focus { border: 2px solid var(--up3-green); padding: 4px 9px; }

.btn-link {
  background: none;
  border: none;
  color: var(--up3-black);
  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); }

/* ── Search page ── */
.search-page {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  min-height: calc(100vh - 72px - 2 * 36px);
}

.search-filters-panel {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 20px;
}
.search-filters-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.filter-group select {
  width: 100%;
  padding: 7px 10px;
  background: #f5f8fa;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.filter-group select:focus { border: 2px solid var(--up3-green); padding: 6px 9px; }
.filter-checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--bg);
}
.filter-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  padding: 3px 0;
  cursor: pointer;
}

.source-type-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--bg);
}
.source-type-group + .source-type-group { margin-top: 8px; }
.source-type-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}
.source-type-group .filter-checklist {
  margin-top: 8px;
  margin-left: 22px;
  max-height: 160px;
  border: none;
  background: transparent;
  padding: 0;
}

.active-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px 3px 12px;
  font-size: 12px;
  color: var(--text);
}
.filter-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}

.search-main { flex: 1; min-width: 0; }

.search-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--navy);
  margin-bottom: 16px;
}
.search-brand i {
  background: var(--up3-black);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 18px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05), 0 8px 24px rgba(183,255,0,0.16);
}
.search-bar-icon { color: var(--muted); font-size: 15px; flex-shrink: 0; }
.search-bar-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  padding: 10px 0;
}
.search-bar-clear {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.search-bar-clear:hover { background: var(--bg); color: var(--text); }
.search-bar-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--up3-green);
  color: var(--up3-black);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 0.15s, opacity 0.15s;
}
.search-bar-submit:hover:not(:disabled) { filter: brightness(1.05); }
.search-bar-submit:disabled { opacity: 0.45; cursor: not-allowed; }

.search-results { width: 100%; margin-top: 24px; }
.search-meta { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.search-meta-release { text-transform: capitalize; }

/* ── 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; }
.result-meta-row { display: flex; gap: 8px; margin-bottom: 10px; }

/* ── 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(--up3-green);
  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; }

/* ── Accent strip ── */
.accent-strip {
  height: 4px;
  background: var(--up3-green);
  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: 15px;
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  background: #f5f8fa;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.browse-search:focus { border: 2px solid var(--up3-green); padding: 6px 9px; }

.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: 15px;
  font-family: var(--font);
  font-size: 11px;
  outline: none;
  background: #f5f8fa;
  box-sizing: border-box;
  min-width: 0;
}
.browse-filter-input:focus { border: 2px solid var(--up3-green); padding: 4px 7px; }
.browse-filter-select {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 15px;
  font-family: var(--font);
  font-size: 11px;
  outline: none;
  background: #f5f8fa;
  box-sizing: border-box;
  min-width: 0;
  cursor: pointer;
}
.browse-filter-select:focus { border: 2px solid var(--up3-green); padding: 4px 7px; }
.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-sm);
  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: var(--up3-grey-100); }
.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 {
  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-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,
.danger-card,
.nav-panel,
.doc-panel,
.runner-card { box-shadow: var(--shadow); }

/* ── Default panel style ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-header .card-title { margin: 0; }

.danger-card {
  background: var(--surface);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.danger-card .card-title { color: var(--error); }

/* ── Form fields (standalone create/edit pages, e.g. instance_create.html,
   docs_source_create.html) ── */
.form-row       { margin-bottom: 16px; }
.form-row label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 5px; }
.form-input     { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 15px; font-family: var(--font); font-size: 13px; color: var(--text); background: #f5f8fa; outline: none; box-sizing: border-box; }
.form-input:focus { border: 2px solid var(--up3-green); padding: 7px 11px; }
.form-hint      { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.5; }

/* ── Sidebar overlay backdrop ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,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; }
  .user-menu-name { display: none; }

  /* 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;
  }

  /* Search page: filters panel above search bar/results */
  .search-page {
    flex-direction: column;
  }
  .search-filters-panel {
    width: 100%;
    position: static;
  }

  /* 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;
  }
}

/* Reusable condition builder (ServiceNow-style filter) — app/static/condition-builder.js */
.cb-wrap { display: flex; flex-direction: column; gap: 10px; }
.cb-heading { font-size: 13px; font-weight: 600; color: var(--text); }
.cb-chain { display: flex; flex-direction: column; gap: 4px; }
.cb-item { display: flex; align-items: center; gap: 10px; }
.cb-conn-spacer, .cb-conn-or { width: 26px; flex-shrink: 0; text-align: right; }
.cb-conn-or {
  font-size: 12px; font-style: italic; font-weight: 600; color: var(--violet-dark);
}
.cb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.cb-field, .cb-op, .cb-value, .cb-value-multi {
  height: 32px; font-size: 13px; padding: 4px 8px;
  border: 1px solid var(--border-2); border-radius: 6px;
  background: var(--surface); color: var(--text); font-family: var(--font);
}
.cb-field { min-width: 140px; }
.cb-op { min-width: 150px; }
.cb-value { min-width: 160px; }
.cb-value-multi { height: auto; min-height: 60px; min-width: 160px; }
.cb-value-n { width: 64px; min-width: 64px; }
.cb-value-group { display: flex; align-items: center; gap: 6px; }
.cb-and { font-size: 12px; color: var(--muted); }
.cb-empty-hint { font-size: 12px; color: var(--muted); font-style: italic; padding: 6px 0; }

.cb-row-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.cb-and-btn, .cb-or-btn {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 6px;
  cursor: pointer; font-size: 11px; font-weight: 700; letter-spacing: 0.03em;
  padding: 5px 10px; color: var(--muted);
}
.cb-and-btn:hover { border-color: var(--cyan-dark); color: var(--up3-black); }
.cb-or-btn:hover { border-color: var(--violet-dark); color: var(--violet-dark); }
.cb-remove {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 16px; line-height: 1; padding: 0 4px;
}
.cb-remove:hover { color: var(--error); }

.cb-group-box {
  flex: 1; display: flex; flex-direction: column; gap: 4px;
  background: var(--bg); border: 1px dashed var(--border-2); border-radius: var(--radius);
  padding: 10px;
}
.cb-group-box .cb-add-row {
  align-self: flex-start; background: none; border: none; cursor: pointer;
  color: var(--up3-black); font-size: 12px; font-weight: 600; padding: 2px 0;
}
.cb-group-box .cb-add-row:hover { text-decoration: underline; }

.cb-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cb-toolbar-spacer { flex: 1; }
.cb-toolbar-btn { padding: 6px 14px; }
.cb-add-group {
  background: none; border: 1px dashed var(--border-2); border-radius: 6px;
  cursor: pointer; color: var(--violet-dark); font-size: 12px; font-weight: 600;
  padding: 6px 10px;
}
.cb-add-group:hover { background: rgba(75,75,75,0.08); }
.cb-clear, .cb-run {
  border-radius: 6px; font-size: 13px; font-weight: 600; padding: 6px 16px;
  cursor: pointer; border: 1px solid var(--border-2);
}
.cb-clear { background: var(--surface); color: var(--muted); }
.cb-clear:hover { background: var(--bg); }
.cb-run { background: var(--up3-green); color: var(--up3-black); border-color: transparent; }
.cb-run:hover { filter: brightness(1.05); }

/* ── Stat cards ──────────────────────────────────────────────────── */
.stat-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:14px; margin-bottom:28px; }
.stat-grid-wide { grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); }
.stat-card { background:var(--surface); border:1px solid var(--border); border-radius:30px; padding:16px 18px; 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-icon { width:34px; height:34px; border-radius:8px; display:flex; align-items:center; justify-content:center; margin-bottom:12px; flex-shrink:0; }
.stat-num  { font-size:28px; font-weight:700; color:var(--text); line-height:1; }
.stat-sub  { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.07em; color:var(--muted); margin-top:6px; }
.stat-num-row { display:flex; align-items:baseline; gap:8px; }
.stat-delta { display:inline-flex; align-items:center; gap:2px; font-size:11px; font-weight:700; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--error); }
.stat-delta.flat { color: var(--warning); }

/* ── Homepage: section heading, hero fun-stats, superlatives ─────── */
.section-heading {
  font-size: 14px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 12px;
}
.hero-stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.hero-stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.hero-stat::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gradient); }
.hero-stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--up3-black); color: var(--up3-green); font-size: 18px;
  margin-bottom: 14px;
}
.hero-stat-select {
  font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 4px 10px; background: var(--surface); cursor: pointer; outline: none;
  max-width: 190px;
}
.hero-stat-select:focus { border-color: var(--up3-green); }
.hero-stat-toggle {
  display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 2px; background: var(--surface); gap: 2px;
}
.hero-stat-toggle button {
  font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--muted);
  border: none; border-radius: var(--radius-pill); padding: 4px 10px;
  background: transparent; cursor: pointer;
}
.hero-stat-toggle button.active { background: var(--up3-black); color: var(--up3-green); }
.hero-stat-num { font-size: 40px; font-weight: 800; color: var(--text); line-height: 1; }
.hero-stat-label { font-size: 14px; font-weight: 600; color: var(--text); margin-top: 8px; }
.hero-stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.hero-stat-chart { position: relative; height: 90px; margin-top: 14px; }

.superlative-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 8px;
}
.superlative-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.superlative-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin-bottom: 6px;
}
.superlative-value {
  font-size: 14px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.superlative-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Data source stat cards ──────────────────────────────────────── */
.ds-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 30px; padding: 18px 20px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.ds-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--gradient);
}
.ds-value { font-size: 30px; font-weight: 700; line-height: 1; margin-bottom: 5px; color: var(--text); }
.ds-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
}

/* ── Error pages (404 / 403 / 500) ───────────────────────────────── */
.error-page-body {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 70vh;
  padding: 40px 20px;
  gap: 8px;
}
.error-page-body .error-page {
  min-height: 0;
}
.error-code {
  font-size: 88px;
  font-weight: 800;
  line-height: 1;
  color: var(--border-2);
  letter-spacing: -0.02em;
}
.error-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.error-subtitle {
  font-size: 14px;
  color: var(--muted);
  max-width: 360px;
  margin-bottom: 12px;
}

/* ── Help articles ── */
.help-article-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.help-article-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px 20px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden; text-decoration: none; display: block;
  transition: box-shadow 0.15s, transform 0.15s;
}
.help-article-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gradient); }
.help-article-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.help-article-icon {
  width: 34px; height: 34px; border-radius: 8px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
  color: var(--up3-black); font-size: 16px;
}
.help-article-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.help-article-summary { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ── Info banner (quiet, non-blocking notice within page content) ── */
.info-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text);
}
.info-banner i { font-size: 18px; color: var(--info); flex-shrink: 0; }
.info-banner a { color: var(--text); font-weight: 700; text-decoration: underline; }

/* ── Welcome banner (eye-catching onboarding nudge, e.g. homepage) ── */
.welcome-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.welcome-banner::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--gradient); }
.welcome-banner-icon {
  width: 48px; height: 48px; border-radius: 50%; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--up3-black); flex-shrink: 0;
}
.welcome-banner-body { flex: 1; min-width: 0; }
.welcome-banner-title { font-size: 17px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.welcome-banner-text { font-size: 13px; color: var(--muted); line-height: 1.5; }
.welcome-banner-cta { flex-shrink: 0; white-space: nowrap; }
@media (max-width: 640px) {
  .welcome-banner { flex-wrap: wrap; }
}

/* ── Rendered markdown (help articles, agent plans/narration) ── */
.markdown-body { font-size: 13px; line-height: 1.6; color: var(--text); }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 14px 0 6px; font-weight: 700; line-height: 1.3; }
.markdown-body h1 { font-size: 17px; }
.markdown-body h2 { font-size: 15.5px; }
.markdown-body h3 { font-size: 14px; }
.markdown-body h4 { font-size: 13px; }
.markdown-body p { margin: 6px 0; }
.markdown-body ul, .markdown-body ol { margin: 6px 0; padding-left: 22px; }
.markdown-body li { margin: 2px 0; }
.markdown-body li > p { margin: 2px 0; }
.markdown-body img { max-width: 100%; border-radius: var(--radius-sm); }
.markdown-body code { font-family: monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; }
.markdown-body pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; overflow-x: auto; margin: 8px 0; }
.markdown-body pre code { background: none; border: none; padding: 0; }
.markdown-body a { color: var(--up3-black); text-decoration: underline; }
.markdown-body strong { font-weight: 700; }
.markdown-body blockquote { margin: 6px 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.markdown-body table { border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 4px 8px; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

/* Blend Toast UI Editor with the app's own theme instead of its default look */
.toastui-editor-defaultUI { border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font); }
.toastui-editor-toolbar { background: var(--surface); border-bottom: 1px solid var(--border) !important; }
.toastui-editor-defaultUI-toolbar { background: var(--surface); }
.toastui-editor-toolbar-icons { color: var(--text); }
.toastui-editor-toolbar-icons:hover { background-color: var(--bg) !important; }
.toastui-editor-toolbar-icons.active { background-color: var(--bg) !important; }
.toastui-editor-mode-switch { background: var(--surface); border-top: 1px solid var(--border); }
.toastui-editor-mode-switch .tab-item { color: var(--muted); }
.toastui-editor-mode-switch .tab-item.active { color: var(--text); border-bottom-color: var(--up3-green) !important; }
.toastui-editor-md-container, .toastui-editor-ww-container { background: var(--bg); }
.toastui-editor-contents { font-family: var(--font); font-size: 13px; color: var(--text); }
.toastui-editor-contents p, .toastui-editor-contents li { font-size: 13px; }
.toastui-editor-contents h1, .toastui-editor-contents h2, .toastui-editor-contents h3,
.toastui-editor-contents h4, .toastui-editor-contents h5, .toastui-editor-contents h6 { color: var(--up3-black); }
.toastui-editor-contents a { color: var(--up3-black); text-decoration: underline; }
.toastui-editor-contents blockquote { border-left: 3px solid var(--border); color: var(--muted); }
.toastui-editor-contents code, .toastui-editor-contents pre {
  background: var(--surface); border: 1px solid var(--border);
}
.toastui-editor-contents table th { background: var(--bg); color: var(--text); }
.toastui-editor-contents table th p { color: var(--text) !important; }
.toastui-editor-contents table th, .toastui-editor-contents table td { border: 1px solid var(--border); }
/* The app's own base stylesheet zeroes out margin/padding on all ul/ol
   (for nav menus etc.), which strips the indentation markers need to sit
   in -- restore it here the same way .markdown-body already does. */
.toastui-editor-contents ul, .toastui-editor-contents ol { list-style: none; margin: 6px 0; padding-left: 22px; }
.toastui-editor-contents li { margin: 2px 0; }
