:root {
  /* Core Colors - Dark Trading Theme */
  --bg-app: #0b0f14;
  --bg-panel: rgba(20, 26, 34, 0.95);
  --bg-input: #0b1117;
  --line: #2a323b;

  --text-primary: #e7eaf0;
  --text-secondary: #b3bac4;
  --text-tertiary: #8b94a3;

  --accent-primary: #c9a45a;
  --accent-glow: rgba(201, 164, 90, 0.4);
  --accent-secondary: #2d3a4a;

  --profit: #10b981;
  /* Emerald 500 */
  --profit-bg: rgba(16, 185, 129, 0.1);
  --loss: #ef4444;
  /* Red 500 */
  --loss-bg: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  /* Amber 500 */

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);

  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-display: 'Cinzel', var(--font-sans);
}

/* Reset & Base */
* {
  box-sizing: border-box;
  outline: none;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(201, 164, 90, 0.12), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(45, 58, 74, 0.35), transparent 55%),
    linear-gradient(180deg, rgba(8, 12, 18, 0.96), rgba(11, 15, 20, 0.98));
  color: var(--text-primary);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  font-weight: 400;
  /* Ensure we don't use too-thin fonts */
  font-size: 15px;
  /* Slightly larger base calculation */
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 5px;
  border: 2px solid var(--bg-app);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  color: var(--text-primary);
  margin: 0 0 0.8rem 0;
  font-weight: 600;
  letter-spacing: 0.02em;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

a {
  color: #d6b36a;
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  text-decoration: underline;
  color: #60a5fa;
}

/* Layout */
.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.auth-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(201, 164, 90, 0.18), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(45, 58, 74, 0.55), transparent 55%),
    linear-gradient(180deg, rgba(8, 12, 18, 0.96), rgba(11, 15, 20, 0.98));
}

/* Components */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  position: sticky;
  top: 12px;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(16, 22, 30, 0.92);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  box-shadow: none;
}

.logo img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
  text-transform: none;
}

.brand-text .subtitle {
  color: #c9a45a;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.user-ctrl {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  background: rgba(201, 164, 90, 0.08);
  color: #f2d27b;
  border-color: rgba(201, 164, 90, 0.4);
}

.gear-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  padding: 0;
}

.modal-open {
  overflow: hidden;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 200;
}

.settings-overlay.open {
  display: block;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 19, 0.72);
  backdrop-filter: blur(4px);
}

.settings-drawer {
  position: absolute;
  top: 16px;
  right: 16px;
  width: min(820px, 92vw);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
}

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

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-panel {
  margin-bottom: 0;
}

/* Calendar */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.calendar-limit {
  font-size: 0.75rem;
}

.calendar-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1rem;
}

.calendar-check-all {
  font-size: 0.8rem;
  padding: 6px 10px;
}

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

.calendar-weekday {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  text-align: center;
}

.calendar-cell {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  position: relative;
}

.calendar-cell.has-trades {
  cursor: pointer;
}

.calendar-cell.is-out {
  opacity: 0.35;
}

.calendar-cell.is-today {
  border-color: rgba(201, 164, 90, 0.7);
  box-shadow: 0 0 0 1px rgba(201, 164, 90, 0.25);
}

.calendar-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.calendar-pnl {
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-display);
}

.calendar-cell.pnl-positive .calendar-pnl {
  color: var(--profit);
}

.calendar-cell.pnl-negative .calendar-pnl {
  color: var(--loss);
}

.calendar-cell.pnl-flat .calendar-pnl {
  color: var(--text-tertiary);
}

.calendar-view {
  align-self: flex-start;
  font-size: 0.7rem;
  color: var(--accent-primary);
}

.calendar-view:hover {
  text-decoration: underline;
}

.calendar-status {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.calendar-status--pass {
  color: var(--profit);
  border: 1px solid rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.12);
}

.calendar-status--fail {
  color: var(--loss);
  border: 1px solid rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.12);
}

.calendar-status--pending {
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.12);
}

/* Dashboard Grid */
.row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.col {
  flex: 1;
  flex-basis: 300px;
  min-width: 0;
  /* Allow shrinking below content size to prevent blowout */
}

