:root {
  --c-bg:       #09090b;
  --c-bg1:      #111113;
  --c-bg2:      #18181b;
  --c-bg3:      #1f1f23;
  --c-bg4:      #27272a;
  --c-bg5:      #3f3f46;
  --c-border:   rgba(255,255,255,0.06);
  --c-border2:  rgba(255,255,255,0.11);
  --c-border3:  rgba(255,255,255,0.18);
  --c-text:     #fafafa;
  --c-text2:    #a1a1aa;
  --c-text3:    #71717a;
  --c-text4:    #52525b;

  --c-blue:     #3b82f6;
  --c-blue-l:   #60a5fa;
  --c-blue-bg:  rgba(59,130,246,0.12);
  --c-blue-bd:  rgba(59,130,246,0.28);

  --c-green:    #22c55e;
  --c-green-l:  #4ade80;
  --c-green-bg: rgba(34,197,94,0.12);
  --c-green-bd: rgba(34,197,94,0.28);

  --c-red:      #ef4444;
  --c-red-l:    #f87171;
  --c-red-bg:   rgba(239,68,68,0.12);
  --c-red-bd:   rgba(239,68,68,0.28);

  --c-amber:    #f59e0b;
  --c-amber-l:  #fbbf24;
  --c-amber-bg: rgba(245,158,11,0.12);
  --c-amber-bd: rgba(245,158,11,0.28);

  --c-violet:   #8b5cf6;
  --c-violet-bg:rgba(139,92,246,0.12);
  --c-violet-bd:rgba(139,92,246,0.28);
  --c-violet-l: #c4b5fd;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);

  --sidebar-w: 240px;
  --topbar-h:  54px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: 'Outfit', sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--c-bg5); border-radius: var(--radius-full); }
::-webkit-scrollbar-track { background: transparent; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

.flex           { display: flex; }
.flex-col       { display: flex; flex-direction: column; }
.flex-between   { display: flex; align-items: center; justify-content: space-between; }
.flex-center    { display: flex; align-items: center; justify-content: center; }
.items-center   { align-items: center; }
.gap-1          { gap: var(--space-1); }
.gap-2          { gap: var(--space-2); }
.gap-3          { gap: var(--space-3); }
.gap-4          { gap: var(--space-4); }
.grid           { display: grid; }
.grid-2         { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.grid-3         { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-3); }
.grid-4         { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--space-3); }
.center         { text-align: center; }
.truncate       { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full         { width: 100%; }
.mt-1           { margin-top: var(--space-1); }
.mt-2           { margin-top: var(--space-2); }
.mt-3           { margin-top: var(--space-3); }
.mt-4           { margin-top: var(--space-4); }
.mb-2           { margin-bottom: var(--space-2); }
.mb-3           { margin-bottom: var(--space-3); }
.mb-4           { margin-bottom: var(--space-4); }
.mb-6           { margin-bottom: var(--space-6); }
.p-4            { padding: var(--space-4); }
.hidden         { display: none !important; }
.relative       { position: relative; }
.overflow-y     { overflow-y: auto; }
.min-h-screen   { min-height: 100vh; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--c-bg1);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.25s ease;
}
.sidebar-logo {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.logo-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--c-blue), var(--c-violet));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 16px; height: 16px; fill: white; }
.logo-text { font-family: 'Playfair Display', serif; font-size: 17px; }
.logo-text em { color: var(--c-blue-l); font-style: normal; }

.sidebar-nav { flex: 1; padding: var(--space-2) var(--space-2); }
.nav-section-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--c-text4);
  padding: var(--space-3) var(--space-2) var(--space-1);
}
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--c-text3);
  font-size: 13.5px; font-weight: 400;
  border: none; background: none; width: 100%;
  text-align: left; margin-bottom: 1px;
  transition: all 0.13s;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .7; }
.nav-item:hover { color: var(--c-text); background: var(--c-bg3); }
.nav-item.active { color: var(--c-blue-l); background: var(--c-blue-bg); font-weight: 500; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  background: var(--c-blue-bg); color: var(--c-blue-l);
  padding: 2px 7px; border-radius: var(--radius-full);
  border: 1px solid var(--c-blue-bd);
}
.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}
.user-card {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer; transition: background .15s;
}
.user-card:hover { background: var(--c-bg3); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-blue), var(--c-violet));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--c-text3); }

