/* ============================================================
   Bruce Portal — v2 design system
   Same warm-dark brand identity as v1, rebuilt as reusable
   tokens + components so templates stop shipping inline <style>.
   Loaded only behind the ?v2=1 flag; v1 is untouched.
   ============================================================ */

:root {
  /* Native form controls (date pickers, selects, scrollbars) render for a
     dark page instead of light-on-dark. */
  color-scheme: dark;

  /* ---- Brand palette (carried over from v1, tuned) ---- */
  --bg:        #17110b;
  --bg-2:      #1e1710;
  --panel:     #241c14;
  --panel-2:   #2e251a;
  --panel-3:   #3a2f21;
  --border:    #3d3324;
  --border-2:  #4c4030;
  --ink:       #f0e6d6;
  --ink-dim:   #a2937b;
  --ink-faint: #6f6350;
  --accent:    #e85a2a;
  --accent-2:  #f7895a;
  --accent-3:  #ffb08c;
  --brand:     #e85a2a;
  --brand-2:   #f7895a;
  --link:      #4cc8ee;
  --good:      #58c479;
  --warn:      #e0b04a;
  --bad:       #e66161;
  --info:      #4cc8ee;
  --code-bg:   #0e0a06;

  /* ---- Type scale ---- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 11px; --fs-sm: 12px; --fs-base: 13.5px; --fs-md: 15px;
  --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 28px; --fs-3xl: 34px;

  /* ---- Spacing scale ---- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s8: 32px; --s10: 40px;

  /* ---- Radius / elevation ---- */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-full: 999px;
  --shadow-1: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-2: 0 6px 20px -6px rgba(0,0,0,0.55);
  --shadow-glow: 0 0 26px -6px rgba(232,90,42,0.45);
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font: var(--fs-base)/1.55 var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 12% -8%, rgba(232,90,42,0.08), transparent 42%),
    radial-gradient(ellipse at 88% 108%, rgba(76,200,238,0.06), transparent 42%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 700; }

/* =========================== Layout shell =========================== */

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid var(--border);
}
.sidebar .brand img {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  box-shadow: 0 0 0 2px rgba(76,200,238,0.35), 0 0 22px rgba(76,200,238,0.28);
}
.sidebar .brand .name {
  font-family: var(--font-mono); font-weight: 700;
  letter-spacing: 1.5px; font-size: var(--fs-md);
}
.sidebar .brand .sub { font-size: var(--fs-xs); color: var(--ink-dim); letter-spacing: 0.5px; }

.sidebar nav { padding: var(--s3) 0; flex: 1; overflow-y: auto; }
.nav-group-label {
  padding: var(--s3) var(--s5) var(--s1);
  font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 700;
}
.sidebar nav a {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px var(--s5); color: var(--ink);
  border-left: 3px solid transparent;
  font-size: var(--fs-base);
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.sidebar nav a .nav-ico { width: 18px; text-align: center; opacity: 0.85; }
.sidebar nav a:hover { background: var(--panel-2); text-decoration: none; }
.sidebar nav a.active {
  border-left-color: var(--accent); background: var(--panel-2);
  color: var(--accent-2); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent), 0 0 16px -4px rgba(232,90,42,0.45);
}
.sidebar .user {
  padding: var(--s3) var(--s5); border-top: 1px solid var(--border);
  font-size: var(--fs-sm); color: var(--ink-dim);
}
.sidebar .user .u-name { color: var(--ink); font-weight: 600; }
.sidebar .user form { margin-top: var(--s2); }

.main {
  flex: 1; min-width: 0;
  padding: var(--s6) var(--s8);
  max-width: 1440px;
}
.page-head { margin-bottom: var(--s5); }
.page-head h1 {
  font-family: var(--font-mono); font-size: var(--fs-xl);
  letter-spacing: 2px; text-transform: uppercase;
}
.page-head .sub { color: var(--ink-dim); margin-top: var(--s1); font-size: var(--fs-base); }

