/* ==========================================================================
   SD Manager — Design tokens, layout and components
   Mobile-first. Light theme on :root, dark theme on [data-theme="dark"].
   ========================================================================== */

:root {
  /* Brand */
  --navy-950: #070f1d;
  --navy-900: #0b1b33;
  --navy-800: #12284a;
  --navy-700: #1b3763;
  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;

  /* Surfaces & text (light) */
  --bg: #f3f6fa;
  --bg-glow: radial-gradient(1200px 600px at 100% -10%, rgb(20 184 166 / 0.08), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-hover: #eef3f8;
  --border: #e2e8f0;
  --border-strong: #cfd8e3;
  --text: #0f1b2d;
  --text-2: #3b4b61;
  --text-muted: #64748b;

  --accent: var(--teal-600);
  --accent-strong: var(--teal-700);
  --accent-text: var(--teal-700);
  --accent-soft: #e3f6f3;
  --on-accent: #ffffff;
  --focus: #0ea5a0;

  /* Sidebar stays navy in both themes */
  --sidebar-bg: linear-gradient(180deg, var(--navy-900) 0%, #0a1830 100%);
  --sidebar-text: #c6d2e3;
  --sidebar-muted: #7f92ad;
  --sidebar-hover: rgb(255 255 255 / 0.06);
  --sidebar-active: rgb(45 212 191 / 0.14);

  /* Status */
  --success: #15803d;
  --success-soft: #e7f6ec;
  --warning: #a16207;
  --warning-soft: #fdf4e1;
  --info: #1d4ed8;
  --info-soft: #e8efff;

  /* Stat icon chips */
  --chip-teal: #e3f6f3;   --chip-teal-fg: var(--teal-700);
  --chip-navy: #e6ecf6;   --chip-navy-fg: var(--navy-700);
  --chip-amber: #fdf1dc;  --chip-amber-fg: #a16207;
  --chip-sky: #e3f1fb;    --chip-sky-fg: #0369a1;

  /* Shape & depth */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgb(15 27 45 / 0.05);
  --shadow: 0 1px 2px rgb(15 27 45 / 0.04), 0 4px 16px -4px rgb(15 27 45 / 0.08);
  --shadow-lg: 0 2px 4px rgb(15 27 45 / 0.04), 0 16px 40px -12px rgb(15 27 45 / 0.18);

  /* Type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", var(--font-sans);

  /* Layout */
  --sidebar-w: 268px;
  --topbar-h: 64px;
  --bottom-nav-h: 68px;
  --gutter: 16px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #08111f;
  --bg-glow: radial-gradient(1200px 600px at 100% -10%, rgb(45 212 191 / 0.07), transparent 60%);
  --surface: #0f1b2e;
  --surface-2: #132238;
  --surface-hover: #182a44;
  --border: #1f3150;
  --border-strong: #2a4066;
  --text: #e8eef7;
  --text-2: #bccadc;
  --text-muted: #8fa1b9;

  --accent: var(--teal-400);
  --accent-strong: var(--teal-300);
  --accent-text: var(--teal-300);
  --accent-soft: rgb(45 212 191 / 0.12);
  --on-accent: #052e2a;
  --focus: var(--teal-300);

  --sidebar-bg: linear-gradient(180deg, #091526 0%, var(--navy-950) 100%);

  --success: #4ade80;
  --success-soft: rgb(74 222 128 / 0.12);
  --warning: #fbbf24;
  --warning-soft: rgb(251 191 36 / 0.12);
  --info: #93b4ff;
  --info-soft: rgb(147 180 255 / 0.13);

  --chip-teal: rgb(45 212 191 / 0.13);   --chip-teal-fg: var(--teal-300);
  --chip-navy: rgb(147 180 255 / 0.13);  --chip-navy-fg: #a9c1ff;
  --chip-amber: rgb(251 191 36 / 0.13);  --chip-amber-fg: #fcd34d;
  --chip-sky: rgb(56 189 248 / 0.13);    --chip-sky-fg: #7dd3fc;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.25), 0 6px 20px -6px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 2px 4px rgb(0 0 0 / 0.3), 0 20px 48px -12px rgb(0 0 0 / 0.6);

  color-scheme: dark;
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

h1, h2, h3, p, ul, dl, dd {
  margin: 0;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform 0.2s var(--ease);
}

.skip-link:focus {
  transform: none;
}

.noscript {
  padding: 24px;
  text-align: center;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--xs {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}

/* ---------- App shell ---------- */

.app {
  min-height: 100dvh;
}

.sidebar {
  display: none;
}

.main {
  min-width: 0;
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}

.content {
  width: 100%;
  max-width: 1320px;
  margin-inline: auto;
  padding: 20px var(--gutter) 32px;
  outline: none;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--teal-400), var(--teal-600) 55%, var(--navy-700));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 16px -6px rgb(20 184 166 / 0.6), inset 0 1px 0 rgb(255 255 255 / 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 12px;
  color: var(--sidebar-muted);
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--topbar-h);
  padding-block: calc(8px + env(safe-area-inset-top, 0px)) 8px;
  /* Line the top bar up with the centered content column on wide screens. */
  padding-inline: max(var(--gutter), calc((100% - 1320px) / 2 + var(--gutter)));
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand--compact {
  flex: none;
  border-radius: 12px;
}

.brand--compact .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  font-size: 13px;
}

.brand--compact .brand-name {
  display: none;
}

.topbar-crumb {
  display: none;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.topbar-crumb .icon {
  opacity: 0.6;
}

.topbar-crumb-current {
  font-weight: 650;
  color: var(--text);
}

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

/* On mobile the profile switcher sits beside the logo; icon buttons stay right. */
.profile-switcher {
  order: -1;
  min-width: 0;
  margin-right: auto;
}

.icon-btn.header-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.icon-btn.header-btn[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* Profile trigger */
.profile-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px 0 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.profile-trigger:hover {
  border-color: var(--border-strong);
}

.profile-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.profile-trigger:focus-visible {
  border-radius: 999px;
}

.profile-trigger-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.profile-trigger-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-trigger-sub {
  display: none;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-muted);
}

.profile-trigger-caret {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s var(--ease);
}

.profile-trigger[aria-expanded="true"] .profile-trigger-caret {
  transform: rotate(180deg);
}

.avatar {
  --avatar-hue: 174;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(var(--avatar-hue) 70% 42%), hsl(calc(var(--avatar-hue) + 30) 60% 30%));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Popovers (profile menu, notifications).
   Mobile: span the top bar width. ≥640px: anchored under their trigger. */
.popover {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline: 12px;
  z-index: 40;
  max-height: calc(100dvh - var(--topbar-h) - var(--bottom-nav-h) - 24px);
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform-origin: top center;
  animation: popover-in 0.18s var(--ease);
}

@keyframes popover-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 10px;
}

.popover-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-2);
}

.popover-foot {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 6px 2px 0;
  padding: 10px 8px 4px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.popover-foot .icon {
  margin-top: 2px;
}

.profile-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
  transition: background-color 0.15s;
}

.profile-option:hover {
  background: var(--surface-hover);
}

.profile-option:focus-visible {
  outline-offset: -2px;
  border-radius: 12px;
}

.profile-option[aria-checked="true"] {
  background: var(--accent-soft);
}

.profile-option .avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.profile-option-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.profile-option-name {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.profile-option-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.profile-option-check {
  color: var(--accent-text);
  visibility: hidden;
}

.profile-option[aria-checked="true"] .profile-option-check {
  visibility: visible;
}

.notice-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 20px;
  text-align: center;
}

.notice-empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.notice-empty-title {
  font-weight: 700;
}

.notice-empty-text {
  max-width: 34ch;
  font-size: 13px;
  color: var(--text-muted);
}

/* Buttons */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.96);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn--sm {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}