.hamburger {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 1px solid var(--c-border2);
  border-radius: var(--radius-md); background: none; color: var(--c-text2);
}
.hamburger svg { width: 18px; height: 18px; }
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 99;
}

.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-w));
}

.topbar {
  height: var(--topbar-h);
  background: var(--c-bg1);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky; top: 0; z-index: 40;
  flex-shrink: 0;
}
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); font-size: 13px; color: var(--c-text3); }
.breadcrumb .crumb-current { color: var(--c-text); font-weight: 500; }
.breadcrumb-sep { width: 12px; height: 12px; opacity: .5; }

.timer-pill {
  display: none; align-items: center; gap: var(--space-1);
  background: var(--c-amber-bg); border: 1px solid var(--c-amber-bd);
  color: var(--c-amber-l); padding: 5px var(--space-3);
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.timer-pill.show { display: flex; }
.timer-pill svg { width: 12px; height: 12px; }

.api-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--c-bg2);
  border: 1px solid var(--c-border2);
  font-size: 11px;
  color: var(--c-text3);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.api-status-pill .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-amber);
  box-shadow: 0 0 0 0 rgba(245,158,11,0.55);
  transition: background .2s, box-shadow .2s;
}
.api-status-pill.ready {
  border-color: var(--c-green-bd);
  background: var(--c-green-bg);
  color: var(--c-green-l);
  box-shadow: 0 0 0 1px rgba(34,197,94,0.18);
}
.api-status-pill.ready .status-dot {
  background: var(--c-green);
  box-shadow: 0 0 0 4px rgba(34,197,94,0.35);
}
.api-status-pill.pending {
  border-color: var(--c-amber-bd);
  background: var(--c-amber-bg);
  color: var(--c-amber-l);
}
.api-status-pill.pending .status-dot {
  background: var(--c-amber);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.35);
}

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-md);
  border: 1px solid var(--c-border2); background: none;
  color: var(--c-text2); display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.icon-btn:hover { background: var(--c-bg3); color: var(--c-text); }
.icon-btn svg { width: 15px; height: 15px; }

.content { flex: 1; padding: var(--space-7) var(--space-7) 64px; overflow-y: auto; }

.page { display: none; animation: fadeUp .2s ease both; }
.page.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--c-text3); margin-top: 3px; margin-bottom: var(--space-6); }
.section-label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--c-text4);
  font-weight: 600; margin-bottom: var(--space-3);
}

.card {
  background: var(--c-bg2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5);
}
.card-sm { padding: var(--space-4); border-radius: var(--radius-md); }

