/* ── Reset & Tokens ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Brand — QuantumApps: amber-yellow → orange (unchanged across themes) */
  --brand: #FFB800;
  --brand2: #FF8000;
  --brand-grad: linear-gradient(135deg, #FFD93D, #FF8C00);
  --brand-lt: rgba(255, 184, 0, .12);

  /* Light theme (default) */
  --bg: #f1f3f8;
  --surface: #ffffff;
  --surface2: #f8f9fc;
  --surface3: #f1f3f8;
  --navy: #0f172a;
  --navy2: #1e293b;
  --navy3: #334155;
  --border: rgba(15, 23, 42, .07);
  --border-md: rgba(15, 23, 42, .13);
  --text: #0f172a;
  --text2: #475569;
  --text3: hsl(214, 24%, 71%);
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-mid: #22c55e;
  --green-bd: #bbf7d0;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-mid: #f59e0b;
  --amber-bd: #fde68a;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-mid: #ef4444;
  --red-bd: #fecaca;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --blue-mid: #3b82f6;
  --blue-bd: #bfdbfe;
  --cyan: #22d3ee;
  --cyan-bg: rgba(34, 211, 238, .12);
  --cyan-mid: #06b6d4;
  --cyan-bd: rgba(34, 211, 238, .25);
  --cyan-glow: rgba(6, 182, 212, .6);
  --sh-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --sh-md: 0 4px 12px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .04);
  --sh-lg: 0 10px 24px rgba(15, 23, 42, .10), 0 4px 8px rgba(15, 23, 42, .05);
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --font: 'Sora', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --topbar-h: 58px;
  --tower-hdr-h: 67px;
  --sticky-table-top: calc(var(--topbar-h) + var(--tower-hdr-h));
  --res-controls-h: 63px;
}

/* ── Dark Theme Token Overrides ──────────────────────────────── */
html[data-theme="dark"] {
  --bg: #08080f;
  --surface: #131313;
  --surface2: #1a1a1a;
  --surface3: #0f0f0f;
  --navy: #0b0b16;
  --navy2: #111122;
  --navy3: #1c1c30;
  --border: rgba(255, 255, 255, .072);
  --border-md: rgba(255, 255, 255, .13);
  --text: #ffffff;
  --text2: rgba(255, 255, 255, .88);
  --text3: rgba(255, 255, 255, .62);
  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, .11);
  --green-mid: #22c55e;
  --green-bd: rgba(74, 222, 128, .22);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, .11);
  --amber-mid: #f59e0b;
  --amber-bd: rgba(251, 191, 36, .22);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, .11);
  --red-mid: #ef4444;
  --red-bd: rgba(248, 113, 113, .22);
  --blue: #60a5fa;
  --blue-bg: rgba(96, 165, 250, .11);
  --blue-mid: #3b82f6;
  --blue-bd: rgba(96, 165, 250, .22);
  --cyan: #22d3ee;
  --cyan-bg: rgba(34, 211, 238, .10);
  --cyan-mid: #06b6d4;
  --cyan-bd: rgba(34, 211, 238, .22);
  --cyan-glow: rgba(6, 182, 212, .6);
  --sh-sm: 0 2px 10px rgba(0, 0, 0, .45);
  --sh-md: 0 4px 24px rgba(0, 0, 0, .55), 0 1px 4px rgba(0, 0, 0, .3);
  --sh-lg: 0 8px 40px rgba(0, 0, 0, .65), 0 2px 8px rgba(0, 0, 0, .4);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

html[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse 80% 50% at 15% -5%, rgba(255, 140, 0, .07) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 85% 105%, rgba(255, 80, 0, .05) 0%, transparent 50%);
}