/* Cards & Stats */
.card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  overflow: hidden;
  /* Clips content that ignores bounds */
  display: flex;
  flex-direction: column;
}

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

.kpi {
  background: var(--bg-app);
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kpi .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  font-weight: 600;
}

.kpi .value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-display);
}

/* Forms */
label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--line);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 1rem;
  /* bumped from 0.95rem */
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(201, 164, 90, 0.2);
  background: rgba(15, 23, 42, 0.8);
  /* Slightly darker focus state */
}

button[type="submit"],
.btn-primary {
  background: linear-gradient(135deg, #d8b36a 0%, #c1974d 60%, #8f6a2d 100%);
  color: #11151c;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s;
  font-size: 0.95rem;
}

button[type="submit"]:hover,
.btn-primary:hover {
  filter: brightness(1.05);
}

#upload-form {
  border: 2px dashed var(--line);
  padding: 24px;
  text-align: center;
  border-radius: var(--radius-md);
  transition: border-color 0.2s;
  background: rgba(255, 255, 255, 0.01);
}

#upload-form:hover {
  border-color: rgba(201, 164, 90, 0.55);
  background: rgba(201, 164, 90, 0.06);
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--bg-panel);
}

th {
  background: #121821;
  /* slightly darker than panel */
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-primary);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Status Pills */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.pill-win {
  background: var(--profit-bg);
  color: var(--profit);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.pill-loss {
  background: var(--loss-bg);
  color: var(--loss);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.pill-breakeven,
.pill-flat {
  background: rgba(241, 245, 249, 0.1);
  color: var(--text-secondary);
  border: 1px solid var(--line);
}

.pill-reviewed {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-primary);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.pill-missing {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.pnl-positive {
  color: var(--profit);
  font-weight: 600;
  font-family: var(--font-display);
}

.pnl-negative {
  color: var(--loss);
  font-weight: 600;
  font-family: var(--font-display);
}

.kpi .value.risk-value {
  color: var(--loss) !important;
}

.kpi .value.profit-value {
  color: var(--profit) !important;
}

.pnl-flat {
  color: var(--text-tertiary);
  font-weight: 600;
  font-family: var(--font-display);
}

.activation-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 1px solid rgba(201, 164, 90, 0.35);
  background: rgba(201, 164, 90, 0.08);
}

.panel-disabled {
  pointer-events: none;
  opacity: 0.45;
  filter: grayscale(0.2);
}

/* Donut Chart */
.donut {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--donut-color, var(--profit)) calc(var(--p) * 1%), var(--line) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 12px;
  background: var(--bg-panel);
  border-radius: 50%;
}

.donut span {
  position: relative;
  z-index: 10;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-display);
}

/* Loading Overlay */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
}

.overlay-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: 32px;
  max-width: 420px;
  margin: 15vh auto;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.spinner {
  border: 4px solid var(--line);
  border-top: 4px solid var(--accent-primary);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Helper Classes */
.muted {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 400;
  opacity: 0.8;
}

.error {
  color: #fecaca;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.2);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  display: block;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.tag-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tag-color, var(--line));
  color: var(--text-primary);
}

.tag-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tag-color, var(--line));
  display: block;
}

/* AI Coach & Logs */
.ai-review,
.ai-log {
  background: rgba(255, 255, 255, 0.04);
  /* Increased opacity for visibility */
  border: 1px solid var(--line);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  border-radius: var(--radius-sm);
  padding: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  /* stronger wrapping for long tokens */
  font-size: 0.95rem;
  line-height: 1.6;
  width: 100%;
  max-width: 100%;
  max-height: 320px;
  /* Constrain height */
  overflow-y: auto;
  /* Scroll if too long */
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Scrollbar for AI box */
.ai-review::-webkit-scrollbar,
.ai-log::-webkit-scrollbar {
  width: 8px;
}

.ai-review::-webkit-scrollbar-thumb,
.ai-log::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.input-dark,
.input-dark:focus,
.input-dark:active,
.input-dark:hover {
  background: #0b1220 !important;
  color: #f8fafc;
}

.rule-delete-btn,
.rule-delete-btn:focus,
.rule-delete-btn:active {
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.6) !important;
  background: rgba(239, 68, 68, 0.12) !important;
}