.stat-card {
  background: var(--c-bg2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card.blue::after  { background: linear-gradient(90deg, var(--c-blue), var(--c-violet)); }
.stat-card.green::after { background: linear-gradient(90deg, var(--c-green), #84cc16); }
.stat-card.amber::after { background: linear-gradient(90deg, var(--c-amber), #f97316); }
.stat-card.red::after   { background: linear-gradient(90deg, var(--c-red), #ec4899); }
.stat-label { font-size: 11px; font-weight: 500; color: var(--c-text3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: var(--space-2); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--c-text3); margin-top: 4px; }
.stat-card.blue  .stat-value { color: var(--c-blue-l); }
.stat-card.green .stat-value { color: var(--c-green-l); }
.stat-card.amber .stat-value { color: var(--c-amber-l); }
.stat-card.red   .stat-value { color: var(--c-red-l); }

.chart-card { background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: var(--space-5); }
.chart-card h4 { font-size: 13px; font-weight: 500; color: var(--c-text2); margin-bottom: var(--space-4); }
.chart-wrap { position: relative; height: 190px; }

.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 9px var(--space-5); border-radius: var(--radius-md);
  border: 1px solid var(--c-border2); background: none;
  color: var(--c-text2); font-size: 13.5px; font-weight: 500;
  transition: all .14s;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn:hover { background: var(--c-bg3); color: var(--c-text); border-color: var(--c-border3); }
.btn-primary { background: var(--c-blue); border-color: var(--c-blue); color: #fff; }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }
.btn-primary:disabled { background: var(--c-bg4); border-color: var(--c-border); color: var(--c-text4); cursor: not-allowed; }
.btn-success { background: var(--c-green-bg); border-color: var(--c-green-bd); color: var(--c-green-l); }
.btn-danger  { background: var(--c-red-bg);   border-color: var(--c-red-bd);   color: var(--c-red-l); }
.btn-sm { padding: 6px var(--space-3); font-size: 12px; }
.btn-row { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-6); }

.tag-grid { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tag {
  padding: 6px var(--space-4); border-radius: var(--radius-full);
  border: 1px solid var(--c-border2); color: var(--c-text3);
  font-size: 13px; cursor: pointer;
  transition: all .13s; user-select: none;
}
.tag:hover { border-color: var(--c-blue-bd); color: var(--c-text); }
.tag.sel { border-color: var(--c-blue-bd); color: var(--c-blue-l); background: var(--c-blue-bg); font-weight: 500; }

.toggle {
  width: 36px; height: 20px; border-radius: var(--radius-full);
  background: var(--c-bg5); position: relative; cursor: pointer;
  border: none; flex-shrink: 0; transition: background .2s;
}
.toggle.on { background: var(--c-blue); }
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: white; transition: transform .18s;
}
.toggle.on::after { transform: translateX(16px); }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--c-border);
}
.toggle-row:last-child { border: none; padding-bottom: 0; }
.toggle-row span { font-size: 13px; color: var(--c-text2); }

.wizard { display: flex; align-items: center; margin-bottom: var(--space-7); overflow-x: auto; }
.ws { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.ws-num {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--c-border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--c-text3);
  transition: all .2s;
}
.ws-lbl { font-size: 12.5px; color: var(--c-text3); white-space: nowrap; }
.ws.active .ws-num { border-color: var(--c-blue); color: var(--c-blue-l); background: var(--c-blue-bg); }
.ws.active .ws-lbl { color: var(--c-text); font-weight: 500; }
.ws.done .ws-num { border-color: var(--c-green); background: var(--c-green); color: #fff; font-size: 10px; }
.ws.done .ws-lbl { color: var(--c-green); }
.ws-line { flex: 1; height: 1px; background: var(--c-border2); margin: 0 var(--space-2); min-width: 16px; }
.ws-line.done { background: var(--c-green); }

.upload-zone {
  border: 1.5px dashed var(--c-border2); border-radius: var(--radius-lg);
  padding: 40px var(--space-6); text-align: center; cursor: pointer;
  transition: all .2s; position: relative; display: block;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--c-blue); background: var(--c-blue-bg); }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-zone svg.upload-ico { width: 44px; height: 44px; margin: 0 auto var(--space-3); display: block; color: var(--c-text3); }
.upload-zone h3 { font-size: 15px; font-weight: 500; margin-bottom: var(--space-1); }
.upload-zone p { font-size: 12px; color: var(--c-text3); }
.ext-badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 5px; background: var(--c-bg3); color: var(--c-text2); border: 1px solid var(--c-border2); margin: 2px; }

.file-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-4); }
.file-item {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--c-bg2); border: 1px solid var(--c-border);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4);
}
.file-ext {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; flex-shrink: 0;
}
.file-ext.pdf  { background: var(--c-red-bg);  color: var(--c-red-l);  border: 1px solid var(--c-red-bd); }
.file-ext.docx { background: var(--c-blue-bg); color: var(--c-blue-l); border: 1px solid var(--c-blue-bd); }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; }
.file-size { font-size: 11px; color: var(--c-text3); margin-top: 1px; }
.file-rm { background: none; border: none; color: var(--c-text3); font-size: 18px; padding: 4px; transition: color .15s; line-height: 1; }
.file-rm:hover { color: var(--c-red); }

.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-bottom: var(--space-4); }
.config-block { background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: var(--space-5); }
.config-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--c-text3); font-weight: 600; margin-bottom: var(--space-4); display: block; }
.qty-row { display: flex; align-items: center; gap: var(--space-4); }
.qty-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--c-border2); background: none;
  color: var(--c-text); font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.qty-btn:hover { border-color: var(--c-blue); color: var(--c-blue-l); background: var(--c-blue-bg); }
.qty-val { font-size: 26px; font-weight: 700; min-width: 40px; text-align: center; }