/* ── Loading Overlay ────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #06060e 0%, #0e0a18 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 16px;
  transition: opacity .45s ease;
}

#loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.lo-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lo-logo-img {
  height: 40px;
  width: auto;
  filter: drop-shadow(0 0 14px rgba(255, 184, 0, .45));
}

.lo-logo-text {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.5px;
}

.lo-logo-text .accent {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid rgba(255, 255, 255, .08);
  border-top-color: #FFB800;
  border-radius: 50%;
  animation: spin .75s linear infinite;
  box-shadow: 0 0 14px rgba(255, 184, 0, .3);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#lo-progress {
  font-size: 12px;
  color: var(--text3);
  font-family: var(--mono);
  max-width: 380px;
  text-align: center;
  min-height: 18px;
  letter-spacing: .01em;
  transition: opacity .2s;
}

.lo-progress-bar {
  width: 260px;
  height: 3px;
  background: rgba(255, 255, 255, .07);
  border-radius: 2px;
  overflow: hidden;
}

.lo-progress-fill {
  height: 100%;
  background: var(--brand-grad);
  border-radius: 2px;
  transition: width .4s ease;
  width: 0%;
}

/* ── Token Modal ────────────────────────────────────────────────── */
#token-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(4, 4, 12, .85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#token-modal.show {
  display: flex;
}

.modal-card {
  background: rgba(14, 14, 24, .96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-md);
  border-radius: var(--r-xl);
  padding: 32px 36px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--sh-lg), 0 0 40px rgba(255, 140, 0, .07);
}

.modal-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.modal-card p {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 20px;
  line-height: 1.6;
}

#token-modal-msg {
  display: none;
  font-size: 12px;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid var(--red-bd);
  border-radius: var(--r);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.modal-input-wrap {
  margin-bottom: 18px;
}

#token-input {
  width: 100%;
  padding: 11px 14px;
  font-size: 13px;
  font-family: var(--mono);
  border: 1.5px solid var(--border-md);
  border-radius: var(--r);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}

#token-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 184, 0, .12);
}

#token-input::placeholder {
  color: var(--text3);
}

.modal-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: -12px;
  margin-bottom: 18px;
  line-height: 1.5;
}

.modal-hint a {
  color: var(--brand);
  text-decoration: none;
}

.modal-hint a:hover {
  text-decoration: underline;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn-primary {
  flex: 1;
  padding: 10px 20px;
  border-radius: var(--r);
  background: var(--brand-grad);
  color: #000;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity .15s, box-shadow .15s;
}

.btn-primary:hover {
  opacity: .88;
  box-shadow: 0 0 16px rgba(255, 184, 0, .35);
}

.btn-secondary {
  padding: 10px 20px;
  border-radius: var(--r);
  background: var(--surface2);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-md);
  cursor: pointer;
  font-family: var(--font);
  transition: background .15s;
}

.btn-secondary:hover {
  background: var(--surface);
}