.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  margin: var(--s6) 0 var(--s3);
  font-size: var(--fs-sm); letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--accent-2); font-weight: 700;
}
.section-title a { font-size: var(--fs-sm); color: var(--ink-dim); font-weight: 400; letter-spacing: 0; text-transform: none; }
.section-title a:hover { color: var(--accent); }

/* =========================== Buttons =========================== */

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #1a0f00; border: none;
  padding: 7px 14px; border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: 600; font-family: inherit;
  cursor: pointer;
  box-shadow: 0 0 16px -4px rgba(232,90,42,0.4), inset 0 1px 0 rgba(255,255,255,0.12);
  transition: box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
}
.btn:hover, button:hover {
  background: var(--accent-2); text-decoration: none; transform: translateY(-1px);
  box-shadow: 0 0 26px -2px rgba(232,90,42,0.6), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn:active, button:active { transform: translateY(0); }
.btn.secondary, button.secondary {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--border);
  box-shadow: none;
}
.btn.secondary:hover, button.secondary:hover { background: var(--panel-3); border-color: var(--border-2); }
.btn.danger, button.danger { background: var(--bad); color: #2a0000; box-shadow: 0 0 16px -4px rgba(230,97,97,0.5); }
.btn.ghost { background: transparent; color: var(--ink-dim); border: 1px solid var(--border); box-shadow: none; }

/* =========================== Cards / panels =========================== */

.grid { display: grid; gap: var(--s4); }
.grid.cols-auto { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .grid.cols-2 { grid-template-columns: 1fr; } }

.card, .panel {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(0,0,0,0)), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.card { padding: var(--s4); }
.panel { padding: var(--s4) var(--s5); }
.card:hover { box-shadow: 0 0 22px -8px rgba(76,200,238,0.35); transform: translateY(-1px); }

.panel > h2 {
  font-size: var(--fs-sm); letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--accent-2); margin-bottom: var(--s3);
  padding-bottom: var(--s2); border-bottom: 1px solid var(--border);
}

/* Stat / KPI card */
.stat .k { color: var(--ink-dim); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.6px; }
.stat .v { font-size: var(--fs-2xl); font-weight: 700; margin: var(--s1) 0; line-height: 1.05; }
.stat .v.small { font-size: var(--fs-md); font-weight: 600; }
.stat .meta { color: var(--ink-dim); font-size: var(--fs-sm); }

/* KPI tiles that link somewhere (attention row) */
.kpi {
  display: block; text-decoration: none; color: inherit;
  border-left: 3px solid var(--border-2);
}
.kpi:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.kpi .n { font-size: var(--fs-2xl); font-weight: 800; line-height: 1.05; color: var(--ink); }
.kpi .lbl { font-size: var(--fs-xs); color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.kpi.good   { border-left-color: var(--good); }
.kpi.warn   { border-left-color: var(--warn); }
.kpi.danger { border-left-color: var(--bad); }

/* =========================== Status dots =========================== */

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.good { background: var(--good); animation: dot-good 2.4s infinite; }
.dot.warn { background: var(--warn); animation: dot-warn 2s infinite; }
.dot.bad  { background: var(--bad);  animation: dot-bad 1.6s infinite; }
@keyframes dot-good { 0%,100%{box-shadow:0 0 0 0 rgba(88,196,121,.6)} 60%{box-shadow:0 0 0 7px rgba(88,196,121,0)} }
@keyframes dot-bad  { 0%,100%{box-shadow:0 0 0 0 rgba(230,97,97,.55)} 60%{box-shadow:0 0 0 7px rgba(230,97,97,0)} }
@keyframes dot-warn { 0%,100%{box-shadow:0 0 0 0 rgba(224,176,74,.5)}  60%{box-shadow:0 0 0 7px rgba(224,176,74,0)} }

/* =========================== Tables =========================== */

table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--r-md); overflow: hidden; }
th, td { padding: 10px var(--s3); text-align: left; border-bottom: 1px solid var(--border); font-size: var(--fs-base); }
th { background: var(--panel-2); color: var(--ink-dim); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--panel-2); }