.summary-card { background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); }
.summary-card h4 { font-size: 11px; color: var(--c-text3); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; margin-bottom: var(--space-3); }
.sum-row { display: flex; gap: var(--space-3); padding: 5px 0; font-size: 13px; align-items: flex-start; }
.sum-k { color: var(--c-text3); width: 110px; flex-shrink: 0; }
.sum-v { color: var(--c-text); }

.banca-panel {
  background: var(--c-bg2); border: 1px solid var(--c-blue-bd);
  border-radius: var(--radius-lg); padding: var(--space-5);
  position: relative; overflow: hidden; margin-bottom: var(--space-4);
}
.banca-panel::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--c-blue), var(--c-violet));
}
.banca-panel-title { display: flex; align-items: center; gap: var(--space-2); margin-bottom: 4px; }
.banca-panel-title span { font-size: 12px; font-weight: 600; color: var(--c-blue-l); text-transform: uppercase; letter-spacing: .07em; }
.ai-badge { font-size: 10px; font-weight: 700; background: var(--c-blue-bg); color: var(--c-blue-l); border: 1px solid var(--c-blue-bd); padding: 2px 7px; border-radius: var(--radius-full); }
.banca-panel-desc { font-size: 12px; color: var(--c-text3); line-height: 1.6; margin-bottom: var(--space-4); }

.loading-view {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 400px; text-align: center;
}
.spinner { width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--c-bg4); border-top-color: var(--c-blue); animation: spin .7s linear infinite; margin-bottom: var(--space-5); }
@keyframes spin { to { transform: rotate(360deg); } }
.load-step  { font-size: 15px; font-weight: 500; margin-bottom: var(--space-1); }
.load-sub   { font-size: 12px; color: var(--c-text3); margin-bottom: var(--space-5); }
.prog-track { width: 260px; height: 3px; background: var(--c-bg4); border-radius: var(--radius-full); overflow: hidden; }
.prog-fill  { height: 100%; background: var(--c-blue); border-radius: var(--radius-full); transition: width .5s ease; }

.quiz-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); flex-wrap: wrap; gap: var(--space-2); }
.quiz-meta { font-size: 13px; color: var(--c-text3); }
.quiz-badges { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.q-badge-subj { font-size: 12px; font-weight: 600; padding: 4px var(--space-3); border-radius: var(--radius-full); background: var(--c-blue-bg); color: var(--c-blue-l); border: 1px solid var(--c-blue-bd); }
.q-badge-banca { font-size: 11px; font-weight: 600; padding: 3px var(--space-3); border-radius: var(--radius-full); background: var(--c-violet-bg); color: var(--c-violet-l); border: 1px solid var(--c-violet-bd); }

.quiz-prog { height: 3px; background: var(--c-bg4); border-radius: var(--radius-full); margin-bottom: var(--space-6); }
.quiz-prog-fill { height: 100%; background: var(--c-blue); border-radius: var(--radius-full); transition: width .35s ease; }

.quiz-stats-strip { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); flex-wrap: wrap; gap: var(--space-2); }
.qs-item { display: flex; align-items: center; gap: var(--space-1); font-size: 12px; color: var(--c-text3); }
.qs-item svg { width: 12px; height: 12px; }
.qs-item strong { color: var(--c-text); }