/* ── Login Overlay ──────────────────────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #06060e 0%, #0e0a18 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 1;
  transition: opacity .45s ease;
}

#login-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.login-title {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -.3px;
  margin-top: 18px;
}

.login-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, .4);
  margin-top: 5px;
  letter-spacing: .6px;
  text-transform: uppercase;
  font-family: var(--mono);
}

.login-divider {
  width: 260px;
  height: 1px;
  background: rgba(255, 255, 255, .07);
  margin: 28px 0 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 280px;
  margin-top: 24px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.login-field label {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, .45);
  letter-spacing: .8px;
  text-transform: uppercase;
  font-family: var(--mono);
}

.login-field input {
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 8px;
  padding: 11px 14px;
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, background .2s, box-shadow .2s;
  width: 100%;
}

.login-field input::placeholder { color: rgba(255,255,255,.2); }

.login-field input:focus {
  border-color: rgba(255, 184, 0, .55);
  background: rgba(255, 184, 0, .05);
  box-shadow: 0 0 0 3px rgba(255, 184, 0, .08);
}

.login-pass-wrap {
  position: relative;
}

.login-pass-wrap input {
  width: 100%;
  padding-right: 40px;
}

.btn-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: rgba(255, 255, 255, .35);
  display: flex;
  align-items: center;
  transition: color .15s;
}

.btn-eye:hover { color: rgba(255, 255, 255, .75); }

.btn-eye svg {
  width: 15px;
  height: 15px;
}

.login-error {
  font-size: 12px;
  color: #f87171;
  text-align: center;
  padding: 9px 12px;
  background: rgba(248, 113, 113, .09);
  border: 1px solid rgba(248, 113, 113, .2);
  border-radius: 8px;
  font-family: var(--mono);
}

.login-btn {
  background: var(--brand-grad);
  border: none;
  border-radius: 8px;
  padding: 12px 0;
  color: #000;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .2px;
  transition: opacity .2s, transform .1s;
  margin-top: 4px;
  width: 100%;
}

.login-btn:hover:not(:disabled) { opacity: .86; }
.login-btn:active:not(:disabled) { transform: scale(.98); }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Top Bar ────────────────────────────────────────────────────── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 1);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  height: var(--topbar-h);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .5), 0 2px 20px rgba(0, 0, 0, .35);
  transition: background .25s;
}

html.scrolled .top-bar {
  background: rgba(0, 0, 0, .77);
}

.tb-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tb-logo-img {
  height: 30px;
  width: auto;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(255, 184, 0, .3));
}

.tb-logo {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.2px;
  white-space: nowrap;
}

.tb-logo .accent {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}


.tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

#tb-subtitle, #hdrSubtitle {
  font-size: 12px;
  color: var(--text3);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 100px;
  text-align: center;
  cursor: default;
}

.lu-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .07);
  padding: 5px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.lu-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-mid);
  animation: pulse 2.2s ease-in-out infinite;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(34, 197, 94, .6);
}

.lu-dot.offline {
  background: var(--red-mid);
  animation: none;
  box-shadow: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.85); }
}

.btn-topbar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r);
  background: #4f46e5;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #4f46e5;
  cursor: pointer;
  transition: all .15s;
  font-family: var(--font);
  letter-spacing: .01em;
}

.btn-topbar:hover {
  background: #4338ca;
  border-color: #4338ca;
  color: #fff;
  box-shadow: 0 0 12px rgba(79, 70, 229, .25);
}

html[data-theme="dark"] .btn-topbar {
  background: rgba(255, 184, 0, .08);
  color: #FFB800;
  border-color: rgba(255, 184, 0, .18);
}

html[data-theme="dark"] .btn-topbar:hover {
  background: rgba(255, 184, 0, .16);
  color: #FFD93D;
  border-color: rgba(255, 184, 0, .32);
  box-shadow: 0 0 12px rgba(255, 184, 0, .15);
}

.btn-topbar:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.btn-topbar svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.btn-topbar.spinning svg {
  animation: spin .7s linear infinite;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r);
  background: rgba(220, 38, 38, .07);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, .18);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: var(--font);
  letter-spacing: .01em;
}

.btn-logout svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  box-shadow: 0 0 12px rgba(220, 38, 38, .25);
}

html[data-theme="dark"] .btn-logout {
  background: rgba(248, 113, 113, .08);
  color: #f87171;
  border-color: rgba(248, 113, 113, .18);
}

html[data-theme="dark"] .btn-logout:hover {
  background: rgba(248, 113, 113, .18);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, .35);
  box-shadow: 0 0 12px rgba(248, 113, 113, .15);
}

.btn-settings {
  padding: 7px 10px;
}

/* ── Page ───────────────────────────────────────────────────────── */
.page {
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px 32px 25px;
}

.sec-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text3);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sec-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 184, 0, .18), rgba(255, 184, 0, .04) 25%, var(--border) 55%, transparent);
}

/* ── Error State ────────────────────────────────────────────────── */
#error-state {
  display: none;
  margin-bottom: 22px;
  background: var(--red-bg);
  border: 1px solid var(--red-bd);
  border-radius: var(--r-lg);
  padding: 20px 24px;
}

.err-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 6px;
}

#error-msg {
  font-size: 13px;
  color: var(--text2);
}

.btn-retry {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r);
  background: var(--red-mid);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity .15s;
}

.btn-retry:hover {
  opacity: .88;
}

.btn-retry svg {
  width: 12px;
  height: 12px;
}

