/* The Future Phases admin theme
   Dark mode is the default. Light mode is [data-theme="light"].
   Brand blue is for logos, icons and large text.
   Primary buttons use #4058F2 so white text stays readable. */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --brand-blue: #5170ff;
  --brand-purple: #8c52ff;
  --brand-blue-light: #7d92ff;
  --brand-purple-light: #a57bff;
  --brand-gradient: linear-gradient(135deg, #5170ff 0%, #8c52ff 100%);
  --btn-primary: #4058f2;
  --btn-primary-hover: #3349dc;
  --cta-gradient: linear-gradient(135deg, #4058f2 0%, #7b3ff2 100%);
  --bg: #070714;
  --sidebar: #0b0c1f;
  --card: #11132b;
  --elevated: #181a38;
  --input: #0d0e1f;
  --border: #23264a;
  --row-hover: #1e2148;
  --text: #f4f5ff;
  --text-secondary: #b9bcd8;
  --text-muted: #8e92b4;
  --link: #7d92ff;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #ff6b8b;
  --info: #7d92ff;
  --success-bg: rgba(52, 211, 153, 0.14);
  --warning-bg: rgba(251, 191, 36, 0.14);
  --danger-bg: rgba(255, 107, 139, 0.14);
  --info-bg: rgba(125, 146, 255, 0.14);
  --brand-bg: rgba(140, 82, 255, 0.16);
  --badge-brand: #a57bff;
  --nav-active: rgba(81, 112, 255, 0.14);
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  --overlay: rgba(7, 7, 20, 0.72);
  --sidebar-width: 248px;
  --sidebar-collapsed: 72px;
  --sidebar-current: var(--sidebar-width);
  --topbar-height: 64px;
  --font-display: "Space Grotesk", "Avenir Next", sans-serif;
  --font-ui: "Inter", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius-badge: 6px;
  --radius-control: 10px;
  --radius-card: 14px;
  --radius-modal: 20px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7fb;
  --sidebar: #ffffff;
  --card: #ffffff;
  --elevated: #ffffff;
  --input: #ffffff;
  --border: #e4e6f0;
  --row-hover: #f3f4fb;
  --text: #0b0b1a;
  --text-secondary: #4a4a5e;
  --text-muted: #6b6f86;
  --link: #4058f2;
  --success: #059669;
  --warning: #d97706;
  --danger: #e11d48;
  --info: #4058f2;
  --success-bg: rgba(5, 150, 105, 0.12);
  --warning-bg: rgba(217, 119, 6, 0.12);
  --danger-bg: rgba(225, 29, 72, 0.1);
  --info-bg: rgba(64, 88, 242, 0.1);
  --brand-bg: rgba(140, 82, 255, 0.12);
  --badge-brand: #8c52ff;
  --nav-active: rgba(64, 88, 242, 0.1);
  --shadow: 0 16px 40px rgba(11, 11, 26, 0.08);
  --overlay: rgba(11, 11, 26, 0.4);
}

html.is-collapsed {
  --sidebar-current: var(--sidebar-collapsed);
}

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

html, body { min-height: 100%; }

body,
h1, h2, h3, p, ul, ol, figure { margin: 0; }

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

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

button { cursor: pointer; }

img { display: block; max-width: 100%; }

a { color: var(--link); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(81, 112, 255, 0.35);
  color: #fff;
}

[data-theme="light"] ::selection {
  background: rgba(64, 88, 242, 0.2);
  color: #0b0b1a;
}

:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible { outline: none; }

h1, h2, h3, .stat-value, .brand strong, .ring strong, .day strong {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

h1 { font-size: 24px; line-height: 32px; font-weight: 700; }
h2 { font-size: 20px; line-height: 28px; font-weight: 600; }
h3 { font-size: 16px; line-height: 24px; font-weight: 600; }

.skip {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 80;
  background: var(--card);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-control);
}

.skip:focus { top: 16px; }

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

.sidebar {
  width: var(--sidebar-current);
  height: 100vh;
  position: sticky;
  top: 0;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  z-index: 30;
  transition: width 0.2s ease;
}

.brand {
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}

.brand img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }

.brand strong {
  display: block;
  font-size: 14px;
  line-height: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand span {
  display: block;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0;
}

.nav {
  flex: 1;
  overflow: auto;
  padding: 8px 12px 16px;
}

.nav-section {
  margin: 16px 12px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-link {
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-link:hover,
.nav-link.is-active {
  background: var(--nav-active);
  color: var(--text);
}

.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 99px;
  background: var(--brand-gradient);
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.side-user-text { min-width: 0; }
.side-user-text strong,
.side-user-text span { display: block; }
.side-user-text strong {
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-user-text span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
}

html.is-collapsed .brand { justify-content: center; padding: 12px 0; }
html.is-collapsed .brand-text,
html.is-collapsed .nav-label,
html.is-collapsed .nav-section,
html.is-collapsed .side-user-text { display: none; }
html.is-collapsed .nav-link { justify-content: center; padding: 0; }
html.is-collapsed .collapse-toggle .icon { transform: rotate(180deg); }
html.is-collapsed .side-user { justify-content: center; padding: 8px 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}

.today-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.search {
  margin-left: auto;
  position: relative;
  width: min(320px, 36vw);
}

.search .kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  height: 20px;
  display: flex;
  align-items: center;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-badge);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  pointer-events: none;
}

.top-tools { display: flex; align-items: center; gap: 8px; }

.currency-switch {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 4px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--input);
}

.currency-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  line-height: 16px;
  text-decoration: none;
}

.currency-option:hover { color: var(--text); background: var(--elevated); }
.currency-option.is-active { background: var(--btn-primary); color: #fff; }
.currency-option.is-active:hover { color: #fff; background: var(--btn-primary-hover); }

.content { padding: 32px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.lede {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 20px;
}

.page-actions form { display: inline-flex; }
.page-actions, .cluster, .actions, .quick, .filters, .alerts, .legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.page-actions { justify-content: flex-end; }
.legend { gap: 16px; color: var(--text-secondary); font-size: 12px; line-height: 16px; font-weight: 500; }
.filters { margin-bottom: 0; }

.dashboard, .stack-page { display: flex; flex-direction: column; gap: 16px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.grid-2.even { grid-template-columns: 1fr 1fr; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
}

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

.card-head h2, .card-head h3 { margin: 0; }
.card-head a { font-size: 13px; font-weight: 600; text-decoration: none; }

.stat-top, .modal-head, .invoice-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stat-icon, .icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  flex: none;
}

.stat-icon {
  width: 36px;
  height: 36px;
  background: var(--nav-active);
  color: var(--brand-blue-light);
}

[data-theme="light"] .stat-icon { color: var(--btn-primary); }

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

.nav-toggle { display: none; }

.stat-value {
  margin-top: 12px;
  font-size: 32px;
  line-height: 40px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat-hint, .hint, .sub {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
}

.stat-hint { margin-top: 4px; }
.stat-warn { box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.45); }

.btn {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 20px; }
.btn-primary { background: var(--btn-primary); color: #fff; }
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-gradient { background: var(--cta-gradient); color: #fff; }
.btn-gradient:hover { filter: brightness(1.06); }
.btn-secondary { border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--elevated); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--elevated); color: var(--text); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-block { width: 100%; }

.chip, .chip-btn {
  height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.chip.is-active, .chip-btn.is-active {
  background: var(--btn-primary);
  border-color: transparent;
  color: #fff;
}

.chip-btn { border-radius: 8px; height: 32px; padding: 0 10px; font-size: 12px; }
.chip:hover { color: var(--text); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-badge);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-brand { background: var(--brand-bg); color: var(--badge-brand); }
.badge-neutral { background: rgba(142, 146, 180, 0.16); color: var(--text-secondary); }

.label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.field { display: block; min-width: 0; }

.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--input);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
}

.textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

.input::placeholder, .textarea::placeholder { color: var(--text-muted); }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(81, 112, 255, 0.28);
}

.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238E92B4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.input-sm { height: 40px; width: 240px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field-span { grid-column: 1 / -1; }

.check-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 168px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--input);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: 14px;
  cursor: pointer;
}

.check input { width: 16px; height: 16px; accent-color: var(--btn-primary); }
.check .hint { margin-left: auto; }

.money-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--input);
}