/* =========================== Bits =========================== */

.tag { display: inline-block; padding: 2px 9px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--r-full); font-size: var(--fs-xs); color: var(--ink-dim); }
.tag.on { color: var(--good); border-color: rgba(88,196,121,0.4); }
.muted { color: var(--ink-dim); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.flash { background: var(--panel-2); border: 1px solid var(--accent); box-shadow: 0 -1px 0 var(--accent) inset, 0 0 18px -4px rgba(232,90,42,0.35); padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: var(--s4); }
.warning-box { background: rgba(230,97,97,0.08); border: 1px solid var(--bad); padding: 12px 14px; border-radius: var(--r-sm); }
.empty { color: var(--ink-dim); font-size: var(--fs-base); padding: var(--s3) 0; }

/* List rows inside panels (diary / jobs / feed) */
.list-row { display: grid; grid-template-columns: 96px 1fr; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px dashed rgba(255,255,255,0.06); align-items: start; }
.list-row:last-child { border-bottom: none; }
.list-row .when { color: var(--ink-dim); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.list-row .title { font-weight: 600; color: var(--ink); }
.list-row .meta { color: var(--ink-dim); font-size: var(--fs-xs); }
.day-header { margin-top: var(--s3); font-size: var(--fs-xs); color: var(--accent-2); font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; }
.day-header:first-child { margin-top: 0; }
.panel-footer { text-align: right; margin-top: var(--s3); padding-top: var(--s2); border-top: 1px solid var(--border); }
.panel-footer a { font-size: var(--fs-sm); }

/* Global search bar */
.search-bar { display: flex; gap: var(--s2); margin: var(--s4) 0; }
.search-bar input { flex: 1; padding: 11px 15px; background: var(--panel-2); border: 1px solid var(--border); color: var(--ink); border-radius: var(--r-sm); font-size: var(--fs-md); }
.search-bar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,90,42,0.15); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--accent), #b03d18); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--accent-2); }

/* v2 badge in corner */
.v2-badge {
  position: fixed; bottom: 14px; left: 14px; z-index: 900;
  background: rgba(76,200,238,0.12); border: 1px solid var(--link);
  color: var(--link); font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 1px; padding: 4px 10px; border-radius: var(--r-full);
}
.v2-badge a { color: var(--ink-dim); margin-left: 8px; }

/* =========================== Mobile =========================== */

.mobile-topbar, .sidebar-backdrop, .mobile-menu-btn { display: none; }

@media (max-width: 860px) {
  .mobile-topbar {
    display: flex; align-items: center; gap: var(--s3);
    position: sticky; top: 0; z-index: 50;
    background: var(--panel); border-bottom: 1px solid var(--border);
    padding: var(--s2) var(--s3); height: 52px;
  }
  .mobile-topbar-title { font-family: var(--font-mono); font-size: var(--fs-base); font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent-2); }
  .mobile-menu-btn { display: flex !important; flex-direction: column; justify-content: space-between; width: 36px; height: 36px; padding: 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; }
  .mobile-menu-btn span { display: block; height: 2px; background: var(--ink); border-radius: 1px; }

  .layout { display: block; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; z-index: 100; transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 99; opacity: 0; pointer-events: none; transition: opacity 0.22s ease; }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar nav a { padding: 13px var(--s5); font-size: var(--fs-md); }

  .main { padding: var(--s4) var(--s3) 90px; max-width: 100%; }
  .page-head h1 { font-size: var(--fs-lg); letter-spacing: 1.2px; }
  .grid.cols-2, .grid.cols-auto { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px !important; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ============================================================
   Polish layer (2026-07-02) — modernizes ALL pages at once.
   ============================================================ */

/* ---- Global dark form controls (many pages had browser-default
       white inputs on the dark theme) ---- */
input[type="text"], input[type="search"], input[type="email"], input[type="url"],
input[type="tel"], input[type="number"], input[type="password"], input[type="date"],
input[type="time"], input[type="datetime-local"], input:not([type]),
select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  font-family: inherit;
  font-size: var(--fs-base);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 90, 42, 0.15);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