/* ── KPI Grid ───────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--sh-sm);
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.kpi.k-purple::before { background: linear-gradient(90deg, #7c3aed, #c084fc); }
.kpi.k-indigo::before { background: linear-gradient(90deg, #4338ca, #818cf8); }
.kpi.k-blue::before   { background: linear-gradient(90deg, #1d4ed8, #60a5fa); }
.kpi.k-green::before  { background: linear-gradient(90deg, #15803d, #4ade80); }
.kpi.k-amber::before  { background: var(--brand-grad); }
.kpi.k-red::before    { background: linear-gradient(90deg, #b91c1c, #f87171); }

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
}

.kpi-val {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1.5px;
  color: var(--text);
  font-family: var(--mono);
}

.kpi-sub {
  font-size: 11px;
  color: var(--text2);
  margin-top: 6px;
}

/* ── Charts Grid ────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 2fr;
  gap: 14px;
  margin-bottom: 26px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--sh-sm);
  position: relative;
  overflow: hidden;
}

.cc-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 14px;
}

.chart-wrap {
  position: relative;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.lg-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text2);
}

.lg-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Portfolio Accordion ────────────────────────────────────────── */
.portfolio {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: var(--r-lg);
  margin-bottom: 10px;
  overflow: clip;
  box-shadow: var(--sh-sm);
  transition: box-shadow .15s, border-color .15s;
  position: relative;
}

.pf-hdr {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 20px;
  cursor: pointer;
  user-select: none;
  border-left: 4px solid transparent;
  transition: background .12s;
  position: sticky;
  top: var(--topbar-h);
  z-index: 0;
  background: var(--surface2);
  box-shadow: inset 0 -1px 0 var(--border);
}

.pf-hdr:hover {
  background: var(--surface3);
}

.pf-tower {
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 20px;
  white-space: nowrap;
  font-family: var(--mono);
  letter-spacing: .05em;
  flex-shrink: 0;
}

.pf-name-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.pf-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.pf-sub {
  font-size: 11px;
  color: var(--text3);
  font-weight: 400;
  line-height: 1.3;
}

html[data-theme="dark"] .pf-sub {
  color: rgba(255, 255, 255, .48);
}

.pf-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.pf-proj-count {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
  white-space: nowrap;
}

.ov-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--red);
  background: var(--red-bg);
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--red-bd);
  font-family: var(--mono);
  white-space: nowrap;
}

.rag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.rag-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rag-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.rag-green .dot { background: var(--green-mid); box-shadow: 0 0 5px rgba(34, 197, 94, .7); }

.rag-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-bd); }
.rag-amber .dot { background: var(--amber-mid); box-shadow: 0 0 5px rgba(245, 158, 11, .7); }

.rag-red { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-bd); }
.rag-red .dot { background: var(--red-mid); box-shadow: 0 0 5px rgba(239, 68, 68, .7); }

.rag-blue { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-bd); }
.rag-blue .dot { background: var(--blue-mid); box-shadow: 0 0 5px rgba(59, 130, 246, .7); }

.pf-prog-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 120px;
}

.mini-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, .07);
  border-radius: 2px;
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  border-radius: 2px;
}

.pf-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  font-family: var(--mono);
  white-space: nowrap;
}

.chevron {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text3);
  font-size: 22px;
  flex-shrink: 0;
  transition: transform .22s ease, background .12s;
}

.pf-hdr:hover .chevron {
  background: rgba(255, 255, 255, .07);
}

.chevron.open {
  transform: rotate(90deg);
}

.pf-body {
  border-top: 1px solid var(--border);
}

.pf-body.hidden {
  display: none;
}

/* ── Project Table ──────────────────────────────────────────────── */
.proj-table {
  width: 100%;
  border-collapse: collapse;
}

.proj-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text3);
  padding: 10px 18px 10px 6px;
  text-align: left;
  background: var(--surface2);
  box-shadow: inset 0 -1px 0 var(--border);
  white-space: nowrap;
  position: sticky;
  top: var(--sticky-table-top);
  z-index: 12;
}

.proj-table td {
  padding: 14px 18px 14px 6px;
  vertical-align: middle;
  font-size: 13px;
  border-bottom: none;
}