.question-card { background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: var(--space-6); }
.q-text { font-size: 15.5px; line-height: 1.75; margin-bottom: var(--space-5); }
.options { display: flex; flex-direction: column; gap: var(--space-2); }
.opt {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  border: 1px solid var(--c-border2); cursor: pointer; transition: all .12s;
}
.opt:hover:not(.locked) { border-color: var(--c-blue-bd); background: var(--c-blue-bg); }
.opt.picked  { border-color: var(--c-blue-bd);  background: var(--c-blue-bg); }
.opt.correct { border-color: var(--c-green-bd); background: var(--c-green-bg); }
.opt.wrong   { border-color: var(--c-red-bd);   background: var(--c-red-bg); }
.opt.faded   { opacity: .4; }
.opt.locked  { cursor: default; }
.opt-key {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--c-border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--c-text3);
  flex-shrink: 0; margin-top: 1px;
}
.opt.picked  .opt-key { background: var(--c-blue);  border-color: var(--c-blue);  color: #fff; }
.opt.correct .opt-key { background: var(--c-green); border-color: var(--c-green); color: #fff; }
.opt.wrong   .opt-key { background: var(--c-red);   border-color: var(--c-red);   color: #fff; }
.opt-txt { font-size: 13.5px; line-height: 1.55; }

.feedback { margin-top: var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: 13px; line-height: 1.65; display: none; }
.feedback.show { display: block; }
.feedback.ok   { background: var(--c-green-bg); border: 1px solid var(--c-green-bd); color: #86efac; }
.feedback.fail { background: var(--c-red-bg);   border: 1px solid var(--c-red-bd);   color: #fca5a5; }
.fb-head { font-weight: 700; margin-bottom: 4px; font-size: 14px; }
.fb-section-lbl { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; margin-top: var(--space-2); margin-bottom: 2px; }
.fb-artigo-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  background: rgba(139,92,246,0.15); color: var(--c-violet-l);
  border: 1px solid rgba(139,92,246,0.3);
  border-radius: var(--radius-full);
  padding: 2px 10px; margin-bottom: var(--space-2);
}
.fb-text { font-size: 13px; margin: 0 0 2px; line-height: 1.6; }
.fb-peg  { opacity: .85; }
.fb-analise { margin-top: 6px; display: flex; flex-direction: column; gap: 5px; }
.fb-analise-item { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.55; }
.fb-analise-letra { flex-shrink: 0; width: 20px; height: 20px; border-radius: 4px; background: var(--c-bg4); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--c-text2); }
.fb-analise-txt { color: var(--c-text2); }

.quiz-foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-5); flex-wrap: wrap; gap: var(--space-3); }
.breadcrumb-dots { display: flex; flex-wrap: wrap; gap: 5px; }
.bd { width: 9px; height: 9px; border-radius: 50%; background: var(--c-bg5); transition: background .2s; cursor: pointer; }
.bd.cur       { background: var(--c-blue); }
.bd.ok-done   { background: var(--c-green); }
.bd.fail-done { background: var(--c-red); }
.bd.skipped   { background: var(--c-amber); }

.result-hero {
  text-align: center; background: var(--c-bg2); border: 1px solid var(--c-border);
  border-radius: var(--radius-lg); padding: var(--space-8) var(--space-6);
  margin-bottom: var(--space-5); position: relative; overflow: hidden;
}
.result-hero::before {
  content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,.04) 0%, transparent 70%);
  pointer-events: none;
}
.res-pct { font-family: 'Playfair Display',serif; font-size: 80px; line-height: 1; }
.res-pct.great { color: var(--c-green-l); }
.res-pct.ok    { color: var(--c-amber-l); }
.res-pct.bad   { color: var(--c-red-l); }
.res-msg { font-size: 14px; color: var(--c-text2); margin: 8px 0 var(--space-5); }
.res-bar-wrap { max-width: 340px; margin: 0 auto; }
.res-bar { height: 5px; background: var(--c-bg4); border-radius: var(--radius-full); overflow: hidden; }
.res-bar-fill { height: 100%; border-radius: var(--radius-full); transition: width 1.2s cubic-bezier(.4,0,.2,1); }
.res-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--space-3); margin-top: var(--space-5); }
.rs { background: var(--c-bg3); border-radius: var(--radius-md); padding: var(--space-4) var(--space-2); text-align: center; }
.rs-v { font-size: 26px; font-weight: 700; }
.rs-l { font-size: 11px; color: var(--c-text3); margin-top: 3px; }
.rs.ok   .rs-v { color: var(--c-green-l); }
.rs.fail .rs-v { color: var(--c-red-l); }

.bm-row { margin-bottom: var(--space-3); }
.bm-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bm-bar { height: 5px; background: var(--c-bg4); border-radius: var(--radius-full); overflow: hidden; }
.bm-fill { height: 100%; border-radius: var(--radius-full); }

