@font-face {
  font-family: "Montserrat";
  src: url("/assets/fonts/Montserrat.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #20201f;
  --ink-soft: #2b2a29;
  --paper: #eff4ed;
  --muted: #a8aca5;
  --line: rgba(255, 255, 255, .12);
  --coral: #ff6657;
  --violet: #706cff;
  --yellow: #ffd261;
  --mint: #c8ddd1;
  --cyan: #b7efff;
  --green: #4fd08b;
  --orange: #ff9d55;
  --radius: 28px;
  --safe-top: max(14px, env(safe-area-inset-top));
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: #c8d9cf;
  color: var(--paper);
  font-family: "Montserrat", system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

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

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .13;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}

.loading-screen {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--ink);
}

.loading-screen p { margin: 0; color: var(--muted); font-weight: 650; }

.loading-mark, .brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: var(--coral);
  color: var(--ink);
  font-size: 28px;
  font-weight: 900;
  transform: rotate(-4deg);
}

.loading-mark { animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { transform: rotate(4deg) scale(1.08); } }

.app-shell {
  position: relative;
  width: min(1460px, calc(100% - 48px));
  min-height: calc(100dvh - 48px);
  margin: 24px auto;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  overflow: hidden;
  background: var(--ink);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 34px;
  box-shadow: 0 28px 80px rgba(26, 35, 31, .24);
}

.sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
}

.sidebar .brand-mark { width: 52px; height: 52px; margin-bottom: 26px; }
.sidebar-spacer { flex: 1; }

.nav-button, .icon-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}

.nav-button {
  width: 52px;
  height: 52px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  color: #aeb0ab;
  font-size: 20px;
}

.nav-button:hover, .nav-button.active { background: var(--paper); color: var(--ink); }
.nav-button:active, .icon-button:active, .card-button:active { transform: scale(.96); }

.main-column { min-width: 0; }

.topbar {
  height: 96px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.breadcrumb { color: #737570; font-size: 13px; font-weight: 700; }
.breadcrumb strong { color: var(--paper); }
.user-chip { display: flex; align-items: center; gap: 11px; }
.user-copy { text-align: right; }
.user-copy strong, .user-copy span { display: block; }
.user-copy span { color: var(--muted); font-size: 11px; margin-top: 3px; }

.avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
  border: 3px solid var(--paper);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.screen { padding: 28px; min-height: calc(100dvh - 145px); }
.screen-enter { animation: screen-in .3s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 22px; }
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 850; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(29px, 4vw, 54px); line-height: .98; letter-spacing: -.055em; text-transform: uppercase; }
h2 { letter-spacing: -.035em; }
.page-heading p { max-width: 520px; margin-bottom: 4px; color: var(--muted); line-height: 1.55; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr .9fr .9fr;
  grid-auto-rows: minmax(170px, auto);
  gap: 18px;
}

.panel, .action-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, .12);
}

.panel { padding: 24px; background: var(--ink-soft); }
.panel-coral { background: var(--coral); color: var(--ink); }
.panel-violet { background: var(--violet); }
.panel-yellow { background: var(--yellow); color: var(--ink); }
.panel-mint { background: var(--mint); color: var(--ink); }
.panel-cyan { background: var(--cyan); color: var(--ink); }
.panel-dark { background: #282726; }
.span-2 { grid-column: span 2; }
.row-2 { grid-row: span 2; }

.panel-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel h2, .panel h3 { margin-bottom: 8px; text-transform: uppercase; }
.panel h2 { font-size: clamp(26px, 3vw, 43px); }
.panel h3 { font-size: 21px; }
.panel p { line-height: 1.5; opacity: .78; }

.arrow-badge, .round-action {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-size: 20px;
}

.readiness-value { margin-top: 26px; font-size: clamp(58px, 8vw, 112px); font-weight: 850; letter-spacing: -.08em; line-height: .8; }
.readiness-scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; margin-top: 26px; }
.readiness-scale i { display: block; height: 34px; background: rgba(32, 32, 31, .15); border-radius: 8px; }
.readiness-scale i.on { background: var(--ink); }

.metric-big { font-size: 48px; font-weight: 850; letter-spacing: -.06em; margin-top: 30px; }
.metric-caption { font-size: 12px; font-weight: 750; opacity: .7; }
.progress-track { height: 12px; margin-top: 18px; background: rgba(32, 32, 31, .14); border-radius: 20px; overflow: hidden; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: currentColor; }

.card-button, .primary-button, .secondary-button, .answer-button, .ticket-button, .segmented button {
  border: 0;
  cursor: pointer;
}

.card-button {
  position: absolute;
  inset: 0;
  width: 100%;
  background: transparent;
}
.card-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; }

.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.mode-card { min-height: 220px; }
.mode-card .metric-big { margin-top: 48px; }
.mode-card small { display: block; opacity: .7; line-height: 1.5; }

