:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --panel: #151820;
  --panel-2: #1c202a;
  --panel-3: #222835;
  --text: #f5f6f8;
  --muted: #a9b0be;
  --line: #303746;
  --accent: #d9b768;
  --accent-strong: #f1d586;
  --blue: #8ab4ff;
  --green: #72d6a3;
  --red: #ff7a7a;
  --shadow: 0 20px 70px rgba(0, 0, 0, .35);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #11141b 0%, var(--bg) 42%, #08090c 100%);
  color: var(--text);
  padding: 24px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.auth-layout {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.surface {
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .015)), var(--panel);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-panel,
.start-panel,
.question-panel,
.result-panel {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 34px;
}

.auth-panel {
  width: min(460px, 100%);
}

.eyebrow {
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 10px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: 42px;
}

h2 {
  font-size: 30px;
}

.lead,
.help-text,
.muted {
  color: var(--muted);
  line-height: 1.55;
}

.lead {
  margin: 14px 0 26px;
  font-size: 18px;
}

.field {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.field span {
  color: var(--muted);
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #0c0f15;
  color: var(--text);
  padding: 0 14px;
}

.field input:focus,
.field select:focus,
.result-text:focus {
  outline: 2px solid rgba(217, 183, 104, .45);
  outline-offset: 2px;
}

.form-error {
  color: var(--red);
  font-weight: 800;
  margin: 12px 0;
}

.primary-btn,
.ghost-btn,
.tab-btn {
  border: 0;
  border-radius: var(--radius);
  min-height: 48px;
  padding: 0 18px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, background .12s ease, border-color .12s ease;
}

.primary-btn {
  color: #11100b;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  box-shadow: 0 14px 34px rgba(217, 183, 104, .16);
}

.primary-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost-btn,
.tab-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, .1);
}

.compact {
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}

.primary-btn:not(:disabled):active,
.ghost-btn:active,
.tab-btn:active,
.rating-btn:active {
  transform: translateY(1px);
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 8px 0 18px;
}

.header-actions,
.topbar,
.button-row,
.scale-info,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  align-items: center;
}

.user-pill {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(114, 214, 163, .28);
  border-radius: var(--radius);
  background: rgba(114, 214, 163, .1);
  color: var(--green);
  padding: 0 12px;
  font-weight: 850;
}

.tabbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.tab-btn.active {
  background: #2a2f3b;
  border-color: rgba(217, 183, 104, .58);
  color: var(--accent-strong);
}

.view-stack {
  display: grid;
  gap: 18px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 96px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: var(--radius);
  background: var(--panel);
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 28px;
  line-height: 1.1;
}

.dashboard-panel,
.detail-panel {
  padding: 24px;
}

.section-head {
  margin-bottom: 18px;
  align-items: flex-start;
}

.section-head h2 {
  font-size: 24px;
}

.section-head p {
  margin: 6px 0 0;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  color: var(--text);
}

.score-strip {
  border: 1px solid rgba(114, 214, 163, .3);
  border-radius: var(--radius);
  background: rgba(114, 214, 163, .1);
  color: var(--green);
  font-size: 22px;
  font-weight: 900;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.rubric-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.rubric-item {
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .025);
  padding: 14px;
}

.rubric-item strong {
  display: block;
  margin-bottom: 10px;
}

.answer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.answer-grid span {
  border-radius: var(--radius);
  background: var(--panel-3);
  color: var(--muted);
  padding: 7px 9px;
  font-size: 13px;
}

.privacy-box {
  margin: 22px 0;
  padding: 16px;
  border: 1px solid rgba(217, 183, 104, .35);
  border-radius: var(--radius);
  background: rgba(217, 183, 104, .09);
  color: #fff0c8;
  line-height: 1.5;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0 24px;
  line-height: 1.45;
  cursor: pointer;
}

.check-row input {
  width: 24px;
  height: 24px;
  margin-top: 1px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.progress-text {
  color: var(--muted);
  font-weight: 800;
}

.progress-outer {
  margin-top: 20px;
  height: 12px;
  border-radius: 999px;
  background: #07080b;
  border: 1px solid rgba(255, 255, 255, .08);
  overflow: hidden;
}

.progress-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--accent-strong));
  transition: width .25s ease;
}

.rubric-badge {
  display: inline-flex;
  margin-top: 24px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: #11100b;
  background: var(--accent-strong);
  font-weight: 900;
}

.question-panel h2 {
  margin-top: 18px;
}

.help-text {
  font-size: 18px;
}

.scale-info {
  color: var(--muted);
  font-size: 14px;
  margin: 24px 0 12px;
  font-weight: 800;
}

.rating-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.rating-btn {
  min-height: 76px;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  font-size: 30px;
  font-weight: 950;
  cursor: pointer;
  transition: transform .12s ease, border .12s ease, background .12s ease;
}

.rating-btn:hover,
.rating-btn:focus-visible {
  outline: none;
  border-color: rgba(217, 183, 104, .78);
  background: #2a2f3b;
}

.rating-btn.selected {
  color: #11100b;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  border-color: transparent;
}

.score-card {
  margin: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: var(--radius);
  padding: 18px;
}

.score-label {
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 6px;
}

.score-big {
  font-size: 42px;
  font-weight: 950;
}

.verdict-pill {
  text-align: center;
  background: rgba(114, 214, 163, .12);
  color: var(--green);
  border: 1px solid rgba(114, 214, 163, .35);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 900;
}

.button-row {
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.button-row .primary-btn,
.button-row .ghost-btn {
  flex: 1 1 180px;
}

.result-text {
  width: 100%;
  min-height: 440px;
  resize: vertical;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, .12);
  background: #090b10;
  color: var(--text);
  padding: 16px;
  line-height: 1.5;
  font-size: 15px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-weight: 900;
  box-shadow: var(--shadow);
  z-index: 20;
}

@media (max-width: 760px) {
  body {
    padding: 14px;
  }

  h1 {
    font-size: 34px;
  }

  h2 {
    font-size: 26px;
  }

  .app-header,
  .section-head,
  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-panel,
  .start-panel,
  .question-panel,
  .result-panel,
  .dashboard-panel,
  .detail-panel {
    padding: 20px;
  }

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

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

  .score-card {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 430px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .tabbar {
    flex-direction: column;
  }

  .topbar,
  .scale-info {
    align-items: stretch;
    flex-direction: column;
  }
}