.proj-row > td {
  background: var(--surface);
}

.proj-row:hover > td {
  background: var(--surface2);
}

.proj-row > td:first-child {
  border-left: 3px solid transparent;
}

.rag-main-on_track > td:first-child  { border-left-color: var(--green); }
.rag-main-at_risk > td:first-child   { border-left-color: var(--amber); }
.rag-main-off_track > td:first-child { border-left-color: var(--red); }

.sub-row.last-sub > td {
  border-bottom: 10px solid var(--bg);
}

.proj-link {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.proj-link:hover {
  color: var(--brand);
  text-decoration: underline;
}

.model-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  font-family: var(--mono);
  white-space: nowrap;
}

.model-tag.scrum  { background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; }
.model-tag.kanban { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

html[data-theme="dark"] .model-tag.scrum  { background: rgba(139, 92, 246, .15); color: #c4b5fd; border-color: rgba(139, 92, 246, .25); }
html[data-theme="dark"] .model-tag.kanban { background: rgba(34, 197, 94, .12); color: #4ade80; border-color: rgba(34, 197, 94, .22); }

.dim-dash {
  color: var(--text3);
  font-size: 13px;
}

.bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-track {
  width: 72px;
  height: 5px;
  background: rgba(255, 255, 255, .07);
  border-radius: 3px;
  flex-shrink: 0;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
}

.bar-lbl {
  font-size: 11px;
  color: var(--text2);
  font-family: var(--mono);
  min-width: 36px;
}

.mc           { font-size: 12px; font-family: var(--mono); color: var(--text2); }
.mc.done      { color: var(--green); font-weight: 600; }
.mc.rem       { color: var(--amber); }
.mc.ov        { color: var(--red); font-weight: 700; }
.mc.none      { color: var(--text3); }
.mc.over-date { color: var(--red); font-weight: 600; }

.sub-row td {
  padding: 0;
  border-bottom: none;
}

.sub-row.last-sub td {
  border-bottom: 2px solid rgba(255, 255, 255, .07);
}

.sections-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px;
  background: var(--surface2);
  align-items: center;
}

.pipe-lbl {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-right: 4px;
  white-space: nowrap;
}

.sec-chip {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-md);
  background: var(--surface);
  color: var(--text2);
}

.sec-chip.active { background: var(--blue-bg);  color: var(--blue);  border-color: var(--blue-bd);  font-weight: 600; }
.sec-chip.done   { background: var(--green-bg); color: var(--green); border-color: var(--green-bd); font-weight: 600; }

.assignees-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 14px;
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
}

tbody tr:last-child .assignees-row {
  border-bottom: 0;
}

tbody tr:last-child > td {
  border-bottom: 0 !important;
}

.team-lbl {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}

.assignee-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.a-pill {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  color: var(--text2);
}

.a-pill.more {
  background: var(--brand-lt);
  color: var(--brand);
  border: 1px solid rgba(255, 184, 0, .22);
  font-weight: 600;
}

/* ── Resource Utilization ───────────────────────────────────────── */
.res-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: rgba(255, 255, 255);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: sticky;
  top: var(--sticky-table-top);
  z-index: 12;
}

.res-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
}

.res-date-input {
  padding: 7px 10px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--r);
  font-size: 12px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  cursor: pointer;
  color-scheme: light;
}

.res-date-input::-webkit-calendar-picker-indicator { cursor: pointer; }

.res-date-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 184, 0, .10);
}

.res-btn {
  padding: 7px 18px;
  border-radius: var(--r);
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity .15s;
}

.res-btn-apply {
  background: #4f46e5;
  color: #fff;
  font-weight: 700;
}

.res-btn-apply:hover {
  background: #4338ca;
}

.res-btn-clear {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border-md);
  transition: background .15s;
}

.res-btn-clear:hover {
  background: rgba(15, 23, 42, .05);
}