.list-stack { display: grid; gap: 12px; }
.list-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  border-radius: 20px;
  background: #2a2928;
  border: 1px solid var(--line);
}
.list-row h3 { margin: 0 0 5px; font-size: 16px; }
.list-row p { margin: 0; color: var(--muted); font-size: 12px; }
.mini-progress { width: 110px; height: 8px; border-radius: 10px; background: #44423f; overflow: hidden; }
.mini-progress i { display: block; height: 100%; background: var(--violet); }

.ticket-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.ticket-button {
  min-height: 70px;
  border-radius: 18px;
  background: #2b2a29;
  color: var(--paper);
  font-size: 18px;
  font-weight: 800;
  border: 1px solid var(--line);
}
.ticket-button.failed { background: var(--orange); color: var(--ink); }
.ticket-button.passed { background: var(--violet); }
.ticket-button.perfect { background: var(--green); color: var(--ink); }

.quiz-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(330px, .75fr); gap: 18px; }
.question-panel { padding: 0; }
.question-media {
  width: 100%;
  max-height: 48vh;
  display: block;
  object-fit: contain;
  background: #fff;
  border-radius: 28px 28px 0 0;
}
.question-content { padding: 24px; }
.question-content h2 { font-size: clamp(21px, 3vw, 34px); line-height: 1.2; text-transform: none; }
.quiz-side { display: flex; flex-direction: column; gap: 14px; }
.quiz-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 750; }
.quiz-progress { height: 8px; background: #444; border-radius: 10px; overflow: hidden; }
.quiz-progress i { display: block; height: 100%; background: var(--coral); }
.answers { display: grid; gap: 10px; }
.answer-button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 14px;
  border-radius: 18px;
  text-align: left;
  background: #343230;
  border: 1px solid var(--line);
}
.answer-button b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: #44413e; }
.answer-button.selected { background: var(--violet); }
.answer-button.correct { background: var(--green); color: var(--ink); }
.answer-button.wrong { background: var(--orange); color: var(--ink); }
.answer-button:disabled { cursor: default; opacity: 1; }

.primary-button, .secondary-button {
  min-height: 54px;
  padding: 0 20px;
  border-radius: 18px;
  font-weight: 800;
}
.primary-button { background: var(--coral); color: var(--ink); }
.secondary-button { background: var(--paper); color: var(--ink); }
.button-row { display: flex; gap: 10px; }
.button-row > * { flex: 1; }

.icon-button { width: 44px; height: 44px; border-radius: 15px; background: #343230; }
.icon-button.favorite { background: var(--yellow); color: var(--ink); }

details {
  border-top: 1px solid var(--line);
  padding: 15px 0 0;
  margin-top: 15px;
  line-height: 1.55;
}
summary { cursor: pointer; font-weight: 800; }
details p, details li { color: #c4c6c1; }

.result-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.result-metric { padding: 20px; border-radius: 20px; background: #302f2d; }
.result-metric b { display: block; font-size: 32px; margin-top: 12px; }
.result-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 8px; margin-top: 18px; }
.result-grid button { min-height: 48px; border: 0; border-radius: 14px; background: #3a3836; color: var(--paper); font-weight: 800; cursor: pointer; }
.result-grid .correct { background: var(--green); color: var(--ink); }
.result-grid .wrong { background: var(--orange); color: var(--ink); }

.stats-hero { display: grid; grid-template-columns: 1.2fr repeat(3, .7fr); gap: 14px; margin-bottom: 18px; }
.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td { padding: 14px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.stats-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 5px; gap: 5px; background: #353331; border-radius: 18px; }
.segmented button { min-height: 48px; border-radius: 14px; background: transparent; }
.segmented button.active { background: var(--violet); }

.empty-state { min-height: 360px; display: grid; place-content: center; justify-items: center; text-align: center; }
.empty-state strong { font-size: 64px; }
.empty-state p { max-width: 420px; color: var(--muted); line-height: 1.5; }

.bottom-nav { display: none; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 30px; transform: translate(-50%, 20px); padding: 14px 18px; border-radius: 15px; background: var(--paper); color: var(--ink); font-weight: 750; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: 0 12px 30px rgba(0,0,0,.25); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid .span-2 { grid-column: span 1; }
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .ticket-grid { grid-template-columns: repeat(5, 1fr); }
  .quiz-layout { grid-template-columns: 1fr; }
  .question-media { max-height: 42vh; }
  .stats-hero { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  body { background: var(--ink); }
  .app-shell { width: 100%; min-height: 100dvh; margin: 0; display: block; border: 0; border-radius: 0; padding-bottom: calc(78px + var(--safe-bottom)); }
  .sidebar { display: none; }
  .topbar { height: auto; min-height: 76px; padding: var(--safe-top) 18px 12px; border-bottom: 0; }
  .breadcrumb { display: none; }
  .user-chip { width: 100%; justify-content: space-between; flex-direction: row-reverse; }
  .user-copy { text-align: left; margin-right: auto; }
  .screen { min-height: 0; padding: 12px 14px 24px; }
  .page-heading { display: block; margin-bottom: 16px; }
  .page-heading p { margin-top: 10px; font-size: 13px; }
  h1 { font-size: 34px; }
  .dashboard-grid, .mode-grid { grid-template-columns: 1fr; gap: 12px; }
  .dashboard-grid { grid-auto-rows: auto; }
  .dashboard-grid .span-2, .dashboard-grid .row-2 { grid-column: auto; grid-row: auto; }
  .panel { padding: 20px; border-radius: 24px; }
  .dashboard-grid .panel { min-height: 160px; }
  .readiness-value { font-size: 74px; }
  .mode-card { min-height: 180px; }
  .mode-card .metric-big { margin-top: 26px; }
  .ticket-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .ticket-button { min-height: 58px; border-radius: 15px; }
  .list-row { padding: 16px; border-radius: 18px; }
  .quiz-layout { gap: 12px; }
  .question-content { padding: 18px; }
  .question-media { max-height: 34vh; }
  .answer-button { min-height: 58px; }
  .result-summary, .stats-hero { grid-template-columns: 1fr 1fr; }
  .result-grid { grid-template-columns: repeat(5, 1fr); }
  .bottom-nav {
    position: fixed;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    left: 10px;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    min-height: 66px;
    padding: 7px;
    background: rgba(45, 44, 42, .94);
    border: 1px solid var(--line);
    border-radius: 22px;
    backdrop-filter: blur(18px);
  }
  .bottom-nav .nav-button { width: auto; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