.rule-delete-btn:hover {
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.85) !important;
  background: rgba(239, 68, 68, 0.12) !important;
}

.reset-data-btn,
.reset-data-btn:focus,
.reset-data-btn:active {
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.6) !important;
  background: rgba(239, 68, 68, 0.12) !important;
}

.reset-data-btn:hover {
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.85) !important;
  background: rgba(239, 68, 68, 0.12) !important;
}

/* Password checklist */
.password-checklist {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.password-checklist li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.password-checklist li.met {
  color: var(--profit);
}

.password-checklist .check-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.password-checklist li.met .check-icon {
  color: var(--profit);
  border-color: rgba(16, 185, 129, 0.5);
}

/* Performance Snapshot Controls */
.snapshot-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
}

.snapshot-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.snapshot-title h3 {
  margin: 0;
}

.snapshot-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.snapshot-kpis {
  align-items: stretch;
}

.snapshot-kpis .kpi {
  height: 100%;
  justify-content: flex-start;
}

.snapshot-charts {
  align-items: flex-start;
}

.snapshot-donuts {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-self: stretch;
}

.donut-card--equity {
  min-height: 240px;
}

.donut-card--projection {
  min-height: 220px;
}

.chart-frame {
  position: relative;
}

.chart-frame-header {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 2;
  pointer-events: none;
}

.chart-title {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.chart-title--secondary {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.chart-summary {
  font-size: 0.85rem;
}

.chart-canvas {
  display: block;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
}

/* Tooltips */
.has-tooltip {
  position: relative;
}

.tooltip-host {
  overflow: visible;
}

.has-tooltip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(9, 13, 19, 0.95);
  border: 1px solid var(--line);
  color: var(--text-primary);
  font-size: 0.75rem;
  line-height: 1.4;
  text-align: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
}

.has-tooltip::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: rgba(9, 13, 19, 0.95) transparent transparent transparent;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 49;
}

.has-tooltip:hover::after,
.has-tooltip:hover::before,
.has-tooltip:focus-within::after,
.has-tooltip:focus-within::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

.snapshot-controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(15, 20, 28, 0.65);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.control-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  margin: 0;
}

.control-toggle input {
  width: auto;
  margin: 0;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 210px;
}

.control-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-weight: 600;
}

.control-hint {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.compact-input {
  padding: 8px 10px;
  font-size: 0.95rem;
}

.btn-compact {
  padding: 8px 14px;
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .page {
    padding: 18px;
  }

  .topbar {
    padding: 14px 18px;
  }

  .panel {
    padding: 16px;
  }

  .chart-container #chart {
    height: 480px !important;
  }
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    position: static;
  }

  .user-ctrl {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
  }

  .row {
    flex-direction: column;
    gap: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .snapshot-controls {
    width: 100%;
    align-items: center;
  }

  th,
  td {
    padding: 10px 12px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .page {
    padding: 12px;
  }

  .topbar {
    padding: 12px 14px;
    border-radius: var(--radius-md);
  }

  .brand {
    flex-wrap: wrap;
    gap: 10px;
  }

  .brand-text h1 {
    font-size: 1.1rem;
  }

  .panel {
    padding: 14px;
    margin-bottom: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .kpi .value {
    font-size: 1.25rem;
  }

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

  .control-toggle {
    justify-content: space-between;
  }

  .control-field {
    min-width: 0;
    width: 100%;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px;
  }

  button[type="submit"],
  .btn-primary {
    width: 100%;
  }

  .btn-ghost {
    width: auto;
  }

  .table-wrap {
    border-radius: var(--radius-sm);
  }

  table {
    font-size: 0.85rem;
  }

  th {
    font-size: 0.7rem;
  }

  .pill {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  .chart-container #chart {
    height: 360px !important;
  }

  .ai-review,
  .ai-log {
    max-height: 240px;
  }

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