/* =====================================================================
   RENDIMENTO+ · Design System
   ===================================================================== */

/* ---------- TOKENS · LIGHT ---------- */
:root {
  /* Brand */
  --primary: #005DE0;
  --primary-600: #0050C2;
  --primary-700: #023D8F;
  --primary-50: #E7F0FF;
  --primary-100: #D1E2FE;
  --primary-soft: rgba(0, 93, 224, 0.08);
  --navy: #0C2249;

  /* Surfaces */
  --background: #F4F6F8;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #F1F4F8;

  /* Borders */
  --border: #E3E7ED;
  --border-strong: #D8DEE8;
  --divider: #EAECEF;

  /* Text */
  --text-primary: #172B4D;
  --text-secondary: #667085;
  --text-muted: #98A2B3;
  --text-inverse: #FFFFFF;

  /* Status */
  --success: #159A72;
  --success-50: #E6F6EF;
  --warning: #E9A400;
  --warning-50: #FFF6E0;
  --danger: #D84A4A;
  --danger-50: #FCEAEA;
  --info: #005DE0;
  --info-50: #E7F0FF;

  /* Discipline palette */
  --disc-portugues: #005DE0;
  --disc-matematica: #E76F2C;
  --disc-const: #0F8C7E;
  --disc-admin: #8B2E47;
  --disc-informatica: #6E4FBF;
  --disc-raciocinio: #C28F00;
  --disc-penal: #A6324A;
  --disc-processual: #0C2249;
  --disc-atualidades: #3D8C5F;

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing (4px scale) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-pill: 999px;

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-focus: 0 0 0 3px rgba(0, 93, 224, 0.10);

  /* Motion */
  --t-fast: 150ms;
  --t-base: 200ms;
  --t-slow: 250ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --sidebar-w: 248px;
  --header-h: 64px;
  --content-max: 1280px;
}

/* ---------- TOKENS · DARK ---------- */
[data-theme="dark"] {
  --background: #0B1220;
  --surface: #111827;
  --surface-2: #0F1729;
  --surface-3: #18243D;

  --border: #243044;
  --border-strong: #2D3B53;
  --divider: #1E2A40;

  --text-primary: #F8FAFC;
  --text-secondary: #98A2B3;
  --text-muted: #667085;
  --text-inverse: #0B1220;

  --primary: #4A86FF;
  --primary-600: #2F6BE5;
  --primary-700: #1E50B8;
  --primary-50: rgba(74, 134, 255, 0.12);
  --primary-100: rgba(74, 134, 255, 0.20);
  --primary-soft: rgba(74, 134, 255, 0.10);
  --navy: #0A1730;

  --success-50: rgba(21, 154, 114, 0.14);
  --warning-50: rgba(233, 164, 0, 0.14);
  --danger-50: rgba(216, 74, 74, 0.14);
  --info-50: rgba(74, 134, 255, 0.14);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.4);
  --shadow-focus: 0 0 0 3px rgba(74, 134, 255, 0.20);
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; margin: 0; }
img, svg { display: block; max-width: 100%; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--background); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- TYPOGRAPHY ---------- */
.t-display { font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
.t-h1 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.t-h2 { font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -0.015em; }
.t-h3 { font-size: 18px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
.t-h4 { font-size: 16px; line-height: 1.4; font-weight: 600; }
.t-body { font-size: 14px; line-height: 1.55; font-weight: 400; }
.t-body-lg { font-size: 16px; line-height: 1.55; font-weight: 400; }
.t-small { font-size: 13px; line-height: 1.5; }
.t-caption { font-size: 12px; line-height: 1.45; font-weight: 400; }
.t-overline { font-size: 11px; line-height: 1.2; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-secondary); }
.t-mono { font-family: var(--font-mono); }
.t-muted { color: var(--text-muted); }
.t-secondary { color: var(--text-secondary); }
.t-primary { color: var(--primary); }
.t-num { font-variant-numeric: tabular-nums; }

/* ---------- LAYOUT ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.04em;
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 2px;
  right: 6px;
  top: 6px;
  opacity: 0.85;
}
.brand-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}
.brand-plus { color: var(--primary); margin-left: 1px; }

.nav { padding: 16px 12px; flex: 1; }
.nav-section-title {
  padding: 16px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  position: relative;
  margin-bottom: 2px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--surface-3);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}
.nav-item.active .nav-badge { background: var(--primary); color: #fff; }
.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 8px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.cycle-mini {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.cycle-mini-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.cycle-mini-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
}
.cycle-mini-progress {
  height: 5px;
  background: var(--surface-3);
  border-radius: 999px;
  margin-top: 8px;
  overflow: hidden;
}
.cycle-mini-progress div {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}
.cycle-mini-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; }
.header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
}
.header-breadcrumb strong { color: var(--text-primary); font-weight: 600; }
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  height: 38px;
  width: 360px;
  max-width: 100%;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.search:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
  background: var(--surface);
}
.search svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.search input {
  border: 0;
  outline: 0;
  background: transparent;
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 0;
}
.search input::placeholder { color: var(--text-muted); }
.search kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
}

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-secondary);
  position: relative;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border: 2px solid var(--surface);
  border-radius: 999px;
}
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  transition: background var(--t-fast) var(--ease);
}
.profile-chip:hover { background: var(--surface-2); }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  display: grid;
  place-items: center;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.profile-info { line-height: 1.2; }
.profile-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.profile-role { font-size: 11px; color: var(--text-muted); }

.content {
  padding: 28px 32px 48px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
.btn-primary:active:not(:disabled) { background: var(--primary-700); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-muted); }

.btn-ghost {
  background: transparent;
  color: var(--primary);
}
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #B73838; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 6px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }

.icon-only {
  width: 36px; height: 36px; padding: 0; border-radius: 8px;
}
.icon-only.btn-sm { width: 30px; height: 30px; border-radius: 6px; }

/* ---------- INPUTS ---------- */
.input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  outline: 0;
}
.input::placeholder { color: var(--text-muted); }
.input:hover { border-color: var(--text-muted); }
.input:focus { border-color: var(--primary); box-shadow: var(--shadow-focus); }
.input:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }

