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

:root {
  --bg:           #edf0fb;
  --surface:      #ffffff;
  --surface-2:    #f5f7ff;
  --border:       #dce3f3;
  --border-light: #edf0fb;
  --text:         #1c2040;
  --text-muted:   #5c6888;
  --accent:       #4f46e5;
  --accent-light: #ede9fe;
  --shadow-sm:    0 1px 3px rgba(50,60,140,0.08);
  --shadow-md:    0 4px 14px rgba(50,60,140,0.10);
}

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

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 44px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 40;
}

header h1 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}

nav { display: flex; gap: 2px; }

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 5px;
  transition: background 0.12s, color 0.12s;
}

.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

main { padding: 12px 16px; }

.hidden { display: none !important; }

/* ── Radar page ──────────────────────────────────────────────────────────── */
#radar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#radar-top {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  width: 100%;
}

#radar-svg-wrap { flex: 0 0 auto; }

/* ── Infobox ─────────────────────────────────────────────────────────────── */
#radar-infobox {
  flex: 0 0 188px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.info-card-title {
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 7px;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 0;
}

.info-row-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.info-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.info-total {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
  margin-top: 2px;
}

/* ── Technology list ──────────────────────────────────────────────────────── */
#radar-lists {
  width: 100%;
  max-width: 1500px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.quadrant-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px 6px;
  box-shadow: var(--shadow-sm);
}

.quadrant-title {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-bottom: 5px;
  margin-bottom: 4px;
  border-bottom: 2px solid var(--accent-light);
}

.tech-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 2px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
}

.tech-item:hover { background: var(--surface-2); }

.tech-name { flex: 1; font-size: 0.77rem; color: var(--text); line-height: 1.3; }

.new-badge {
  font-size: 0.58rem;
  color: #d97706;
  font-weight: 700;
  margin-left: 2px;
  vertical-align: middle;
}

.ring-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Detail panel ────────────────────────────────────────────────────────── */
#detail-panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 24px 20px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: -4px 0 20px rgba(50,60,140,0.08);
  animation: slideIn 0.18s ease;
}

@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

#detail-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.12s;
}

#detail-close:hover { background: var(--border); color: var(--text); }

#detail-name { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 8px; padding-right: 32px; }

#detail-ring-badge { margin-bottom: 4px; }

#detail-quadrant { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 12px; }

#detail-desc { font-size: 0.83rem; line-height: 1.6; color: var(--text-muted); margin-bottom: 12px; }

#detail-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }

.tag-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 8px;
}

#detail-custom { font-size: 0.78rem; color: var(--text-muted); }
.custom-field { margin-bottom: 3px; }
.custom-field strong { color: var(--text); }

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
.tooltip {
  position: fixed;
  background: #1e2338;
  color: #cdd3ee;
  border: 1px solid #2e3454;
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 0.8rem;
  max-width: 300px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 200;
  line-height: 1.5;
  box-shadow: 0 6px 24px rgba(0,0,0,0.22);
}

.tooltip-name { font-size: 0.9rem; font-weight: 700; color: #fff; margin-bottom: 5px; }

.tooltip-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }

.tooltip-quadrant { font-size: 0.72rem; color: #8892b8; }

.tooltip-desc {
  font-size: 0.77rem;
  color: #a8b2d0;
  line-height: 1.5;
  border-top: 1px solid #2e3454;
  padding-top: 6px;
}

.tooltip-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 3px; }

.tooltip-tag {
  font-size: 0.65rem;
  background: #2a2f4e;
  color: #8892b8;
  padding: 1px 5px;
  border-radius: 6px;
}

/* ── Blip ────────────────────────────────────────────────────────────────── */
.blip-group { cursor: pointer; }

/* ── Admin ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  max-width: 480px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card h2 { font-size: 0.95rem; margin-bottom: 6px; }
.card p  { color: var(--text-muted); font-size: 0.84rem; margin-bottom: 12px; }

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

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.92rem;
  flex: 1;
  outline: none;
  transition: border-color 0.12s;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #fff; }

textarea { resize: vertical; min-height: 130px; font-family: inherit; line-height: 1.55; }

.error { color: #dc2626; font-size: 0.78rem; }

.admin-actions { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 13px;
  transition: opacity 0.12s, background 0.12s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.88; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: none; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { opacity: 0.88; }

table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th { text-align: left; color: var(--text-muted); padding: 5px 10px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
td { padding: 6px 10px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tr:hover td { background: var(--surface-2); }

.side-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  max-width: 480px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.side-panel h3 { font-size: 0.88rem; font-weight: 700; margin-bottom: 12px; }

.ring-edit-row, .quadrant-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.color-swatch { width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0; border: 1px solid var(--border); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,18,50,0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
}

#modal { max-width: 640px; width: 100%; padding: 28px 32px; box-shadow: var(--shadow-md); }

#modal-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 16px; }

.form-field { margin-bottom: 12px; }
.form-field label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; letter-spacing: 0.02em; text-transform: uppercase; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; }
input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

/* ── AI Models ───────────────────────────────────────────────────────────── */
.ai-model-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.ai-model-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ai-model-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
}

.ai-model-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}

.ai-model-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-xs {
  font-size: 0.72rem;
  padding: 3px 8px;
}

.badge-default {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-inactive {
  display: inline-block;
  background: #fee2e2;
  color: #991b1b;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  text-transform: uppercase;
}

.badge-key {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
}

/* ── Reports page ────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

@keyframes spin { to { transform: rotate(360deg); } }

.status-spinner {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

#reports-table-wrap { overflow-x: auto; }

#reports-panel .side-panel { max-width: 100%; }

input[type="date"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.12s;
}

input[type="date"]:focus { border-color: var(--accent); background: #fff; }