.review-item {
  background: var(--c-bg2); border-radius: var(--radius-lg);
  border: 1px solid var(--c-border); border-left: 3px solid var(--c-border2);
  padding: var(--space-4) var(--space-4); margin-bottom: var(--space-2);
  cursor: pointer; transition: border-color .15s;
}
.review-item.ok   { border-left-color: var(--c-green); }
.review-item.fail { border-left-color: var(--c-red); }
.review-item:hover { border-color: var(--c-border2); }
.ri-q   { font-size: 13.5px; font-weight: 500; margin-bottom: 5px; }
.ri-ans { font-size: 12px; color: var(--c-text3); }
.ri-ans .ok   { color: var(--c-green-l); font-weight: 600; }
.ri-ans .fail { color: var(--c-red-l);   font-weight: 600; }
.ri-explain { font-size: 12px; color: var(--c-text2); margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--c-border); display: none; line-height: 1.65; }
.review-item.open .ri-explain { display: block; }

.history-item {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--c-bg2); border: 1px solid var(--c-border);
  border-radius: var(--radius-lg); margin-bottom: var(--space-2);
  cursor: pointer; transition: border-color .15s;
}
.history-item:hover { border-color: var(--c-border2); }
.hi-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hi-main { flex: 1; min-width: 0; }
.hi-title { font-size: 13.5px; font-weight: 500; }
.hi-meta  { font-size: 11px; color: var(--c-text3); margin-top: 2px; }
.hi-badge { font-size: 11px; color: var(--c-text3); background: var(--c-bg3); padding: 3px 9px; border-radius: var(--radius-full); white-space: nowrap; }
.score-pill { font-size: 13px; font-weight: 700; padding: 4px var(--space-3); border-radius: var(--radius-full); white-space: nowrap; }
.score-pill.g { background: var(--c-green-bg); color: var(--c-green-l); border: 1px solid var(--c-green-bd); }
.score-pill.a { background: var(--c-amber-bg); color: var(--c-amber-l); border: 1px solid var(--c-amber-bd); }
.score-pill.r { background: var(--c-red-bg);   color: var(--c-red-l);   border: 1px solid var(--c-red-bd); }

.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: var(--space-3); }
.mat-card { background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: var(--space-4); cursor: pointer; transition: all .15s; }
.mat-card:hover { border-color: var(--c-border2); transform: translateY(-2px); }
.mat-icon { width: 36px; height: 36px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-3); font-size: 17px; }
.mat-name  { font-size: 13.5px; font-weight: 600; margin-bottom: var(--space-2); }
.mat-bar   { height: 4px; background: var(--c-bg4); border-radius: var(--radius-full); overflow: hidden; margin-bottom: var(--space-2); }
.mat-fill  { height: 100%; border-radius: var(--radius-full); }
.mat-stats { font-size: 11px; color: var(--c-text3); }

.week-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: var(--space-2); margin-bottom: var(--space-5); }
.day-cell { background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-2); text-align: center; }
.day-cell.today { border-color: var(--c-blue-bd); background: var(--c-blue-bg); }
.day-cell.today .day-num { color: var(--c-blue-l); }
.day-name { font-size: 10px; color: var(--c-text3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.day-num  { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.day-dot  { width: 6px; height: 6px; border-radius: 50%; background: var(--c-blue); margin: 0 auto; display: none; }
.day-cell.has-tasks .day-dot { display: block; }

.task-item { display: flex; align-items: center; gap: var(--space-3); background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-2); transition: border-color .15s; }
.task-item:hover { border-color: var(--c-border2); }
.task-check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--c-border2); flex-shrink: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.task-check.done { background: var(--c-green); border-color: var(--c-green); }
.task-check.done::after { content: '✓'; font-size: 10px; color: #fff; font-weight: 700; }
.task-info { flex: 1; }
.task-name { font-size: 13px; font-weight: 500; }
.task-sub  { font-size: 11px; color: var(--c-text3); margin-top: 1px; }
.task-badge { font-size: 10px; padding: 3px 8px; border-radius: var(--radius-full); font-weight: 600; }
.cron-prog-wrap { background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); margin-bottom: var(--space-5); }
.cron-prog-header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: var(--space-2); }
.cron-prog-bar { height: 6px; background: var(--c-bg4); border-radius: var(--radius-full); overflow: hidden; }
.cron-prog-fill { height: 100%; border-radius: var(--radius-full); background: var(--c-green); transition: width .6s ease; }

