/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --bg:           #f5f7fb;
  --panel:        #ffffff;
  --border:       #e5e7eb;
  --border-focus: #4f46e5;
  --muted:        #6b7280;
  --muted-light:  #9ca3af;
  --text:         #111827;
  --accent:       #4f46e5;
  --accent-2:     #3730a3;
  --accent-bg:    #eef2ff;
  --danger-bg:    #fef2f2;
  --danger-border:#fecaca;
  --danger-text:  #b91c1c;
  --ok-bg:        #ecfdf5;
  --ok-border:    #bbf7d0;
  --ok-text:      #166534;
  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    16px;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* ── App shell ─────────────────────────────────────────────────────────── */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.topbar-logo  { color: var(--accent); font-size: 18px; }
.topbar-title { font-weight: 700; font-size: 16px; }
.topbar-session { flex: 1; color: var(--muted); font-size: 13px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; }

/* ── Main nav ──────────────────────────────────────────────────────────── */
.main-nav {
  display: flex; gap: 0;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.nav-tab {
  padding: 10px 16px;
  background: none; border: none; color: var(--muted);
  font-size: 14px; font-weight: 500;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: color .15s, border-color .15s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn-ghost   { background: none; border: 1px solid var(--border); color: var(--muted); padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-secondary { background: var(--accent-bg); color: var(--accent-2); border: none; padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; }
.btn-back    { background: none; border: 1px solid var(--border); color: var(--muted); padding: 5px 10px; border-radius: var(--radius-sm); font-size: 13px; }
.btn-back:hover { color: var(--text); background: var(--bg); }
.btn-save    { background: var(--accent); color: #fff; border: none; padding: 7px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; }
.btn-save:hover { background: var(--accent-2); }
.btn-xs { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ── Alert ─────────────────────────────────────────────────────────────── */
.alert { margin: 12px 20px 0; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel); font-size: 14px; }
.alert.error   { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.alert.success { background: var(--ok-bg);     border-color: var(--ok-border);     color: var(--ok-text); }

/* ── Content layout (2-col) ────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 16px 20px 24px;
  flex: 1;
  align-items: start;
}
.layout-full {
  padding: 20px;
  flex: 1;
  display: flex;
  justify-content: center;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar { min-width: 0; }
.sidebar-header {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted-light); padding: 0 4px 8px;
}
.cluster-list { display: flex; flex-direction: column; gap: 6px; }
.cluster-card {
  display: flex; flex-direction: column; gap: 2px;
  text-align: left; width: 100%;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel);
  transition: background .12s, border-color .12s;
}
.cluster-card:hover { background: var(--accent-bg); border-color: #c7d2fe; }
.cluster-card.active { background: var(--accent-bg); border-color: var(--accent); }
.cluster-name { font-size: 14px; font-weight: 600; color: var(--text); }
.cluster-meta { font-size: 12px; color: var(--muted); }

/* ── Main area ─────────────────────────────────────────────────────────── */
.main-area { min-width: 0; }

/* ── Panel ─────────────────────────────────────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel-title { margin: 0; font-size: 18px; font-weight: 700; }

/* ── Card ──────────────────────────────────────────────────────────────── */
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--bg); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.badge-readonly { font-size: 11px; color: var(--muted-light); background: #f3f4f6; border-radius: 99px; padding: 2px 8px; font-weight: 500; }

/* ── Content list (cluster items) ──────────────────────────────────────── */
.content-list { display: flex; flex-direction: column; gap: 6px; }
.content-card {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel);
  transition: background .12s;
}
.content-card:hover { background: var(--accent-bg); border-color: #c7d2fe; }
.content-badge { font-size: 11px; font-weight: 600; background: #ede9fe; color: #6d28d9; border-radius: 99px; padding: 2px 7px; white-space: nowrap; }
.content-name  { font-size: 14px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content-meta  { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── Fields ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text); }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 14px; color: var(--text); background: var(--panel);
  transition: border-color .15s;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--border-focus); }
.field textarea { resize: vertical; min-height: 80px; }
.field-check { flex-direction: row; align-items: center; }
.field-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.field-ro { }
.field-ro-value { margin: 2px 0 0; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Service form ──────────────────────────────────────────────────────── */
.service-form { display: flex; flex-direction: column; gap: 4px; }
.svc-section { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.svc-section:last-of-type { border-bottom: none; }
.svc-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-light); margin-bottom: 2px; }

/* ── Site panel ────────────────────────────────────────────────────────── */
.site-panel { width: 100%; max-width: 760px; }

/* ── Status screen (unmapped / pending) ────────────────────────────────── */
.status-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}
.status-icon    { font-size: 48px; line-height: 1; margin-bottom: 20px; }
.status-title   { margin: 0 0 12px; font-size: 22px; font-weight: 700; color: var(--text); }
.status-message { margin: 0; max-width: 440px; font-size: 15px; color: var(--muted); line-height: 1.6; }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state { color: var(--muted); font-size: 14px; padding: 8px 4px; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .content-card { grid-template-columns: auto 1fr; }
  .content-meta { display: none; }
}
