:root {
  --sb-w-expanded: 236px;
  --sb-w-collapsed: 64px;
  --topbar-h: 64px;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  --serif: var(--sans);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --text: #111111;
  --text-2: #4b4f56;
  --text-mute: #8a8f98;
  --rule: #dee1e6;
  --rule-soft: #eceef2;
  --accent: #0a84ff;
  --accent-2: #0062d1;
  --accent-soft: rgba(10, 132, 255, 0.1);
  --positive: #1f8f5f;
  --warning: #b26a1c;
  --error: #d64545;
  --kpi-border-color: #ffffff;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #151923;
  --surface-2: #1b2030;
  --text: #f4f6fb;
  --text-2: #c2c8d4;
  --text-mute: #7f8796;
  --rule: #272d3a;
  --rule-soft: #1b2030;
  --accent: #5aa9ff;
  --accent-2: #2c8af7;
  --accent-soft: rgba(90, 169, 255, 0.12);
  --positive: #4eb37f;
  --warning: #d39b3d;
  --error: #f06a6a;
  --kpi-border-color: #151923;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--text);
  transition: background 180ms ease, color 180ms ease;
}
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0;
}
body::before { content: none; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
button { font: inherit; cursor: pointer; background: none; border: 0; color: inherit; padding: 0; }
::selection { background: var(--accent); color: #fff; }

.app-shell { min-height: 100vh; }
html[data-sidebar="expanded"] { --sb-w: var(--sb-w-expanded); }
html[data-sidebar="collapsed"] { --sb-w: var(--sb-w-collapsed); }

.app-area {
  margin-left: var(--sb-w);
  min-height: 100vh;
  transition: margin-left 220ms cubic-bezier(.2,.8,.2,1);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sb-w);
  background: var(--surface);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: width 220ms cubic-bezier(.2,.8,.2,1), transform 220ms cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}

.sidebar-head {
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-shrink: 0;
}
.brand { display: flex; flex-direction: column; color: var(--text); white-space: nowrap; overflow: hidden; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}
.brand-mark em { font-style: italic; color: var(--accent); font-weight: 700; }
.brand-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-top: 6px;
}
html[data-sidebar="collapsed"] .brand { display: none; }
html[data-sidebar="collapsed"] .brand-kicker { display: none; }
html[data-sidebar="collapsed"] .brand-mark { font-size: 20px; }
html[data-sidebar="collapsed"] .sidebar-head { padding: 18px 0; justify-content: center; }

.sidebar-toggle {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-mute);
  flex-shrink: 0;
  transition: color 120ms, background 120ms;
}
.sidebar-toggle:hover { color: var(--accent); background: var(--surface-2); }
html[data-sidebar="collapsed"] .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 16px 12px 8px;
}
html[data-sidebar="collapsed"] .nav-section-label { display: none; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 14px;
  color: var(--text-2);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: color 120ms, background 120ms;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.is-active { color: var(--accent); background: var(--accent-soft); }
.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent);
}
.nav-item svg { color: currentColor; flex-shrink: 0; opacity: 0.9; }
.nav-item.is-active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
html[data-sidebar="collapsed"] .nav-label { display: none; }
html[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 11px; }
html[data-sidebar="collapsed"] .nav-item.is-active::before { display: none; }
html[data-sidebar="collapsed"] .nav-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
}
html[data-sidebar="collapsed"] .nav-item.is-active {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-foot {
  border-top: 1px solid var(--rule);
  padding: 12px;
  flex-shrink: 0;
}
.user { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  color: var(--accent);
  border-radius: 10px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 14px;
}
.user-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.user-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.user-logout button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-mute);
  transition: color 120ms, background 120ms;
}
.user-logout button:hover { background: var(--surface-2); color: var(--error); }
html[data-sidebar="collapsed"] .user-text,
html[data-sidebar="collapsed"] .user-logout { display: none; }
html[data-sidebar="collapsed"] .user { justify-content: center; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.28);
  backdrop-filter: blur(2px);
  z-index: 40;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}