.btn--primary:hover {
  background: var(--accent-strong);
}

.btn--ghost {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text-2);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-text);
}

.link-btn .icon {
  width: 15px;
  height: 15px;
  transition: transform 0.15s var(--ease);
}

.link-btn:hover .icon {
  transform: translateX(2px);
}

/* Theme toggle icons */
[data-theme="dark"] [data-theme-toggle] .icon-moon,
:root:not([data-theme="dark"]) [data-theme-toggle] .icon-sun {
  display: none;
}

/* ---------- Bottom navigation (mobile) ---------- */

.bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 30;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--border);
}

.bottom-nav ul {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 560px;
  margin-inline: auto;
}

.tab-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  padding: 8px 2px 6px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.15s;
}

.tab-link span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-link .icon {
  width: 22px;
  height: 22px;
}

.tab-link::before {
  content: "";
  position: absolute;
  top: 2px;
  width: 44px;
  height: 30px;
  border-radius: 999px;
  background: var(--accent-soft);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  z-index: -1;
}

.tab-link[aria-current="page"],
.tab-link.is-active {
  color: var(--accent-text);
}

.tab-link[aria-current="page"]::before,
.tab-link.is-active::before {
  opacity: 1;
  transform: none;
}

/* "More" sheet */
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 85dvh;
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.sheet[open] {
  animation: sheet-in 0.28s var(--ease);
}

.sheet::backdrop {
  background: rgb(7 15 29 / 0.5);
  backdrop-filter: blur(2px);
}

@keyframes sheet-in {
  from { transform: translateY(24px); opacity: 0; }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
}

