/* ── Clinly Demo v11 — Shared Design System ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #070D1C;
  --bg-card: #0C1525;
  --bg-card-hover: #0F1B30;
  --sidebar-bg-start: #070E22;
  --sidebar-bg-end: #0C0820;
  --border: #182640;
  --border-bright: #1E3258;
  --text: #D4E8FF;
  --text-muted: #7A9CC8;
  --text-dim: #4A6A90;
  --cyan: #18D4F0;
  --cyan-dim: rgba(24,212,240,0.12);
  --cyan-mid: rgba(24,212,240,0.25);
  --purple: #8B5CF6;
  --purple-dim: rgba(139,92,246,0.12);
  --green: #10D9A0;
  --green-dim: rgba(16,217,160,0.12);
  --red: #F87171;
  --red-dim: rgba(248,113,113,0.12);
  --yellow: #FBBF24;
  --yellow-dim: rgba(251,191,36,0.12);
  --primary-btn: #18D4F0;
  --primary-btn-text: #040810;
  --radius: 8px;
  --sidebar-width: 232px;
  --header-h: 52px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ── */
.app { display: flex; height: 100vh; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.content { flex: 1; overflow-y: auto; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(175deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-end) 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden;
}
.sidebar-logo {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.logo-text {
  font-family: 'Inter', sans-serif;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}
.logo-dot { color: #3B82F6; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.nav-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--cyan); padding: 0 8px; margin-bottom: 4px; margin-top: 14px;
}
.nav-group-label:first-child { margin-top: 0; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 0; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 1px; border: 1px solid transparent;
  transition: all 0.15s;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-item.active {
  color: var(--cyan);
  background: linear-gradient(90deg, var(--cyan-dim), rgba(139,92,246,0.06));
  border-color: rgba(24,212,240,0.2);
  border-left: 2px solid var(--cyan);
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge {
  margin-left: auto; font-size: 9px; font-weight: 700;
  background: var(--cyan-dim); color: var(--cyan);
  padding: 2px 6px; border-radius: 10px;
}
.sidebar-footer {
  padding: 10px 16px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim);
}
.sidebar-footer strong { color: var(--text-muted); display: block; margin-bottom: 1px; }

/* ── Topbar ── */
.topbar {
  height: var(--header-h); min-height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-size: 14px; font-weight: 600; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-badge {
  font-size: 10px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
  background: var(--cyan-dim); color: var(--cyan);
  border: 1px solid rgba(24,212,240,0.3);
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #040810;
}

/* ── Page inner ── */
.page-inner { padding: 28px 32px; max-width: 1200px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-weight: 500; border: none; outline: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary-btn); color: var(--primary-btn-text); }
.btn-primary:hover { opacity: 0.9; }
.btn-outline {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover { color: var(--text); border-color: var(--border-bright); }
.btn-ghost { background: transparent; color: var(--text-muted); border: none; padding: 6px 10px; }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.stat-value.cyan { color: var(--cyan); }
.stat-value.green { color: var(--green); }
.stat-value.purple { color: var(--purple); }
.stat-value.yellow { color: var(--yellow); }
.stat-sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ── Cards ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-bright); }
.card-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.card-sub { font-size: 12px; color: var(--text-muted); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; margin-bottom: 28px; }
.study-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 22px; cursor: pointer;
  transition: all 0.2s; display: block;
  text-decoration: none; color: inherit;
}
.study-card:hover { border-color: var(--cyan); background: var(--bg-card-hover); transform: translateY(-1px); box-shadow: 0 4px 24px rgba(24,212,240,0.08); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-cyan { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(24,212,240,0.25); }
.badge-green { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,217,160,0.25); }
.badge-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(139,92,246,0.25); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(251,191,36,0.25); }
.badge-red { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248,113,113,0.25); }
.badge-gray { background: rgba(255,255,255,0.06); color: var(--text-muted); border: 1px solid var(--border); }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 5px var(--green); }
.dot-cyan { background: var(--cyan); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab {
  padding: 10px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  transition: all 0.15s; margin-bottom: -1px;
  background: none; border-top: none; border-left: none; border-right: none;
  outline: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: rgba(255,255,255,0.03); }
th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-muted); vertical-align: middle; }
td:first-child { color: var(--text); font-weight: 500; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1/-1; }
label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
input, select, textarea {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; padding: 9px 12px;
  color: var(--text); font-size: 13px; font-family: inherit;
  outline: none; transition: border-color 0.15s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); }
textarea { resize: vertical; min-height: 80px; }

/* ── Code / Query ── */
.code-block {
  background: #050A14; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; font-family: 'Roboto Mono', monospace; font-size: 12px;
  color: var(--cyan); overflow-x: auto; line-height: 1.7;
}
.code-kw { color: var(--purple); }
.code-fn { color: var(--cyan); }
.code-str { color: var(--green); }
.code-cmt { color: var(--text-dim); }
.code-num { color: var(--yellow); }

/* ── Progress / bars ── */
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; border-radius: 2px; background: var(--cyan); }
.progress-fill.green { background: var(--green); }
.progress-fill.purple { background: var(--purple); }

/* ── Audit timeline ── */
.audit-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.audit-item:last-child { border-bottom: none; }
.audit-icon {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.audit-icon.ins { background: var(--green-dim); color: var(--green); }
.audit-icon.upd { background: var(--cyan-dim); color: var(--cyan); }
.audit-icon.del { background: var(--red-dim); color: var(--red); }
.audit-icon.qry { background: var(--purple-dim); color: var(--purple); }
.audit-body { flex: 1; min-width: 0; }
.audit-title { font-size: 13px; color: var(--text); }
.audit-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.audit-old { font-size: 11px; color: var(--red); margin-top: 3px; }
.audit-new { font-size: 11px; color: var(--green); }

/* ── Misc helpers ── */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-28 { margin-bottom: 28px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: 'Roboto Mono', monospace; }
.section-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ── Export cards ── */
.export-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; cursor: pointer;
  transition: all 0.2s; display: flex; flex-direction: column; gap: 10px;
}
.export-card:hover { border-color: var(--cyan); }
.export-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

/* ── Chart bars (pure CSS) ── */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding: 0 4px; }
.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart-bar { width: 100%; border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.3s; }
.chart-label { font-size: 9px; color: var(--text-dim); text-align: center; }

/* ── User cards ── */
.user-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #040810; flex-shrink: 0; }
.user-info { flex: 1; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-email { font-size: 11px; color: var(--text-dim); }