select option { background: var(--panel); color: var(--ink); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input[type="file"] { color: var(--ink-dim); }
input[type="file"]::file-selector-button {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 6px 12px; margin-right: 10px;
  font-family: inherit; font-size: var(--fs-sm); cursor: pointer;
}
input:disabled, select:disabled, textarea:disabled, button:disabled {
  opacity: 0.55; cursor: not-allowed;
}
label { color: var(--ink-dim); font-size: var(--fs-sm); }
fieldset { border: 1px solid var(--border); border-radius: var(--r-md); }

/* ---- Unified page headers: v1 pages use a bare <h1> under .main ---- */
.main > h1 {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0 0 4px;
}
.main > h1 + .sub, .main > .sub { color: var(--ink-dim); margin-bottom: var(--s5); }
.main h2 {
  font-size: var(--fs-md); color: var(--accent-2);
  letter-spacing: 0.8px; margin: var(--s6) 0 var(--s3);
}

/* ---- Keyboard focus rings everywhere (a11y + polish) ---- */
a:focus-visible, button:focus-visible, .btn:focus-visible,
[tabindex]:focus-visible, summary:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- Text selection in brand color ---- */
::selection { background: rgba(232, 90, 42, 0.35); color: var(--ink); }

/* ---- Tables: subtle zebra + softer chrome ---- */
tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }
tbody tr:hover td { background: var(--panel-2); }
td, th { border-bottom-color: rgba(61, 51, 36, 0.7); }

/* ---- Links: smooth color transitions, no layout-shifting underlines ---- */
a { transition: color 0.14s ease; }
a:hover { text-decoration: none; color: var(--accent-3); }
.sidebar nav a:hover { color: var(--ink); }
p a, td a, .list-row a, .panel a { text-decoration: underline; text-decoration-color: rgba(76, 200, 238, 0.35); text-underline-offset: 3px; }
p a:hover, td a:hover { text-decoration-color: var(--accent-2); }

/* ---- Flash messages slide in ---- */
.flash { animation: flash-in 0.28s ease; }
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

/* ---- Content fade-in on navigation (very subtle) ---- */
.main { animation: page-in 0.22s ease; }
@keyframes page-in {
  from { opacity: 0.35; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ---- details/summary used on several admin pages ---- */
details {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--s2) var(--s4); margin: var(--s2) 0;
}
details[open] { padding-bottom: var(--s4); }
summary { cursor: pointer; color: var(--accent-2); font-weight: 600; padding: var(--s1) 0; }
summary:hover { color: var(--accent-3); }

/* ---- hr ---- */
hr { border: none; border-top: 1px solid var(--border); margin: var(--s5) 0; }

/* ---- Code/kbd inline ---- */
code, kbd {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px;
  font-family: var(--font-mono); font-size: 0.9em;
}
pre code { border: none; padding: 0; background: transparent; }

/* ---- Login page modernization ---- */
.login-wrap {
  background:
    radial-gradient(ellipse at 20% 15%, rgba(232,90,42,0.10), transparent 50%),
    radial-gradient(ellipse at 80% 85%, rgba(76,200,238,0.08), transparent 50%),
    var(--bg);
}
.login-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0)), var(--panel);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2), 0 0 60px -20px rgba(232,90,42,0.25);
  animation: login-in 0.4s ease;
}
@keyframes login-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.login-card h1 { font-family: var(--font-mono); letter-spacing: 2px; text-transform: uppercase; font-size: var(--fs-lg); }
.google-btn { border-radius: var(--r-sm); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.google-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,0.3); }

/* ---- Navigation progress bar (driven by JS in base.html) ---- */
#nav-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px rgba(232,90,42,0.7);
  z-index: 2000; opacity: 0;
  transition: width 0.25s ease, opacity 0.3s ease;
}
#nav-progress.active { opacity: 1; }