html[data-theme="dark"] .res-btn-apply         { background: var(--brand-grad); color: #000; }
html[data-theme="dark"] .res-btn-apply:hover   { background: var(--brand-grad); opacity: .85; }
html[data-theme="dark"] .res-btn-clear:hover   { background: rgba(255, 255, 255, .09); }

.res-table {
  width: 100%;
  border-collapse: collapse;
}

.res-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text3);
  padding: 10px 18px;
  text-align: left;
  background: var(--surface2);
  box-shadow: inset 0 -1px 0 var(--border);
  white-space: nowrap;
  position: sticky;
  top: calc(var(--sticky-table-top) + var(--res-controls-h));
  z-index: 11;
}

.res-table td {
  padding: 12px 18px;
  vertical-align: middle;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.res-table tbody tr:hover td {
  background: rgba(255, 255, 255, .03);
}

.res-name-cell {
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, .025) !important;
  border-right: 2px solid var(--border-md) !important;
  vertical-align: middle;
}

.res-total-cell {
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, .025) !important;
  border-left: 2px solid var(--border-md) !important;
  vertical-align: middle;
  text-align: center;
  padding-right: 12px;
}

.res-empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  font-style: italic;
}

.res-loading-wrap {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 20px;
  color: var(--text3);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.res-load-spin {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-md);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

.res-btn-download {
  background: #4f46e5;
  color: #fff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.res-btn-download:hover:not(:disabled) {
  background: #4338ca;
  opacity: 1;
}

.res-btn-download:disabled {
  opacity: .35;
  cursor: not-allowed;
}

html[data-theme="dark"] .res-btn-download                    { background: var(--brand-grad); color: #000; }
html[data-theme="dark"] .res-btn-download:hover:not(:disabled) { opacity: .85; background: var(--brand-grad); }

.res-btn-download svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* ── Resource Availability ──────────────────────────────────────── */
.avail-table {
  width: 100%;
  border-collapse: collapse;
}

.avail-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text3);
  padding: 10px 18px;
  text-align: left;
  background: var(--surface2);
  box-shadow: inset 0 -1px 0 var(--border);
  white-space: nowrap;
  position: sticky;
  top: var(--sticky-table-top);
  z-index: 11;
}

.avail-table td {
  padding: 11px 18px;
  vertical-align: middle;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.avail-table tbody tr:hover td {
  background: rgba(255, 255, 255, .03);
}

.avail-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}

.avail-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.avail-badge.assigned  { background: rgba(249, 115, 22, .12); color: #fb923c; border: 1px solid rgba(249, 115, 22, .25); }
.avail-badge.assigned::before  { background: #f97316; box-shadow: 0 0 5px rgba(249, 115, 22, .6); }

.avail-badge.available { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.avail-badge.available::before { background: var(--green-mid); box-shadow: 0 0 5px rgba(34, 197, 94, .6); }

.avail-badge.notask { background: var(--cyan-bg); color: var(--cyan); border: 1px solid var(--cyan-bd); }
.avail-badge.notask::before { background: var(--cyan-mid); box-shadow: 0 0 5px var(--cyan-glow); }

.avail-note {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
}

.avail-from {
  font-weight: 600;
  color: var(--text);
}

.avail-from.immediate {
  color: var(--green);
}

.avail-empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  font-style: italic;
}

/* ── Footer ─────────────────────────────────────────────────────── */
.dash-footer {
  margin-top: 25px;
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.dash-footer .sep {
  color: var(--border-md);
}

/* ── Clean Card Interactions ─────────────────────────────────── */
.kpi:hover,
.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .55);
}

html:not([data-theme="dark"]) .kpi:hover,
html:not([data-theme="dark"]) .chart-card:hover {
  box-shadow: var(--sh-md);
}

html:not([data-theme="dark"]) .portfolio       { border: none; }
html:not([data-theme="dark"]) .portfolio:hover { box-shadow: 0 4px 14px rgba(15, 23, 42, .10); }

.portfolio:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .55);
}