.input-lg { height: 44px; font-size: 15px; }
.input-sm { height: 32px; font-size: 13px; }

.input-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  height: 38px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input-search:focus-within { border-color: var(--primary); box-shadow: var(--shadow-focus); }
.input-search svg { width: 16px; height: 16px; color: var(--text-muted); }
.input-search input { border: 0; outline: 0; background: transparent; flex: 1; font-size: 13px; color: var(--text-primary); min-width: 0; }

.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.input-help { font-size: 12px; color: var(--text-muted); }
.input-error { font-size: 12px; color: var(--danger); }
.input.error { border-color: var(--danger); }
.input.error:focus { box-shadow: 0 0 0 3px rgba(216, 74, 74, 0.12); }

/* Select */
.select {
  height: 40px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/</svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  outline: 0;
  cursor: pointer;
}
.select:focus { border-color: var(--primary); box-shadow: var(--shadow-focus); }

/* Checkbox & Radio */
.check {
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  display: inline-grid;
  place-items: center;
  background: var(--surface);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  cursor: pointer;
  flex-shrink: 0;
}
.check svg { width: 12px; height: 12px; color: transparent; }
input[type="checkbox"] { display: none; }
input[type="checkbox"]:checked + .check {
  background: var(--primary);
  border-color: var(--primary);
}
input[type="checkbox"]:checked + .check svg { color: #fff; }

/* ---------- BADGES ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-50); color: var(--success); }
.badge-warning { background: var(--warning-50); color: var(--warning); }
.badge-danger { background: var(--danger-50); color: var(--danger); }
.badge-info { background: var(--info-50); color: var(--info); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.chip.active { background: var(--primary-soft); border-color: transparent; color: var(--primary); font-weight: 600; }
.chip .dot-color { width: 8px; height: 8px; border-radius: 999px; }

/* Discipline indicators */
.disc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}
.disc-mark {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--primary);
  flex-shrink: 0;
}
.disc[data-disc="portugues"] .disc-mark { background: var(--disc-portugues); }
.disc[data-disc="matematica"] .disc-mark { background: var(--disc-matematica); }
.disc[data-disc="const"] .disc-mark { background: var(--disc-const); }
.disc[data-disc="admin"] .disc-mark { background: var(--disc-admin); }
.disc[data-disc="informatica"] .disc-mark { background: var(--disc-informatica); }
.disc[data-disc="raciocinio"] .disc-mark { background: var(--disc-raciocinio); }
.disc[data-disc="penal"] .disc-mark { background: var(--disc-penal); }
.disc[data-disc="processual"] .disc-mark { background: var(--disc-processual); }
.disc[data-disc="atualidades"] .disc-mark { background: var(--disc-atualidades); }