/* ---- Respect users who prefer less motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Visual refresh v2.1 (2026-07-02) — the step-change pass.
   Loaded last, so these override the base system where they
   overlap. Unmistakably different at first glance:
   glass sidebar, gradient headers, ringed cards, pill buttons.
   ============================================================ */

:root {
  --r-md: 12px;
  --r-lg: 16px;
}

/* ---- Richer layered background with visible depth ---- */
body {
  background:
    radial-gradient(1100px 500px at 8% -12%, rgba(232, 90, 42, 0.13), transparent 55%),
    radial-gradient(900px 460px at 96% 112%, rgba(76, 200, 238, 0.10), transparent 55%),
    radial-gradient(700px 380px at 55% 45%, rgba(247, 137, 90, 0.04), transparent 60%),
    linear-gradient(180deg, #1b140c, #150f09 60%, #17110b);
  background-attachment: fixed;
}

/* ---- Sidebar: dark glass ---- */
.sidebar {
  background: linear-gradient(180deg, rgba(36, 28, 20, 0.86), rgba(24, 18, 12, 0.92));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar .brand { border-bottom-color: rgba(255, 255, 255, 0.06); }
.sidebar nav a {
  margin: 1px 10px 1px 0;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.sidebar nav a.active {
  background: linear-gradient(90deg, rgba(232, 90, 42, 0.20), rgba(232, 90, 42, 0.05));
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar .user { border-top-color: rgba(255, 255, 255, 0.06); }

/* ---- Headers: gradient ink — the "something changed" moment ---- */
.page-head h1, .main > h1 {
  background: linear-gradient(92deg, var(--ink) 0%, var(--accent-2) 55%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent-2); /* fallback for old engines */
  padding-bottom: 2px;
}
.page-head { padding-bottom: var(--s3); border-bottom: 1px solid rgba(255, 255, 255, 0.05); }

/* ---- Cards & panels: gradient ring + deeper elevation ---- */
.card, .panel, .dash-panel {
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.008)) padding-box,
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(165deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.03) 45%, rgba(232, 90, 42, 0.12)) border-box;
  border-radius: var(--r-md);
  box-shadow: 0 8px 28px -14px rgba(0, 0, 0, 0.65);
}
.card:hover {
  box-shadow: 0 10px 34px -12px rgba(0, 0, 0, 0.7), 0 0 26px -10px rgba(76, 200, 238, 0.4);
  transform: translateY(-2px);
}
/* keep the KPI status edge visible over the ring */
.kpi { border-left-width: 3px !important; }
.kpi.good   { border-left-color: var(--good) !important; }
.kpi.warn   { border-left-color: var(--warn) !important; }
.kpi.danger { border-left-color: var(--bad) !important; }

/* ---- Buttons: gradient pills ---- */
.btn, button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: var(--r-full);
  padding: 7px 16px;
}
.btn:hover, button:hover {
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
}
.btn.secondary, button.secondary, .btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--ink);
}
.btn.secondary:hover, button.secondary:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn.danger, button.danger { background: linear-gradient(135deg, #c94444, var(--bad)); color: #fff; }

/* ---- Inputs: match the glass language ---- */
input[type="text"], input[type="search"], input[type="email"], input[type="url"],
input[type="tel"], input[type="number"], input[type="password"], input[type="date"],
input[type="time"], input[type="datetime-local"], input:not([type]),
select, textarea {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--r-md);
}
.search-bar input { border-radius: var(--r-full); padding-left: 18px; }
.search-bar button { border-radius: var(--r-full); }

/* ---- Tables: floating container ---- */
table {
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 8px 24px -16px rgba(0, 0, 0, 0.6);
  border-radius: var(--r-md);
}
th { background: rgba(255, 255, 255, 0.035); }

/* ---- Tags: glass pills ---- */
.tag {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ---- Mobile topbar matches the glass sidebar ---- */
@media (max-width: 860px) {
  .mobile-topbar {
    background: rgba(24, 18, 12, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }
}

/* ---- Notification bell (2026-07-02) ---- */
#notif-bell {
  position: fixed; top: 14px; right: 16px; z-index: 950;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer; user-select: none;
  background: rgba(24, 18, 12, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
#notif-bell:hover { transform: scale(1.08); border-color: var(--accent); }
#notif-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 10px rgba(232, 90, 42, 0.6);
}
#notif-panel {
  position: fixed; top: 60px; right: 16px; z-index: 949;
  width: 340px; max-width: calc(100vw - 32px);
  max-height: 60vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(36, 28, 20, 0.97), rgba(24, 18, 12, 0.97));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 48px -12px rgba(0, 0, 0, 0.7);
  animation: flash-in 0.2s ease;
}
#notif-panel .notif-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--accent-2);
}
.notif-item {
  display: grid; grid-template-columns: 26px 1fr; gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--ink); text-decoration: none !important;
}
.notif-item:hover { background: rgba(255, 255, 255, 0.04); }
.notif-item.unseen { background: rgba(232, 90, 42, 0.07); }
.notif-item.unseen .ni-title::after {
  content: ""; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent); margin-left: 7px;
}
.notif-item .ni-title { display: block; font-weight: 600; font-size: var(--fs-base); }
.notif-item .ni-detail { display: block; color: var(--ink-dim); font-size: var(--fs-xs); margin-top: 2px; }
.notif-empty { padding: var(--s6); text-align: center; color: var(--ink-dim); }
@media (max-width: 860px) {
  #notif-bell { top: 8px; right: 60px; width: 36px; height: 36px; }
  #notif-panel { top: 56px; }
}