/* ── Animations ─────────────────────────────────────────────────── */
.fade-in {
  animation: fadeIn .35s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .charts-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid .chart-card:first-child { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
  .top-bar, .page { padding-left: 16px; padding-right: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  #tb-subtitle, #hdrSubtitle { display: none; }
}

@media (max-width: 600px) {
  .top-bar {
    --topbar-h: 82px;
    padding: 8px 12px;
    height: auto;
    flex-wrap: wrap;
    gap: 6px;
    align-content: center;
  }
  .tb-logo-img { height: 24px; }
  .tb-right { flex-wrap: wrap; }
  .lu-pill {
    order: 10;
    flex-basis: 100%;
    justify-content: center;
    margin-top: 2px;
  }
  .btn-label { display: none; }
  .btn-topbar, .btn-logout { padding: 7px 10px; }
}

@media print {
  .top-bar, .btn-topbar { display: none !important; }
  body { background: #fff; }
  .pf-body { display: block !important; }
  .chevron { display: none; }
}

/* ── Dark Theme Component Overrides ─────────────────────────── */
html[data-theme="dark"] .pf-hdr       { background: #1a1a1a; }
html[data-theme="dark"] .pf-hdr:hover { background: #222222; }

html[data-theme="dark"] .proj-row > td       { background: #131313; }
html[data-theme="dark"] .proj-row:hover > td { background: #1c1c1c; }

html[data-theme="dark"] .sections-row  { background: #1a1a1a; border-top-color: rgba(255, 255, 255, .04); }
html[data-theme="dark"] .assignees-row { background: #1a1a1a; }

html[data-theme="dark"] .sec-chip { background: rgba(255, 255, 255, .06); color: rgba(255, 255, 255, .85); border-color: rgba(255, 255, 255, .14); }
html[data-theme="dark"] .a-pill   { background: rgba(255, 255, 255, .05); color: rgba(255, 255, 255, .75); border-color: rgba(255, 255, 255, .12); }
html[data-theme="dark"] .a-pill.more { background: rgba(255, 184, 0, .10); color: #FFB800; border-color: rgba(255, 184, 0, .22); }

html[data-theme="dark"] .pf-body { border-top-color: rgba(255, 255, 255, .072); }

html[data-theme="dark"] .portfolio {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-theme="dark"] .res-controls { background: rgba(0, 0, 0, .88); }


html[data-theme="dark"] .res-date-input { background: rgba(255, 255, 255, .05); color: #fff; color-scheme: dark; }
html[data-theme="dark"] .res-btn-clear  { background: rgba(255, 255, 255, .05); color: rgba(255, 255, 255, .88); border-color: rgba(255, 255, 255, .13); }

html[data-theme="dark"] .modal-card { background: rgba(14, 14, 24, .96); backdrop-filter: blur(20px); }

html[data-theme="dark"] .mini-bar  { background: rgba(255, 255, 255, .07); }
html[data-theme="dark"] .bar-track { background: rgba(255, 255, 255, .07); }

html[data-theme="dark"] .sec-label::after { background: linear-gradient(90deg, rgba(255, 184, 0, .18), rgba(255, 184, 0, .04) 25%, rgba(255, 255, 255, .07) 55%, transparent); }

html[data-theme="dark"] .top-bar          { background: rgba(8, 8, 18, .65); border-bottom-color: rgba(255, 255, 255, .07); }
html[data-theme="dark"] #loading-overlay  { background: linear-gradient(135deg, #06060e 0%, #0e0a18 100%); }

/* ── Theme Toggle Button ─────────────────────────────────────── */
.btn-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--r);
  border: 1px solid rgba(255, 255, 255, .07);
  background: rgba(79, 70, 229, .1);
  color: var(--text3);
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}

.btn-theme:hover {
  background: rgba(79, 70, 229, .18);
  border-color: rgba(79, 70, 229, .5);
}

html[data-theme="dark"] .btn-theme       { background: rgba(255, 184, 0, .08); color: #FFB800; border-color: rgba(255, 184, 0, .18); }
html[data-theme="dark"] .btn-theme:hover { background: rgba(255, 184, 0, .18); border-color: rgba(255, 184, 0, .34); }

.btn-theme svg {
  width: 16px;
  height: 16px;
  transition: opacity .2s;
}