/* ---------- CARDS ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.card-pad-lg { padding: 24px; }
.card-pad-sm { padding: 16px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ---------- PROGRESS ---------- */
.progress {
  height: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width var(--t-slow) var(--ease);
}
.progress-success .progress-fill { background: var(--success); }
.progress-warning .progress-fill { background: var(--warning); }
.progress-danger .progress-fill { background: var(--danger); }
.progress-lg { height: 8px; }
.progress-sm { height: 4px; }

/* ---------- PROGRESS RING ---------- */
.ring {
  position: relative;
  display: inline-grid;
  place-items: center;
}
.ring svg { transform: rotate(-90deg); }
.ring-track { stroke: var(--primary-50); fill: none; }
.ring-progress { stroke: var(--primary); fill: none; stroke-linecap: round; transition: stroke-dashoffset var(--t-slow) var(--ease); }
.ring-label { position: absolute; text-align: center; }
.ring-value { font-size: 28px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-text { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ---------- STAT CARDS ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.stat:hover { border-color: var(--border-strong); }
.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.stat-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
}
.stat-icon svg { width: 16px; height: 16px; }
.stat-icon.success { background: var(--success-50); color: var(--success); }
.stat-icon.warning { background: var(--warning-50); color: var(--warning); }
.stat-icon.danger { background: var(--danger-50); color: var(--danger); }
.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-value-sm { font-size: 22px; }
.stat-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
}
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }
.stat-delta svg { width: 12px; height: 12px; }

