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

:root {
  --bg: #ffffff;
  --bg-alt: #f6f8fa;
  --fg: #1a1a2e;
  --fg-muted: #555;
  --border: #d0d5dd;
  --accent: #2d67f6;
  --accent-light: #e8eeff;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --table-head: #f0f2f5;
  --table-stripe: #fafbfc;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #131a2c;
  --bg-alt: #1a2236;
  --fg: #e8ecf1;
  --fg-muted: #9ca3af;
  --border: #2a3650;
  --accent: #4d8eff;
  --accent-light: #1a2a4a;
  --table-head: #1a2236;
  --table-stripe: #161e30;
}

html { color-scheme: light dark; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}

.container { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Header === */
.app-header {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.app-title { font-size: 1.2rem; font-weight: 700; }
.accent { color: var(--accent); font-weight: 400; }
.header-meta { font-size: 0.8rem; color: var(--fg-muted); }

/* === Controls === */
.controls { margin: 16px 0; }
.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--fg);
}
.search-input { flex: 1; min-width: 200px; }
.select { min-width: 140px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

/* Calculator */
.calculator {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 8px;
}
.calc-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--fg-muted);
}
.calc-profiles { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--bg-alt); }
.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-sort-dir { min-width: 160px; }
.calc-fields { display: flex; gap: 12px; flex-wrap: wrap; }
.calc-field { flex: 1; min-width: 120px; }
.calc-field label { display: block; font-size: 0.75rem; color: var(--fg-muted); margin-bottom: 2px; }
.calc-input { width: 100%; }

/* === Results === */
.results-info {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-bottom: 8px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* === Table === */
.model-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.model-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}
.model-table th {
  background: var(--table-head);
  border-bottom: 2px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.model-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.model-table tbody tr:nth-child(even) { background: var(--table-stripe); }
.model-table tbody tr:hover { background: var(--accent-light); }

/* Model name cell */
.model-name { font-weight: 600; }
.model-id {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-family: "SF Mono", "Fira Code", monospace;
}

/* Price cell */
.price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.price-none { color: var(--fg-muted); font-style: italic; }

/* Context */
.context { white-space: nowrap; }

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}
.status-active { background: #dcfce7; color: #15803d; }
.status-inactive { background: #fecaca; color: #b91c1c; }

html[data-theme="dark"] .status-active { background: #0a3020; color: #4ade80; }
html[data-theme="dark"] .status-inactive { background: #3a1010; color: #f87171; }

/* Calc cost column */
.calc-cost { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.calc-cost-none { color: var(--fg-muted); }

/* Release date */
.release-date { white-space: nowrap; font-size: 0.8rem; }

/* === Footer === */
.app-footer {
  margin-top: 32px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-align: center;
}

/* === Responsive === */
@media (max-width: 900px) {
  .model-table { font-size: 0.78rem; }
  .model-table th, .model-table td { padding: 5px 6px; }
  .calc-fields { gap: 8px; }
  .calc-field { min-width: 100px; }
}

@media (max-width: 600px) {
  .controls-row { gap: 6px; }
  .search-input { min-width: 120px; }
  .calc-profiles { gap: 4px; }
  .btn { padding: 4px 8px; font-size: 0.72rem; }
}