.sheet-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.sheet-nav {
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px));
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.sheet-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--text-2);
  transition: background-color 0.15s, border-color 0.15s;
}

.sheet-link .icon {
  width: 22px;
  height: 22px;
  color: var(--accent-text);
}

.sheet-link:hover {
  background: var(--surface-hover);
}

.sheet-link[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ---------- Page header ---------- */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 32px);
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.page-subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--text-muted);
}

.page-subtitle strong {
  color: var(--text-2);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tag--demo {
  background: var(--warning-soft);
  color: var(--warning);
}

/* Local emulator (test data) — matches the emulator sign-in note and sidebar pill.
   Light text is a darker green than --success so the 11px label stays above 4.5:1. */
.tag--emulator {
  background: var(--success-soft);
  color: #166534;
}

[data-theme="dark"] .tag--emulator {
  color: var(--success);
}

/* Live workspace, read-only (profile menu). */
.tag--readonly {
  background: var(--surface-hover);
  color: var(--text-2);
}

.tag--soon {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* Month picker */
.month-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.month-picker .icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 11px;
  box-shadow: none;
  background: transparent;
}

.month-picker-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 150px;
  justify-content: center;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.month-picker-label .icon {
  width: 17px;
  height: 17px;
  color: var(--accent-text);
}

.month-picker .btn {
  margin-left: 2px;
  border-radius: 11px;
}

/* Demo banner */
.demo-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--warning) 28%, transparent);
  border-radius: var(--radius);
  background: var(--warning-soft);
  color: var(--text-2);
  font-size: 13.5px;
}

.demo-banner .icon {
  margin-top: 1px;
  color: var(--warning);
}

.demo-banner strong {
  color: var(--text);
}

/* ---------- Cards ---------- */

.card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-subtitle {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

.stat-icon--teal  { background: var(--chip-teal);  color: var(--chip-teal-fg); }
.stat-icon--navy  { background: var(--chip-navy);  color: var(--chip-navy-fg); }
.stat-icon--amber { background: var(--chip-amber); color: var(--chip-amber-fg); }
.stat-icon--sky   { background: var(--chip-sky);   color: var(--chip-sky-fg); }

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-value {
  margin-top: 2px;
  font-family: var(--font-display);
  font-size: clamp(20px, 5.4vw, 28px);
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat-unit {
  margin-left: 2px;
  font-size: 0.6em;
  font-weight: 650;
  color: var(--text-muted);
}

.stat-meta {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Dashboard grid */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

/* Events */
.event-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  margin-inline: -10px;
  border-radius: var(--radius);
  transition: background-color 0.15s;
}

.event-row:hover {
  background: var(--surface-2);
}

.date-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 54px;
  flex: none;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-text);
  line-height: 1.1;
}

.date-tile-day {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.date-tile-num {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
}

.event-body {
  min-width: 0;
}

.event-title {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
}

.dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}

/* Budget ring */
.card--budget {
  display: flex;
  flex-direction: column;
}

.budget {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
}

.ring {
  position: relative;
  width: 128px;
  height: 128px;
  flex: none;
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 10;
}

.ring-track {
  stroke: var(--surface-hover);
}

.ring-value {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dasharray 0.6s var(--ease);
}

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}

.ring-pct {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.ring-caption {
  font-size: 12px;
  color: var(--text-muted);
}

.kv-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.kv-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.kv-list dt {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  white-space: nowrap;
}

.kv-list dd {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.kv-total {
  padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
}

.kv-list--inline {
  flex-direction: row;
  gap: 24px;
  margin-top: 14px;
}

.kv-list--inline > div {
  flex-direction: column;
  gap: 0;
}

.kv-list--inline dt {
  font-size: 12.5px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.swatch--accent { background: var(--accent); }
.swatch--track  { background: var(--surface-hover); box-shadow: inset 0 0 0 1px var(--border-strong); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--info    { background: var(--info-soft);    color: var(--info); }

/* Reimbursement rows */
.tx-list > li + li {
  border-top: 1px solid var(--border);
}

.tx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}

.tx-row:first-child {
  padding-top: 0;
}

.tx-row:last-child {
  padding-bottom: 0;
}

.tx-body {
  min-width: 0;
}

.tx-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.tx-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.tx-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Metrics & progress */
.metric {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.metric-of {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
}

.metric-foot {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.progress {
  height: 10px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--surface-hover);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-500), var(--accent));
  transition: width 0.6s var(--ease);
}

/* Quick links */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s var(--ease);
}

.quick-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  transform: translateY(-1px);
}

.quick-link-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm);
}

.quick-link-icon .icon {
  width: 18px;
  height: 18px;
}

