/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3346;
  --text: #e4e6ed;
  --text-dim: #8b8fa3;
  --accent: #4f8ff7;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

/* === Typography === */
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 12px; color: var(--text-dim); }
h3 { font-size: 0.9rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 8px; }

/* === Header === */
.header { margin-bottom: 24px; }
.header .subtitle { color: var(--text-dim); font-size: 0.85rem; }
.header .updated { color: var(--text-dim); font-size: 0.75rem; margin-top: 4px; }

/* === Status Badge === */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-active { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-archived { background: rgba(139,143,163,0.15); color: var(--text-dim); }

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(79,143,247,0.2);
}

/* === Metric Grid === */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.metric {
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.metric-value {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}
.metric-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.metric-good .metric-value { color: var(--green); }
.metric-warn .metric-value { color: var(--yellow); }
.metric-bad .metric-value { color: var(--red); }

/* === Version Cards === */
.version-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.version-name {
  font-size: 1.1rem;
  font-weight: 700;
}
.version-summary {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* === Comparison Table === */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.compare-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  text-transform: uppercase;
}
.compare-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table .best { color: var(--green); font-weight: 600; }
.compare-table .highlight-row { background: rgba(79,143,247,0.08); }

/* === Parameter Tags === */
.param-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.param-tag {
  font-size: 0.7rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  color: var(--text-dim);
}

/* === Grid Layer Bar === */
.layer-bar {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.8rem;
}
.layer-label {
  width: 50px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.layer-track {
  flex: 1;
  height: 20px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
  margin: 0 8px;
}
.layer-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.layer-fill-good { background: var(--green); }
.layer-fill-warn { background: var(--yellow); }
.layer-fill-bad { background: var(--red); }
.layer-value { width: 45px; text-align: right; font-weight: 600; flex-shrink: 0; }

/* === Chart Container === */
.chart-wrap {
  position: relative;
  width: 100%;
}
.chart-wrap canvas {
  width: 100% !important;
}

/* === Section === */
.section { margin-bottom: 24px; }
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* === Recommendation Box === */
.recommend {
  background: rgba(79,143,247,0.08);
  border: 1px solid rgba(79,143,247,0.3);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.recommend-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--accent);
}
.recommend-text {
  font-size: 0.85rem;
  line-height: 1.6;
}
.recommend-text li {
  margin-bottom: 4px;
  list-style: none;
}
.recommend-text li::before {
  content: ">";
  color: var(--accent);
  font-weight: 700;
  margin-right: 6px;
}

/* === Strategy Selector === */
#strategy-selector {
  margin-bottom: 12px;
}
.strategy-current {
  display: flex;
  flex-direction: column;
  margin-bottom: 4px;
}
.strategy-current-name {
  font-size: 1rem;
  font-weight: 700;
}
.strategy-current-detail {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.strategy-chip {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  margin-right: 4px;
  margin-bottom: 4px;
  transition: all 0.2s;
}
.strategy-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}
.strategy-chip.active {
  background: rgba(79,143,247,0.15);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* === Nav Tabs === */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.tab:hover { border-color: var(--accent); color: var(--text); }
.tab.active {
  background: rgba(79,143,247,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* === Responsive: Tablet+ === */
@media (min-width: 768px) {
  body { max-width: 720px; padding: 24px; }
  .metrics { grid-template-columns: repeat(6, 1fr); }
}

/* === Login Gate === */
.login-gate {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.login-card {
  text-align: center;
  padding: 32px 24px;
  max-width: 320px;
  width: 100%;
}
.login-subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 20px;
}
.login-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}
.login-input:focus {
  border-color: var(--accent);
}
.login-button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.2s;
}
.login-button:hover {
  opacity: 0.9;
}
.login-error {
  color: var(--red);
  font-size: 0.8rem;
  margin-top: 10px;
  min-height: 1.2em;
}