.money-preview strong {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
}

.money-preview.is-over,
.money-preview.is-over strong { color: var(--danger); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--card);
}

table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table-wrap.fit table { min-width: 0; }

th {
  height: 44px;
  padding: 0 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  height: 52px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 20px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--row-hover); }
tr[hidden] { display: none; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.02em; }
.row-title { color: var(--text); font-weight: 600; text-decoration: none; }
.row-title:hover { color: var(--link); }
.actions { justify-content: flex-end; }
.actions form { display: flex; }
td.actions-cell { width: 1%; }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }

.clamp {
  max-width: 320px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  flex: none;
}

.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.stack-avatars { display: flex; align-items: center; }
.stack-avatars .avatar { margin-left: -8px; border: 2px solid var(--card); }
.stack-avatars .avatar:first-child { margin-left: 0; }
.avatar-more { background: var(--elevated); color: var(--text); border: 2px solid var(--card); }

.split-bar, .track, .status-track {
  height: 8px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}

.split-bar { display: flex; height: 10px; }
.split-bar span, .track > span, .status-track > span { display: block; height: 100%; }
.split-bar .is-released, .is-success { background: var(--success); }
.split-bar .is-collect { background: var(--info); }
.split-bar .is-hold, .is-warning { background: var(--warning); }
.track > span { background: var(--cta-gradient); border-radius: inherit; }
.status-track > span { background: var(--brand-blue); border-radius: inherit; }
.status-track > span.is-warning { background: var(--warning); }
.status-track > span.is-success { background: var(--success); }
.status-track > span.is-danger { background: var(--danger); }
.status-track > span.is-brand { background: var(--brand-purple); }

.status-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 28px;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.status-row:last-child { margin-bottom: 0; }
.status-row b { color: var(--text); font-weight: 600; text-align: right; }

.person {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
}

.person + .person { border-top: 1px solid var(--border); }
.person .track { margin-top: 6px; }
.swatch { width: 8px; height: 8px; border-radius: 99px; display: inline-block; }
.swatch-success { background: var(--success); }
.swatch-info { background: var(--info); }
.swatch-warning { background: var(--warning); }

.legend li { display: inline-flex; align-items: center; gap: 8px; }

.ring {
  --p: 0;
  width: 88px;
  height: 88px;
  position: relative;
  flex: none;
}

.ring svg { width: 100%; height: 100%; display: block; }
.ring circle { fill: none; stroke-width: 3; }
.ring .ring-bg { stroke: var(--border); }
.ring .ring-fg {
  stroke: var(--brand-blue);
  stroke-linecap: round;
  stroke-dasharray: calc(var(--p) * 0.9739) 97.39;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.ring strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.progress-hero, .invoice-sheet { display: flex; gap: 20px; align-items: flex-start; }
.progress-copy { flex: 1; min-width: 0; }
.progress-copy h2 { margin-bottom: 4px; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }

.day {
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 10px 6px;
  text-align: center;
}

.day.is-today { border-color: var(--brand-blue); }
.day strong { display: block; font-size: 16px; line-height: 24px; font-weight: 700; }
.day span {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.task-title { font-weight: 600; color: var(--text); }
.timeline { color: var(--text-secondary); font-size: 12px; line-height: 16px; }

.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--overlay);
}

.modal-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
  border-radius: var(--radius-modal);
  background: var(--elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.modal-head { margin-bottom: 20px; position: sticky; top: -24px; background: var(--elevated); padding-top: 4px; z-index: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
body.modal-open { overflow: hidden; }

.flash {
  border-radius: var(--radius-control);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 20px;
}

.flash a { font-weight: 600; }
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-danger { background: var(--danger-bg); color: var(--danger); }
.flash-warning { background: var(--warning-bg); color: var(--warning); }
.flash-info { background: var(--info-bg); color: var(--info); }
.flash code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

.alert-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-control);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}

.alert-link.danger { background: var(--danger-bg); color: var(--danger); }
.alert-link.warning { background: var(--warning-bg); color: var(--warning); }
.alert-link.info { background: var(--info-bg); color: var(--info); }

