:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1f2630;
  --line: #303846;
  --text: #edf2f7;
  --muted: #99a6b8;
  --accent: #4aa8ff;
  --accent-strong: #78c4ff;
  --green: #21c776;
  --yellow: #e4c74f;
  --orange: #f28c35;
  --red: #f75f68;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #10151d;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2f9fff, #42d392);
  color: #081019;
  font-weight: 900;
  letter-spacing: 0;
}

.brand h1,
.brand p,
.page-head h2,
.page-head p {
  margin: 0;
}

.brand h1 {
  font-size: 1.25rem;
}

.brand p,
.muted,
.empty-state {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-button,
.primary-action,
.ghost-action,
.import-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
}

.nav-button {
  width: 100%;
  text-align: left;
  background: transparent;
}

.nav-button:hover,
.nav-button.active {
  background: var(--panel-2);
  border-color: var(--line);
}

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.topbar-note {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.language-switch {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.lang-button {
  min-width: 44px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.lang-button.active {
  background: var(--accent);
  color: #06111d;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-head h2 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.main-recommendation,
.panel,
.window-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.main-recommendation {
  margin-bottom: 16px;
  padding: 18px 20px;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  font-weight: 800;
}

.main-recommendation.green {
  border-left: 6px solid var(--green);
}

.main-recommendation.yellow {
  border-left: 6px solid var(--yellow);
}

.main-recommendation.orange {
  border-left: 6px solid var(--orange);
}

.main-recommendation.red {
  border-left: 6px solid var(--red);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.window-card {
  padding: 18px;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
}

.big-number {
  margin: 2px 0 0;
  font-size: clamp(2.35rem, 7vw, 4.4rem);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: 0;
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  color: #071016;
  font-weight: 900;
}

.risk-badge.green {
  background: var(--green);
}

.risk-badge.yellow {
  background: var(--yellow);
}

.risk-badge.orange {
  background: var(--orange);
}

.risk-badge.red {
  background: var(--red);
}

.risk-badge.unknown {
  background: #8a96a8;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.metric {
  min-height: 74px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.metric-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.metric-head span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.metric strong {
  font-size: 1.04rem;
  overflow-wrap: anywhere;
}

.recommendation {
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
}

.pace-visual {
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.pace-visual-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.pace-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #0f141c;
}

.pace-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--accent);
}

.pace-fill.green {
  background: var(--green);
}

.pace-fill.yellow {
  background: var(--yellow);
}

.pace-fill.orange {
  background: var(--orange);
}

.pace-fill.red {
  background: var(--red);
}

.pace-note,
.model-advice {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.model-advice {
  color: var(--accent-strong);
  font-weight: 800;
}

.comparison-panel {
  margin: 0 0 16px;
  padding: 16px;
}

.comparison-panel-head {
  margin-bottom: 14px;
}

.comparison-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.comparison-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.comparison-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.comparison-head strong {
  font-size: 1rem;
}

.comparison-status {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 900;
}

.comparison-status.green { color: var(--green); }
.comparison-status.yellow { color: var(--yellow); }
.comparison-status.orange { color: var(--orange); }
.comparison-status.red { color: var(--red); }

.comparison-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.comparison-row span {
  color: var(--muted);
}

.comparison-row strong {
  text-align: right;
  overflow-wrap: anywhere;
}

.comparison-empty {
  color: var(--muted);
}

.import-panel {
  margin: 0 0 16px;
  padding: 16px;
}

.import-panel-head {
  margin-bottom: 10px;
}

.import-panel h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.import-panel textarea {
  margin-bottom: 12px;
  min-height: 132px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.import-status {
  min-height: 1.1rem;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.import-status[data-type="error"] {
  color: var(--red);
}

.import-status[data-type="success"] {
  color: var(--green);
}

.import-status[data-type="warn"] {
  color: var(--yellow);
}

.tooltip-button {
  position: relative;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
}

.tooltip-button::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  width: min(240px, 60vw);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e141d;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 120ms ease, transform 120ms ease;
  white-space: normal;
  font-weight: 400;
}

.tooltip-button:hover::after,
.tooltip-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.form-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.field-hint {
  min-height: 1rem;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #0f141c;
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 168, 255, 0.16);
}

.full {
  grid-column: 1 / -1;
}

.form-actions,
.button-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-action {
  background: var(--accent);
  color: #06111d;
  font-weight: 900;
}

.ghost-action,
.import-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border-color: var(--line);
  font-weight: 800;
}

.import-button input {
  display: none;
}

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

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.mini-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 800;
}

.delete-button {
  color: var(--red);
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #202936;
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(120px);
  opacity: 0;
  transition: transform 160ms ease, opacity 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
    padding-bottom: 74px;
  }

  .sidebar {
    position: fixed;
    inset: auto 0 0;
    z-index: 10;
    display: block;
    height: auto;
    padding: 8px;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .brand {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .nav-button {
    min-height: 48px;
    padding: 0 6px;
    text-align: center;
    font-size: 0.78rem;
  }

  .content {
    padding: 18px;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .cards-grid,
  .form-grid,
  .settings-grid,
  .metric-grid,
  .comparison-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .content {
    padding: 14px;
  }

  .window-card,
  .form-grid,
  .settings-grid {
    padding: 14px;
  }

  .button-row,
  .form-actions {
    width: 100%;
  }

  .button-row > *,
  .form-actions > * {
    flex: 1 1 100%;
  }

  .comparison-row {
    flex-direction: column;
  }
}