/* Empty / placeholder state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 640px;
  margin-inline: auto;
  padding: 40px 20px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.empty-icon .icon {
  width: 30px;
  height: 30px;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 750;
}

.empty-text {
  max-width: 44ch;
  color: var(--text-muted);
}

.planned-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 12px;
  text-align: left;
}

.planned-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
}

.planned-list .icon {
  padding: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ---------- Sidebar (desktop) ---------- */

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 28px;
  flex: 1;
  overflow-y: auto;
}

.nav-group-label {
  margin: 0 12px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

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

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--sidebar-text);
  font-weight: 550;
  transition: background-color 0.15s, color 0.15s;
}

.nav-link .icon {
  color: var(--sidebar-muted);
  transition: color 0.15s;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-link[aria-current="page"] {
  background: var(--sidebar-active);
  color: #fff;
}

.nav-link[aria-current="page"] .icon {
  color: var(--teal-300);
}

.nav-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--teal-400);
}

.sidebar :focus-visible {
  outline-color: var(--teal-300);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid rgb(255 255 255 / 0.08);
}

.demo-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgb(251 191 36 / 0.1);
  color: #fcd34d;
  font-size: 12px;
  font-weight: 600;
}

.demo-pill .icon {
  width: 16px;
  height: 16px;
}

.theme-toggle--sidebar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.04);
  color: var(--sidebar-text);
  font-weight: 550;
  text-align: left;
  transition: background-color 0.15s, color 0.15s;
}

.theme-toggle--sidebar:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

/* ---------- Responsive ---------- */

/* Small phones: tighten the trigger so typical names fit without truncating. */
@media (max-width: 439px) {
  .topbar {
    gap: 8px;
  }

  .profile-trigger {
    gap: 7px;
    padding-right: 9px;
  }

  .profile-trigger .avatar {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .profile-trigger-name {
    font-size: 13.5px;
  }

  .profile-trigger-caret {
    width: 14px;
    height: 14px;
  }
}

/* Very narrow phones: the profile trigger collapses to avatar + caret.
   The full name stays in the trigger's accessible label and the menu. */
@media (max-width: 359px) {
  .profile-trigger {
    gap: 4px;
    padding-right: 8px;
  }

  .profile-trigger-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (min-width: 640px) {
  :root {
    --gutter: 24px;
  }

  .content {
    padding-top: 28px;
  }

  .card {
    padding: 22px;
  }

  .stat-card {
    flex-direction: row;
    align-items: flex-start;
    padding: 20px;
  }

  .stat-icon {
    width: 44px;
    height: 44px;
  }

  .topbar {
    gap: 14px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .brand--compact .brand-name {
    display: inline;
  }

  .profile-trigger {
    height: 48px;
    padding-right: 14px;
  }

  .profile-trigger-sub {
    display: block;
  }

  .popover-anchor {
    position: relative;
  }

  .popover {
    inset-inline: auto;
    right: 0;
    top: calc(100% + 10px);
    width: 340px;
    transform-origin: top right;
  }

  .profile-switcher .popover {
    right: auto;
    left: 0;
    width: 320px;
    transform-origin: top left;
  }

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

  .card--upcoming,
  .card--reimbursements {
    grid-column: span 2;
  }
}

@media (min-width: 960px) {
  :root {
    --gutter: 32px;
  }

  .app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    padding: 24px 14px 20px;
    background: var(--sidebar-bg);
    color: #fff;
    border-right: 1px solid rgb(255 255 255 / 0.04);
  }

  .sidebar .brand {
    padding: 0 8px;
  }

  .bottom-nav,
  .topbar .brand--compact,
  .theme-toggle--topbar {
    display: none;
  }

  .main {
    padding-bottom: 0;
  }

  :root {
    --topbar-h: 72px;
  }

  .topbar-crumb {
    display: flex;
  }

  /* Desktop order: crumb … notifications · profile (theme toggle lives in the sidebar). */
  .profile-switcher {
    order: 0;
    margin-right: 0;
    margin-left: 4px;
  }

  .profile-switcher .popover {
    right: 0;
    left: auto;
    transform-origin: top right;
  }
}

@media (min-width: 1200px) {
  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
  }

  .dash-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
  }

  .card--upcoming {
    grid-column: span 2;
  }

  /* Reimbursements sits beside a stacked ComHab + E-ZPass column. */
  .card--reimbursements {
    grid-column: span 2;
    grid-row: span 2;
  }

  .card--quick {
    grid-column: 1 / -1;
  }

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

  .quick-link {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 400px) {
  .month-picker {
    width: 100%;
  }

  .month-picker-label {
    flex: 1;
    min-width: 0;
  }

  .budget {
    flex-direction: column;
    align-items: stretch;
  }

  .ring {
    margin-inline: auto;
  }
}

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