.empty { text-align: center; padding: 48px 24px; }
.empty h2, .empty h3 { margin-bottom: 8px; }
.empty p { color: var(--text-secondary); margin: 0 auto 16px; max-width: 420px; }
.empty-inline { padding: 28px 16px; text-align: center; color: var(--text-secondary); }

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.back:hover { color: var(--text); }

.detail-grid { display: flex; flex-direction: column; gap: 16px; }
.prose { color: var(--text-secondary); white-space: pre-wrap; }

.menu { position: relative; }
.user-trigger {
  list-style: none;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 4px;
  border-radius: 999px;
  cursor: pointer;
}
.user-trigger::-webkit-details-marker { display: none; }
.user-trigger:hover { background: var(--elevated); }
.trigger-name { font-weight: 600; font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 200px;
  padding: 8px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  z-index: 30;
}

.menu-pop a {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.menu-pop a:hover { background: var(--row-hover); }

.scrim { display: none; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.feed-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 20px;
}

.feed-item:first-of-type { border-top: 0; }
.feed-item span { color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.invoice-sheet { display: block; }
.invoice-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.invoice-brand img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }
.invoice-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0; }
.invoice-meta p { color: var(--text-secondary); }
.invoice-lines { width: 100%; border-collapse: collapse; margin-top: 8px; }
.invoice-total { margin-top: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.invoice-total div { display: flex; justify-content: space-between; gap: 32px; min-width: 240px; }
.invoice-total strong { font-family: var(--font-display); font-size: 20px; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-glow {
  position: absolute;
  width: 520px;
  height: 360px;
  background:
    radial-gradient(circle at 40% 40%, rgba(81, 112, 255, 0.35), transparent 60%),
    radial-gradient(circle at 70% 50%, rgba(140, 82, 255, 0.3), transparent 55%);
  filter: blur(8px);
  pointer-events: none;
}

.login-theme { position: absolute; top: 24px; right: 24px; z-index: 2; }
.login-card { width: min(420px, 100%); position: relative; z-index: 1; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 8px; text-align: center; }
.login-brand img { width: 120px; height: 120px; border-radius: 20px; object-fit: cover; }
.login-card h1 { margin-bottom: 4px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-control);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 20px;
}

.icon { display: block; flex: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
[data-theme="dark"] .theme-moon,
[data-theme="light"] .theme-sun { display: none; }

@media (max-width: 1100px) {
  .stats, .stats-3, .grid-2, .grid-2.even { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  html.is-collapsed { --sidebar-current: var(--sidebar-width); }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    width: var(--sidebar-width);
    transition: transform 0.2s ease;
  }
  html.is-nav-open .sidebar { transform: none; }
  html.is-nav-open .scrim { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 25; }
  html.is-collapsed .brand-text,
  html.is-collapsed .nav-label,
  html.is-collapsed .nav-section,
  html.is-collapsed .side-user-text { display: block; }
  html.is-collapsed .nav-link { justify-content: flex-start; padding: 0 12px; }
  html.is-collapsed .brand { justify-content: flex-start; padding: 12px 16px; }
  html.is-collapsed .side-user { justify-content: flex-start; }
  .collapse-toggle { display: none; }
  .nav-toggle { display: inline-grid; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .content { padding-top: 20px; padding-bottom: 32px; }
  .today-label, .search .kbd, .trigger-name { display: none; }
  .search { width: auto; flex: 1; }
}

@media (max-width: 700px) {
  .stats, .stats-3, .grid-2, .grid-2.even, .form-grid, .invoice-meta { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .page-head, .progress-hero { flex-direction: column; }
  .page-actions { width: 100%; justify-content: flex-start; }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .input-sm { width: 100%; }
  .stat-value { font-size: 28px; line-height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar, .topbar, .page-actions, .no-print, .flash, .scrim, .back { display: none !important; }
  .shell, .main, .content { display: block; padding: 0; }
  body, .card, .invoice-sheet { background: #fff; color: #0b0b1a; }
  .card { border: 0; box-shadow: none; padding: 0; }
  a { color: #0b0b1a; }
}