/* ════════════════════════════════════════════════════════════════
   v2.2 GUI upgrade (2026-07-06) — density, navigation, kanban, toasts
   ════════════════════════════════════════════════════════════════ */

/* ── Tables: sticky headers, hover, compact controls ── */
table { border-collapse: separate; border-spacing: 0; }
table th {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, var(--panel));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
table tr:hover td { background: rgba(255, 255, 255, 0.035); }
table td { transition: background 0.12s ease; }
table td select, table td input[type="email"], table td input[type="text"] {
  padding: 4px 8px; font-size: var(--fs-xs); border-radius: 6px;
}
table td .btn, table td button { white-space: nowrap; }

/* ── Tags: consistent pill chips ── */
.tag {
  display: inline-block; padding: 1px 9px; margin: 0 2px;
  border-radius: var(--r-full); font-size: 11px; font-weight: 600;
  background: rgba(255, 255, 255, 0.06); color: var(--ink-dim);
  border: 1px solid rgba(255, 255, 255, 0.09); vertical-align: 1px;
}
.tag.on {
  background: rgba(232, 90, 42, 0.14); color: var(--accent-2);
  border-color: rgba(232, 90, 42, 0.35);
}

/* ── Details/summary (letter bars, settings) ── */
details > summary { cursor: pointer; user-select: none; transition: color 0.15s ease; }
details > summary:hover { color: var(--accent-2); }
details[open] > summary { margin-bottom: var(--s2); }

/* ── Collapsible sidebar groups ── */
.sidebar nav a { padding-top: 6px; padding-bottom: 6px; }
details.nav-group > summary.nav-group-label {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; list-style: none; user-select: none;
}
details.nav-group > summary.nav-group-label::-webkit-details-marker { display: none; }
details.nav-group > summary.nav-group-label::after {
  content: "▸"; font-size: 9px; opacity: 0.5;
  transition: transform 0.18s ease; margin-right: 10px;
}
details.nav-group[open] > summary.nav-group-label::after { transform: rotate(90deg); }
details.nav-group > summary.nav-group-label:hover { color: var(--accent-2); }
.sidebar .cmdk-hint {
  margin: var(--s2) var(--s4); padding: 5px 10px;
  border: 1px dashed rgba(255, 255, 255, 0.14); border-radius: var(--r-md);
  font-size: 11px; color: var(--ink-dim); cursor: pointer; text-align: center;
}
.sidebar .cmdk-hint:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.3); }
.sidebar .cmdk-hint kbd {
  font-family: var(--mono, monospace); font-size: 10px; padding: 1px 5px;
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 4px; margin: 0 1px;
}