.topbar-burger {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  border-radius: 8px;
}
.topbar-burger:hover { background: var(--surface-2); color: var(--accent); }
.topbar-titleblock { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topbar-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.topbar-kicker em { font-style: normal; color: var(--accent); }
.topbar-title {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 650;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.topbar-spacer { flex: 1; }
.theme-toggle {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  transition: color 140ms, background 140ms, border-color 140ms;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.app-main {
  padding: 30px 32px 54px;
  max-width: 1480px;
  margin: 0 auto;
}
.app-footer {
  padding: 18px 32px 26px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}

h1, h2, h3, h4 {
  font-family: var(--sans);
  color: var(--text);
  letter-spacing: -0.02em;
}
h1 { font-size: 31px; font-weight: 650; margin: 0 0 24px; }
h2 { font-size: 21px; font-weight: 600; margin: 28px 0 14px; }
h3 {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-mute);
  letter-spacing: 0.14em;
  margin: 0 0 12px;
}
h4 { margin: 0 0 10px; font-size: 16px; font-weight: 600; }
.muted { color: var(--text-mute); font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.back-link { font-family: var(--mono); font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.08em; }
.back-link:hover { color: var(--accent); }

.flash {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 12px;
  font-family: var(--sans);
  font-size: 13px;
  border: 1px solid transparent;
}
.flash-error { background: rgba(214, 69, 69, 0.08); color: var(--error); border-color: rgba(214, 69, 69, 0.18); }
.flash-success { background: rgba(31, 143, 95, 0.08); color: var(--positive); border-color: rgba(31, 143, 95, 0.18); }
.flash-info { background: var(--accent-soft); color: var(--accent); border-color: rgba(10, 132, 255, 0.18); }

.kpi-grid,
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  align-items: stretch;
}
.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 160px;
  padding: 20px 18px 18px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.035);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
.kpi:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(17, 17, 17, 0.05); border-color: var(--rule); }
.kpi-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.kpi-eyebrow em { font-style: normal; color: var(--accent); margin-right: 6px; }
.kpi-value {
  font-family: var(--sans);
  font-size: 48px;
  line-height: 0.95;
  font-weight: 650;
  margin: 12px 0 8px;
  color: var(--text);
  letter-spacing: -0.04em;
}
.kpi-value sup {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-mute);
  vertical-align: super;
  margin-left: 6px;
}
.kpi-label {
  margin-top: auto;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-2);
}
.kpi-label strong { font-weight: 600; color: var(--text); }
.kpi-link { color: inherit; }
.kpi-link:hover { text-decoration: none; background: #fbfcfd; }
.compact-kpis {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}
.compact-kpis .kpi {
  min-height: 118px;
  padding: 16px;
  border-radius: 14px;
}
.compact-kpis .kpi-value {
  font-size: 34px;
  letter-spacing: 0;
  margin: 8px 0 6px;
}
.compact-kpis .kpi-value sup { font-size: 12px; }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 16px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.035);
}
.chart-card-wide { grid-column: span 2; }
.chart-card h3 { color: var(--text-mute); margin: 0; }
.chart-card canvas { flex: 1; max-height: 244px; }

table.data {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 18px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  overflow: hidden;
}
table.data th,
table.data td {
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table.data th {
  background: var(--bg);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-2); }
table.data .col-mono { font-family: var(--mono); color: var(--text-2); }
table.data .col-num { font-family: var(--mono); text-align: right; color: var(--text); }
table.data .col-accent { color: var(--accent); }
.table-wrap { overflow-x: auto; border-radius: 18px; }
table.dense th,
table.dense td { padding: 12px 14px; }
table.data .compact-input {
  width: 86px;
  padding: 7px 8px;
  border-radius: 10px;
}
.empty-cell {
  padding: 28px 20px;
  text-align: center;
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 28px 0 12px;
}
.section-head h2 { margin: 0; }
.module-section { margin: 0 0 28px; }
.module-toolbar {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.035);
}
.module-toolbar input[type="search"] { min-width: 240px; }
.module-toolbar select { min-width: 150px; }
.bulk-toolbar { margin: 0 0 12px; }
.bulk-toolbar input[type="number"] { width: 150px; }
.work-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  color: var(--text-2);
  font-size: 13px;
}
.work-progress[hidden] { display: none; }
.work-progress__bar {
  position: relative;
  width: 120px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
}
.work-progress__bar::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 45%;
  border-radius: inherit;
  background: var(--accent);
  animation: work-progress-slide 1s ease-in-out infinite;
}
@keyframes work-progress-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(260%); }
}
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar input,
.toolbar select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="url"],
input[type="datetime-local"],
select {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--text);
  border-radius: 12px;
  font: inherit;
  font-family: var(--sans);
  outline: none;
  transition: border-color 140ms, background 140ms, box-shadow 140ms;
}
.toolbar input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.08);
}

.btn {
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0;
  transition: background 140ms, transform 80ms, box-shadow 140ms;
}
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); box-shadow: 0 8px 18px rgba(10, 132, 255, 0.18); }
.btn:active { transform: translateY(1px); }
.btn-secondary {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--rule);
}
.btn-secondary:hover { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid rgba(214, 69, 69, 0.25);
}
.btn-danger:hover { background: rgba(214, 69, 69, 0.08); box-shadow: none; }