.flashcard { width: 100%; max-width: 560px; margin: 0 auto; height: 220px; position: relative; cursor: pointer; transform-style: preserve-3d; transition: transform .5s; }
.flashcard.flipped { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: var(--radius-lg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-6); text-align: center; }
.fc-face.back { transform: rotateY(180deg); }
.fc-lbl  { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--c-text4); font-weight: 600; margin-bottom: var(--space-3); }
.fc-text { font-size: 16px; font-weight: 500; line-height: 1.6; }
.fc-actions { display: flex; gap: var(--space-2); justify-content: center; margin-top: var(--space-4); }

.srs-btn {
  padding: 8px var(--space-4); border-radius: var(--radius-md);
  border: 1px solid var(--c-border2); background: none; font-size: 12.5px;
  font-weight: 500; cursor: pointer; transition: all .13s;
}
.srs-btn.hard  { color: var(--c-red-l);   background: var(--c-red-bg);   border-color: var(--c-red-bd); }
.srs-btn.medium{ color: var(--c-amber-l); background: var(--c-amber-bg); border-color: var(--c-amber-bd); }
.srs-btn.easy  { color: var(--c-green-l); background: var(--c-green-bg); border-color: var(--c-green-bd); }
.srs-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }

.chat-wrap { display: flex; flex-direction: column; }
.chat-msgs { min-height: 320px; max-height: 520px; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-4); padding: 4px 0; margin-bottom: var(--space-4); }
.msg { display: flex; gap: var(--space-2); align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.msg.ai   .msg-avatar { background: linear-gradient(135deg, var(--c-blue), var(--c-violet)); color: #fff; }
.msg.user .msg-avatar { background: var(--c-bg4); color: var(--c-text2); }
.msg-bubble { max-width: 80%; padding: 11px var(--space-4); font-size: 13.5px; line-height: 1.65; }
.msg.ai   .msg-bubble { background: var(--c-bg2); border: 1px solid var(--c-border); border-radius: 2px var(--radius-lg) var(--radius-lg) var(--radius-lg); }
.msg.user .msg-bubble { background: var(--c-blue); color: #fff; border-radius: var(--radius-lg) 2px var(--radius-lg) var(--radius-lg); }
.chat-input-row { display: flex; gap: var(--space-2); border-top: 1px solid var(--c-border); padding-top: var(--space-4); }
.chat-input { flex: 1; background: var(--c-bg2); border: 1px solid var(--c-border2); border-radius: var(--radius-lg); padding: 10px var(--space-4); color: var(--c-text); font-size: 13.5px; resize: none; min-height: 42px; max-height: 120px; transition: border-color .15s; }
.chat-input:focus { outline: none; border-color: var(--c-blue-bd); }
.chat-input::placeholder { color: var(--c-text4); }
.chat-send { width: 42px; height: 42px; border-radius: var(--radius-md); background: var(--c-blue); border: none; color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .15s; }
.chat-send:hover { background: #2563eb; }
.chat-send svg { width: 16px; height: 16px; }
.chat-typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--c-text3); animation: bounce 1.2s infinite; margin: 0 1px; }
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%,80%,100%{transform:translateY(0)}40%{transform:translateY(-5px)} }

.empty-state { text-align: center; padding: 48px var(--space-4); color: var(--c-text3); }
.empty-state svg { width: 44px; height: 44px; margin: 0 auto var(--space-3); display: block; opacity: .3; }
.empty-state p { font-size: 13px; }

#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none; }
.toast { padding: 11px var(--space-4); border-radius: var(--radius-md); font-size: 13px; font-weight: 500; animation: tin .2s ease; max-width: 300px; pointer-events: all; }
.toast.ok   { background: #14532d; border: 1px solid var(--c-green-bd); color: var(--c-green-l); }
.toast.err  { background: #450a0a; border: 1px solid var(--c-red-bd);   color: var(--c-red-l); }
.toast.info { background: #1e3a5f; border: 1px solid var(--c-blue-bd);  color: var(--c-blue-l); }
@keyframes tin { from{transform:translateX(40px);opacity:0} to{transform:translateX(0);opacity:1} }

.dash-hero { background: linear-gradient(135deg, var(--c-bg2) 0%, var(--c-bg3) 100%); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: var(--space-8); margin-bottom: var(--space-5); position: relative; overflow: hidden; }
.dash-hero::before { content: ''; position: absolute; top: -60px; right: -60px; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(circle, rgba(59,130,246,.07) 0%, transparent 70%); pointer-events: none; }
.dash-hero h2 { font-family: 'Playfair Display',serif; font-size: 26px; margin-bottom: 6px; }
.dash-hero p  { font-size: 13px; color: var(--c-text2); }

.rank-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--c-border); }
.rank-item:last-child { border: none; }
.rank-num { width: 22px; font-size: 12px; font-weight: 700; color: var(--c-text4); flex-shrink: 0; }
.rank-name { flex: 1; font-size: 13px; }
.rank-bar-wrap { width: 80px; }
.rank-bar { height: 4px; background: var(--c-bg4); border-radius: var(--radius-full); overflow: hidden; }
.rank-fill { height: 100%; border-radius: var(--radius-full); }
.rank-pct { width: 36px; font-size: 12px; font-weight: 600; text-align: right; }

.step2-materias {
  transition: opacity .18s ease, transform .18s ease;
  opacity: 1;
  transform: translateY(0);
}
.step2-materias.collapsed {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  height: 0;
  overflow: hidden;
}

@media (max-width: 900px) {
  :root { --sidebar-w: 56px; }
  .sidebar-logo .logo-text { display: none; }
  .nav-item span, .nav-badge, .nav-section-label, .user-info { display: none; }
  .sidebar-logo { padding: var(--space-4); justify-content: center; }
  .nav-item { justify-content: center; padding: var(--space-2); }
  .nav-item svg { opacity: 1; }
  .user-card { justify-content: center; padding: var(--space-2); }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2, .config-grid { grid-template-columns: 1fr; }
  .week-grid { grid-template-columns: repeat(4,1fr); }
}
@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-wrap { margin-left: 0; width: 100%; }
  .hamburger { display: flex; }
  .content { padding: var(--space-4) var(--space-4) 64px; }
  .topbar { padding: 0 var(--space-4); }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .res-stats { grid-template-columns: repeat(3,1fr); }
  .week-grid { grid-template-columns: repeat(4,1fr); }
  .quiz-stats-strip { flex-direction: column; align-items: flex-start; }
  .wizard { gap: 0; }
  .ws-lbl { display: none; }
  .history-item .hi-badge { display: none; }
}

.edital-loading { display:flex; flex-direction:column; align-items:center; justify-content:center; padding: 32px; text-align:center; gap:12px; }
.edital-loading .ring { width:36px; height:36px; border:3px solid var(--c-bg4); border-top-color:var(--c-blue); border-radius:50%; animation:spin .7s linear infinite; }
.extracted-badge { display:inline-flex; align-items:center; gap:6px; font-size:11px; font-weight:600; padding:3px 10px; border-radius:var(--radius-full); background:var(--c-green-bg); color:var(--c-green-l); border:1px solid var(--c-green-bd); }
.extracted-badge.warn { background:var(--c-amber-bg); color:var(--c-amber-l); border-color:var(--c-amber-bd); }
.cargo-materia-map { background:var(--c-bg3); border:1px solid var(--c-border); border-radius:var(--radius-md); padding:10px 14px; margin-top:8px; font-size:12px; color:var(--c-text3); line-height:1.6; max-height:120px; overflow-y:auto; }
.cargo-tag-with-materias { display:flex; flex-direction:column; gap:4px; }
.cargo-tag-materias-hint { font-size:10px; color:var(--c-text4); margin-top:2px; }
.step2-source-badge { font-size:11px; padding:3px 10px; border-radius:var(--radius-full); margin-bottom:12px; display:inline-flex; align-items:center; gap:5px; }
.step2-source-badge.from-edital { background:var(--c-blue-bg); color:var(--c-blue-l); border:1px solid var(--c-blue-bd); }
.step2-source-badge.from-default { background:var(--c-bg3); color:var(--c-text3); border:1px solid var(--c-border2); }

/* ============================================================
   AUTHENTICATION STYLES
   Control visibility of app and login overlay
   ============================================================ */

/* Default state: show login, hide app */
#app-container {
  display: none !important;
}

#login-overlay {
  display: flex !important;
}

/* Authenticated state: show app, hide login */
body.auth-ready #app-container {
  display: block !important;
}

body.auth-ready #login-overlay {
  display: none !important;
}