:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --cyan: #39c5cf;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 24px;
  line-height: 1.5;
}

h2 { font-size: 18px; font-weight: 600; margin-bottom: 12px; color: var(--text-dim); }

.specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

#gpus-container {
  display: contents;
}

.spec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.spec-label { font-size: 12px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 4px; }
.spec-value { font-size: 16px; font-weight: 600; }
.spec-detail { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

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

#search {
  flex: 1;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

#fit-filter,
#locale-select {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

#models-table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-dim);
  position: sticky;
  top: 0;
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

tr:hover { background: var(--surface); }

.loading { text-align: center; color: var(--text-dim); padding: 32px; }

.fit-perfect { color: var(--green); font-weight: 600; }
.fit-good { color: var(--accent); font-weight: 600; }
.fit-marginal { color: var(--yellow); }
.fit-tight { color: var(--red); }

.mode-gpu { color: var(--green); }
.mode-moe { color: var(--cyan); }
.mode-cpuoffload { color: var(--yellow); }
.mode-cpuonly { color: var(--text-dim); }

/* Clickable rows */
.model-row { cursor: pointer; }
.model-row:hover { background: var(--surface) !important; }

.installed-dot { color: var(--green); font-size: 10px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.visible { display: flex; }

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.modal-header-row h3 { font-size: 20px; font-weight: 700; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-installed { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.badge-not-installed { background: rgba(139, 148, 158, 0.15); color: var(--text-dim); }

.modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.modal-stat {
  display: flex;
  flex-direction: column;
}

.stat-label { font-size: 11px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 2px; }
.stat-value { font-size: 15px; font-weight: 600; }

.modal-section { margin-bottom: 16px; }
.modal-section h4 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; margin-bottom: 8px; }
.modal-section ul { padding-left: 18px; font-size: 13px; color: var(--text-dim); }
.modal-section li { margin-bottom: 4px; }

.fit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 15px;
}

.fit-detail { color: var(--text-dim); font-size: 13px; }

.mem-bar-container { margin-top: 4px; }

.mem-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.mem-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.mem-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.bar-green { background: var(--green); }
.bar-yellow { background: var(--yellow); }
.bar-red { background: var(--red); }

.pull-status {
  margin: 16px 0;
}

.pull-status-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.pull-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.3s;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

.btn-download {
  padding: 8px 16px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-download:hover { opacity: 0.9; }
.btn-download:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-close {
  padding: 8px 16px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.btn-close:hover { color: var(--text); border-color: var(--text-dim); }
