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

:root {
  --bg: #09090b;
  --surface: #18181b;
  --surface2: #27272a;
  --border: #3f3f46;
  --border-light: #52525b;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --radius-sm: 6px;
  --topbar-h: 56px;
  --sidebar-w: 220px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, sans-serif; font-size: 14px; line-height: 1.5; }

/* ── Topbar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 100;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff;
}
.logo-title { display: block; font-weight: 700; font-size: 14px; line-height: 1.1; }
.logo-sub { display: block; font-size: 11px; color: var(--text-muted); line-height: 1.1; }
.auth-indicator {
  font-size: 12px; padding: 4px 10px; border-radius: 20px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted);
}
.auth-indicator.connected { color: var(--success); border-color: var(--success); background: rgba(34,197,94,.1); }

/* ── Layout ── */
.layout {
  display: flex; min-height: 100vh;
  padding-top: var(--topbar-h);
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 12px 8px; display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.side-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  text-align: left; transition: background .15s, color .15s;
}
.side-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.side-item:hover { background: var(--surface2); color: var(--text); }
.side-item.active { background: var(--surface2); color: var(--text); }

/* ── Content ── */
.content {
  flex: 1; margin-left: var(--sidebar-w);
  padding: 28px 32px; max-width: 900px;
  position: relative;
}

/* ── Auth gate ── */
.auth-gate {
  position: absolute; inset: 0;
  background: rgba(9,9,11,.85); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; border-radius: var(--radius);
}
.auth-gate.hidden { display: none; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 32px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 16px;
}
.auth-card-icon {
  width: 48px; height: 48px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.auth-card-icon svg { width: 22px; height: 22px; color: var(--accent); }
.auth-card h2 { font-size: 18px; font-weight: 700; }
.auth-card > p { color: var(--text-muted); font-size: 13px; }

/* ── Pages ── */
.page { display: none; }
.page.active { display: block; }
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.page-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-header p { color: var(--text-muted); font-size: 13px; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 13px; font-weight: 600; }
.card-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }

/* ── Form elements ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.field-row { display: flex; gap: 12px; }
.flex-1 { flex: 1; }
.label-hint { font-weight: 400; color: var(--text-dim); margin-left: 4px; }

input[type="text"], input[type="password"], textarea, select {
  width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
input[type="text"]:focus, input[type="password"]:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
input[readonly] { opacity: .6; cursor: default; }
textarea { resize: vertical; line-height: 1.5; }
select option { background: var(--surface2); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.hint { font-size: 12px; color: var(--text-muted); }
.hint code { background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-family: monospace; font-size: 11px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, opacity .15s;
  white-space: nowrap; font-family: inherit;
}
.btn svg { width: 15px; height: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,.1); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { padding: 6px; }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── News list ── */
.news-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.news-item:last-child { border-bottom: none; padding-bottom: 0; }
.news-item:first-child { padding-top: 0; }
.news-badge {
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
  white-space: nowrap; flex-shrink: 0; margin-top: 2px;
}
.news-badge.info { background: rgba(99,102,241,.2); color: #a5b4fc; border: 1px solid rgba(99,102,241,.3); }
.news-badge.update { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.2); }
.news-badge.warning { background: rgba(245,158,11,.15); color: #fcd34d; border: 1px solid rgba(245,158,11,.2); }
.news-content { flex: 1; min-width: 0; }
.news-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.news-body { font-size: 12px; color: var(--text-muted); }
.news-meta { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.news-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Form actions ── */
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

/* ── Status line ── */
.status-line {
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
}
.status-line.ok { background: rgba(34,197,94,.1); color: var(--success); border: 1px solid rgba(34,197,94,.2); }
.status-line.err { background: rgba(239,68,68,.1); color: var(--danger); border: 1px solid rgba(239,68,68,.2); }

/* ── Code preview ── */
.code-preview {
  font-family: 'Consolas', 'Monaco', monospace; font-size: 12px;
  color: var(--text-muted); white-space: pre-wrap; word-break: break-all;
  line-height: 1.6;
}

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 32px 16px;
  color: var(--text-dim); font-size: 13px;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  font-size: 13px; max-width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  transform: translateY(80px); opacity: 0;
  transition: transform .25s, opacity .25s;
  pointer-events: none; z-index: 200;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.ok { border-color: var(--success); color: var(--success); }
.toast.err { border-color: var(--danger); color: var(--danger); }