/* ---------- TABLES ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table thead th {
  background: var(--surface-2);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
  font-size: 13.5px;
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.table .num { font-variant-numeric: tabular-nums; }

/* ---------- LISTS ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
  transition: background var(--t-fast) var(--ease);
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }
.list-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.list-icon svg { width: 18px; height: 18px; }
.list-body { flex: 1; min-width: 0; }
.list-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.list-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.list-extra { text-align: right; font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }
.list-extra strong { display: block; font-size: 14px; color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- GRIDS ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
.grid-3-1 { grid-template-columns: 3fr 1fr; }

/* ---------- EMPTY / STATES ---------- */
.empty {
  text-align: center;
  padding: 48px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
}
.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}
.empty-icon svg { width: 26px; height: 26px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.empty-text { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; max-width: 360px; margin-left: auto; margin-right: auto; }

.alert {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  align-items: flex-start;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert.success { background: var(--success-50); border-color: transparent; color: var(--success); }
.alert.warning { background: var(--warning-50); border-color: transparent; color: var(--warning); }
.alert.danger { background: var(--danger-50); border-color: transparent; color: var(--danger); }
.alert.info { background: var(--info-50); border-color: transparent; color: var(--info); }
.alert-title { font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.alert-body { color: var(--text-secondary); font-size: 13px; }
.alert.success .alert-body, .alert.warning .alert-body, .alert.danger .alert-body, .alert.info .alert-body { color: inherit; opacity: 0.9; }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- CHARTS ---------- */
.chart-container { width: 100%; }
.chart-legend { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 200px; padding: 0 4px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.bar-stack { width: 100%; max-width: 40px; background: var(--surface-3); border-radius: 6px 6px 0 0; overflow: hidden; display: flex; flex-direction: column-reverse; position: relative; }
.bar-segment { width: 100%; transition: opacity var(--t-fast) var(--ease); }
.bar-segment:hover { opacity: 0.85; }
.bar-label { font-size: 11px; color: var(--text-muted); }
.bar-value { font-size: 11px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ---------- TABS ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- VIEW SWITCH ---------- */
.view { display: none; animation: fadeIn 200ms ease; }
.view.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- HOME / DASHBOARD ---------- */
.greet {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.greet-text h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 4px; }
.greet-text p { color: var(--text-secondary); font-size: 14px; margin: 0; }
.greet-quick { display: flex; gap: 8px; }

.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.two-col {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* Current cycle card */
.cycle-card { padding: 24px; }
.cycle-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.cycle-badge {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.cycle-meta-text h3 { margin: 0; font-size: 17px; font-weight: 700; }
.cycle-meta-text p { margin: 2px 0 0; font-size: 13px; color: var(--text-secondary); }
.cycle-now {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  margin-bottom: 14px;
}
.cycle-now-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.cycle-now-mark svg { width: 16px; height: 16px; }
.cycle-now-body { flex: 1; min-width: 0; }
.cycle-now-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.cycle-now-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-top: 2px; }
.cycle-now-time { font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.cycle-progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}
.cycle-progress-row strong { font-weight: 600; }
.cycle-progress-row .muted { color: var(--text-muted); }

.cycle-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--divider);
}
.cycle-stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.cycle-stat-value { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-top: 4px; font-variant-numeric: tabular-nums; }
.cycle-stat-delta { font-size: 12px; color: var(--success); margin-top: 2px; display: flex; align-items: center; gap: 3px; }
.cycle-stat-delta svg { width: 11px; height: 11px; }

/* Subject list inside cycle */
.subj-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
}
.subj-row:last-child { border-bottom: 0; }
.subj-row-main { min-width: 0; }
.subj-row-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.subj-row-top .disc { flex: 1; min-width: 0; }
.subj-row-top strong { font-weight: 600; }
.subj-row-time { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.subj-row-progress { display: flex; align-items: center; gap: 10px; }
.subj-row-progress .progress { flex: 1; }
.subj-row-progress .pct { font-size: 12px; font-weight: 600; color: var(--text-primary); width: 36px; text-align: right; font-variant-numeric: tabular-nums; }

/* Performance ring card */
.perf-card { display: flex; flex-direction: column; gap: 16px; }
.perf-ring-wrap { display: flex; align-items: center; gap: 18px; }
.perf-ring-wrap .ring { flex-shrink: 0; }
.perf-info { flex: 1; }
.perf-info .badge { margin-bottom: 8px; }
.perf-info h3 { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.perf-info p { font-size: 13px; color: var(--text-secondary); margin: 0; }

.perf-list { display: flex; flex-direction: column; gap: 12px; }
.perf-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.perf-item .name { flex: 1; color: var(--text-primary); }
.perf-item .val { font-weight: 600; font-variant-numeric: tabular-nums; }
.perf-item .progress { width: 80px; }

/* Questions summary */
.questions-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.qs-block {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
}
.qs-block .v { font-size: 22px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.qs-block .l { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-top: 4px; }
.qs-block.success .v { color: var(--success); }
.qs-block.danger .v { color: var(--danger); }

.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.donut-legend-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.donut-legend-item .dot { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend-item .name { flex: 1; color: var(--text-primary); }
.donut-legend-item .val { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* ---------- STUDIES SCREEN ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-search { flex: 1; min-width: 220px; max-width: 360px; }
.toolbar-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.study-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--divider);
  transition: background var(--t-fast) var(--ease);
}
.study-row:last-child { border-bottom: 0; }
.study-row:hover { background: var(--surface-2); }
.study-row .disc-mark { width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0; }
.study-row .disc-mark-wrap {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--surface-2);
  display: grid; place-items: center;
}
.study-row-info { min-width: 0; }
.study-row-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.study-row-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.study-row-meta .dotsep { color: var(--border-strong); }
.study-row-time { font-size: 13px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; min-width: 60px; text-align: right; }
.study-row-type { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; background: var(--surface-2); }
.study-row-type svg { width: 12px; height: 12px; }
.study-row-actions { display: flex; gap: 4px; }

/* ---------- CYCLES SCREEN ---------- */
.cycle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cycle-card-large { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.cycle-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cycle-card-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.cycle-card-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.cycle-card-body { display: flex; align-items: center; gap: 18px; padding: 12px 0; border-top: 1px solid var(--divider); border-bottom: 1px solid var(--divider); }
.cycle-card-progress-num { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cycle-card-progress-meta { font-size: 12px; color: var(--text-muted); }
.cycle-card-foot { display: flex; align-items: center; justify-content: space-between; }

/* ---------- QUESTIONS SCREEN ---------- */
.q-stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

.subject-perf {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.subject-perf-row { display: grid; grid-template-columns: 200px 1fr 70px; align-items: center; gap: 16px; font-size: 13px; }
.subject-perf-row .name { font-weight: 500; color: var(--text-primary); }
.subject-perf-row .val { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.subject-perf-row .progress { flex: 1; }

/* ---------- HISTORY SCREEN ---------- */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.timeline-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.timeline-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--divider);
}
.timeline-day-title { font-size: 14px; font-weight: 600; }
.timeline-day-meta { font-size: 12px; color: var(--text-muted); }
.timeline-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-item-time { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 50px; }
.timeline-item-body { flex: 1; }
.timeline-item-title { font-size: 13.5px; font-weight: 600; }
.timeline-item-meta { font-size: 12px; color: var(--text-muted); }
.timeline-item-duration { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- DESIGN SYSTEM VIEW ---------- */
.ds-section { margin-bottom: 40px; }
.ds-section h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.ds-section .ds-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.ds-card { padding: 24px; }

.swatch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.swatch {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.swatch-color { height: 80px; }
.swatch-info { padding: 12px; background: var(--surface); }
.swatch-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.swatch-hex { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }
.swatch-token { font-size: 11px; color: var(--text-secondary); font-family: var(--font-mono); margin-top: 2px; }

.typo-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
}
.typo-row:last-child { border-bottom: 0; }
.typo-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.space-row { display: flex; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--divider); }
.space-row:last-child { border-bottom: 0; }
.space-token { width: 80px; font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }
.space-value { width: 60px; font-size: 12px; color: var(--text-muted); }
.space-bar { height: 12px; background: var(--primary); border-radius: 3px; }

.state-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }

/* ---------- MOBILE ---------- */
.mobile-menu-btn { display: none; }

@media (max-width: 1100px) {
  .grid-4, .hero-grid, .q-stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .cycle-grid, .three-col { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .grid-2-1, .grid-1-2, .grid-3-1 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--t-base) var(--ease);
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-base) var(--ease);
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  .mobile-menu-btn { display: grid; }
  .header { padding: 0 16px; }
  .search { width: auto; flex: 1; max-width: none; }
  .search kbd { display: none; }
  .profile-info { display: none; }
  .content { padding: 20px 16px 32px; }
  .grid-4, .hero-grid, .q-stats-row { grid-template-columns: 1fr; }
  .grid-3, .grid-2, .cycle-grid, .three-col, .two-col, .questions-summary { grid-template-columns: 1fr; }
  .study-row { grid-template-columns: auto 1fr; gap: 10px; }
  .study-row-time, .study-row-type { display: none; }
  .study-row-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .page-header { flex-direction: column; align-items: stretch; }
  .greet { flex-direction: column; align-items: stretch; }
  .greet-quick { justify-content: flex-start; }
  .perf-ring-wrap { flex-direction: column; text-align: center; }
  .typo-row { grid-template-columns: 1fr; gap: 4px; }
  .swatch-grid { grid-template-columns: repeat(2, 1fr); }
  .cycle-stats { grid-template-columns: 1fr 1fr; }
}

/* ---------- UTILITIES ---------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.relative { position: relative; }