.pagination-bar,
.tabs-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 28px;
}
.page-chip,
.tab-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.page-chip:hover,
.tab-chip:hover { text-decoration: none; background: var(--surface-2); color: var(--text); }
.page-chip.is-active,
.tab-chip.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(10, 132, 255, 0.25);
}
.btn-secondary.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.035);
  color: var(--text);
}
.stat-card-link:hover { text-decoration: none; border-color: rgba(10, 132, 255, 0.22); box-shadow: 0 10px 24px rgba(17, 17, 17, 0.06); }
.stat-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.stat-card-title {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.2;
}
.stat-card-meta,
.stat-card-foot { color: var(--text-2); font-size: 13px; }

.inline-actions {
  display: inline-flex;
  margin-left: 8px;
}
.compact {
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
}
.compact span { color: var(--text-2); font-size: 12px; }

.schedule-range,
.fee-cell {
  display: grid;
  gap: 8px;
}
.fee-cell {
  grid-template-columns: minmax(0, 1fr) 100px;
  align-items: center;
}
.fee-cell select,
.fee-cell input { width: 100%; }

.check-pill,
.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
}
.check-pill {
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.badge-drafted,
.badge-warning,
.badge-priority-medium { color: var(--warning); background: rgba(178, 106, 28, 0.1); }
.badge-reviewed,
.badge-good,
.badge-priority-low { color: var(--positive); background: rgba(31, 143, 95, 0.1); }
.badge-published { color: var(--accent); background: var(--accent-soft); }
.badge-danger,
.badge-priority-high { color: var(--error); background: rgba(214, 69, 69, 0.1); }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}
.detail-header h2 { margin: 6px 0 4px; }
.detail-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.detail-stats span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.detail-stats strong {
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
}

.split-grid,
.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}
.ops-grid { margin-bottom: 28px; }

.panel-form,
.side-panel,
.ops-panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.035);
}
.panel-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.panel-form label,
.note-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-mute);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.panel-form input,
.panel-form select,
.panel-form textarea,
.note-form textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
}
.panel-form textarea,
.note-form textarea { resize: vertical; min-height: 72px; }
.note-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 24px;
}

.meta-list {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0 0 24px;
}
.meta-list dt {
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.meta-list dd {
  margin: 0;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.activity-list { display: flex; flex-direction: column; gap: 10px; }
.activity-item {
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 12px;
  background: var(--bg);
}
.activity-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.activity-item p { margin: 8px 0 0; color: var(--text-2); }
.source-copy {
  white-space: pre-wrap;
  color: var(--text-2);
  font-size: 13px;
  max-height: 360px;
  overflow: auto;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 220px;
}
.row-actions form { display: inline; }
.row-actions button {
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10px;
}
.row-actions button:hover { color: var(--accent); border-color: var(--accent); }

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}
.login-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 20px;
  padding: 44px 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 18px 44px rgba(17, 17, 17, 0.08);
}
.login-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-mute);
  text-align: center;
  margin-bottom: 8px;
}
.login-title {
  font-family: var(--sans);
  font-size: 30px;
  font-weight: 650;
  margin: 0 0 28px;
  text-align: center;
  letter-spacing: -0.02em;
  color: var(--text);
}
.login-title em { color: var(--accent); font-style: italic; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-mute);
}
.login-form input {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--text);
  border-radius: 12px;
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0;
}
.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.08);
}
.login-form button {
  margin-top: 8px;
  padding: 12px 16px;
  background: var(--accent);
  color: #ffffff;
  border: 0;
  border-radius: 12px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
  transition: background 140ms, transform 80ms, box-shadow 140ms;
}
.login-form button:hover { background: var(--accent-2); box-shadow: 0 8px 18px rgba(10, 132, 255, 0.18); }
.login-form button:active { transform: translateY(1px); }
.login-theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  z-index: 2;
  transition: all 140ms;
}
.login-theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.login-theme-toggle .icon-sun { display: none; }
.login-theme-toggle .icon-moon { display: block; }
[data-theme="light"] .login-theme-toggle .icon-sun { display: block; }
[data-theme="light"] .login-theme-toggle .icon-moon { display: none; }

@media (max-width: 900px) {
  html[data-sidebar="expanded"] .sidebar { transform: translateX(0); }
  html[data-sidebar="collapsed"] .sidebar { transform: translateX(-100%); }
  .sidebar { width: var(--sb-w-expanded); }
  .app-area { margin-left: 0; }
  html[data-sidebar="expanded"] .sidebar-backdrop { display: block; }
  .topbar-burger { display: grid; }
  .app-main { padding: 22px 20px 40px; }
  .topbar { padding: 0 20px; }
  .chart-card-wide { grid-column: span 1; }
  .split-grid,
  .ops-grid { grid-template-columns: 1fr; }
  .detail-header { flex-direction: column; }
  .detail-stats { width: 100%; overflow-x: auto; }
  .kpi-value { font-size: 40px; }
}