/* ── Flash → toast ── */
.main > .flash, .flash {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 300; max-width: min(680px, 90vw);
  padding: 12px 40px 12px 18px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, rgba(38, 46, 60, 0.97), rgba(28, 34, 46, 0.97));
  border: 1px solid rgba(232, 90, 42, 0.45);
  box-shadow: 0 12px 40px -8px rgba(0, 0, 0, 0.75);
  font-size: var(--fs-sm); color: var(--ink);
  animation: toast-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  cursor: pointer;
}
.flash::after { content: "✕"; position: absolute; right: 14px; top: 12px;
  font-size: 11px; opacity: 0.5; }
.flash.fade { opacity: 0; transform: translateX(-50%) translateY(-8px);
  transition: opacity 0.5s ease, transform 0.5s ease; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-14px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Kanban (pipeline) ── */
.kanban {
  display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr));
  gap: var(--s3); align-items: start; overflow-x: auto; padding-bottom: var(--s3);
}
.kanban-col {
  background: rgba(255, 255, 255, 0.025); border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--r-lg); padding: var(--s3);
  max-height: 74vh; overflow-y: auto;
}
.kanban-col > .kcol-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--s2); position: sticky; top: calc(-1 * var(--s3));
  background: inherit; padding: var(--s2) 0; z-index: 2;
}
.kanban-col.k-won { border-color: rgba(88, 196, 121, 0.25); }
.kanban-col.k-lost { opacity: 0.75; }
.kcard {
  background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--src, var(--accent));
  border-radius: var(--r-md); padding: 8px 10px; margin-bottom: var(--s2);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.kcard:hover { transform: translateY(-1px); box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.6); }
.kcard a { text-decoration: none; }
.kcard select { width: 100%; margin-top: 5px; padding: 2px 4px; font-size: 11px;
  opacity: 0.55; transition: opacity 0.15s ease; }
.kcard:hover select { opacity: 1; }

/* ── Command palette ── */
#cmdk-overlay[hidden] { display: none; }
#cmdk-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(8, 10, 14, 0.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh; animation: flash-in 0.15s ease;
}
#cmdk {
  width: min(560px, 92vw); border-radius: var(--r-lg); overflow: hidden;
  background: linear-gradient(160deg, rgba(34, 41, 54, 0.99), rgba(24, 29, 39, 0.99));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 80px -12px rgba(0, 0, 0, 0.85);
}
#cmdk input {
  width: 100%; padding: 15px 18px; border: none; border-radius: 0;
  background: transparent; color: var(--ink); font-size: 15px; outline: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
#cmdk-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
#cmdk-list .ck-item {
  display: flex; gap: 10px; align-items: center;
  padding: 9px 12px; border-radius: var(--r-md);
  color: var(--ink); text-decoration: none; font-size: var(--fs-base);
}
#cmdk-list .ck-item .ck-ico { width: 20px; text-align: center; }
#cmdk-list .ck-item .ck-group { margin-left: auto; font-size: 10px; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.6px; }
#cmdk-list .ck-item.sel { background: rgba(232, 90, 42, 0.16);
  outline: 1px solid rgba(232, 90, 42, 0.4); }
#cmdk-list .ck-empty { padding: 18px; text-align: center; color: var(--ink-dim);
  font-size: var(--fs-sm); }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12);
  border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.22); }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  .kcard, .flash, #cmdk-overlay { animation: none; transition: none; }
}

/* kanban drag-and-drop affordances (v2.2.1) */
.kcard[draggable="true"] { cursor: grab; }
.kcard[draggable="true"]:active { cursor: grabbing; }
.kanban-col.drop-ok {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: rgba(232, 90, 42, 0.06);
}
