@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #f5f6fb;
  --panel: #ffffff;
  --panel-alt: #fbfbfe;
  --border: #e6e8f0;
  --border-strong: #d7dae6;
  --text: #171923;
  --text-muted: #666c80;
  --text-faint: #9498a8;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --primary-soft-strong: #e0e3ff;

  --success: #158a4d;
  --success-bg: #e5f8ee;
  --danger: #d0362a;
  --danger-bg: #fdeceb;
  --warn: #b06b04;
  --warn-bg: #fff5e0;

  --sidebar-from: #14172b;
  --sidebar-to: #1d2140;
  --sidebar-text: #a9adc4;
  --sidebar-active-bg: rgba(255, 255, 255, 0.07);
  --sidebar-border: rgba(255, 255, 255, 0.08);

  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 40, 0.04);
  --shadow-md: 0 4px 16px rgba(20, 22, 40, 0.06), 0 1px 2px rgba(20, 22, 40, 0.05);
  --shadow-lg: 0 12px 32px rgba(20, 22, 40, 0.10);

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: -0.006em;
}
h1, h2, h3 { letter-spacing: -0.015em; font-weight: 700; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code {
  background: var(--primary-soft);
  color: var(--primary-hover);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.85em;
}
hr { border: none; border-top: 1px solid var(--border); }

/* ---------- Layout shell ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-from), var(--sidebar-to));
  color: var(--sidebar-text);
  padding: 14px 10px 16px;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 16px;
  color: #fff;
}
.sidebar .brand .mark {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.5);
}
.sidebar .brand .name { font-weight: 700; font-size: 13px; line-height: 1.2; }
.sidebar .brand small { display: block; font-weight: 400; color: #8388a3; font-size: 10.5px; margin-top: 1px; }

.sidebar nav { flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin: 1px 0;
  border-radius: 6px;
  color: var(--sidebar-text);
  font-size: 12.3px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar nav a svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.85; }
.sidebar nav a:hover { background: var(--sidebar-active-bg); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav a.active svg { opacity: 1; }
.sidebar .section-label {
  padding: 12px 8px 4px;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: #666b87;
}
.sidebar .section-label:first-of-type { padding-top: 2px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .who { color: var(--text-muted); font-size: 12.3px; display: flex; align-items: center; gap: 9px; }
.topbar .avatar {
  width: 25px; height: 25px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 10.5px;
}
.topbar svg { width: 15px; height: 15px; }
.content { padding: 20px; max-width: 1180px; width: 100%; margin: 0 auto; flex: 1; }

/* ---------- Cards & headers ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2, .card h3 { margin-top: 0; }
.card h2 { font-size: 14.5px; }
.card h3 { font-size: 13.3px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.page-header h1 { font-size: 18px; margin: 0; }
.page-header p.subtitle { color: var(--text-muted); margin: 4px 0 0; font-size: 12.3px; max-width: 62ch; }
.page-header > div:last-child { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}
.stat-card .icon svg { width: 16px; height: 16px; }
.stat-card .num { font-size: 19px; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.stat-card .label { color: var(--text-muted); font-size: 11.3px; margin-top: 1px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 12.5px; }
thead th { border-top: none; color: var(--text-muted); }
th { font-size: 10.3px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; padding-top: 0; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--panel-alt); }
tbody tr:last-child td { border-bottom: none; }
.table-actions { white-space: nowrap; text-align: right; }
.table-actions a, .table-actions button.link {
  margin-left: 10px;
  font-size: 12px;
  font-weight: 600;
}
.table-actions a:first-child, .table-actions button.link:first-child { margin-left: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 12.3px;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.15);
}
.btn svg { width: 13px; height: 13px; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { background: var(--panel-alt); border-color: var(--text-faint); }
.btn.danger { background: var(--danger); border-color: var(--danger); box-shadow: 0 1px 2px rgba(208, 54, 42, 0.2); }
.btn.danger:hover { background: #ae2c21; border-color: #ae2c21; }
.btn.small { padding: 4px 9px; font-size: 11.5px; }
button.link { background: none; border: none; color: var(--danger); padding: 0; cursor: pointer; font-size: 12px; font-weight: 600; font-family: inherit; }
button.link:hover { text-decoration: underline; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10.3px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.active, .badge.live, .badge.success { background: var(--success-bg); color: var(--success); }
.badge.inactive, .badge.archived, .badge.disabled { background: #eef0f4; color: var(--text-muted); }
.badge.draft, .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 12.3px;
  font-weight: 500;
  border: 1px solid transparent;
}
.alert svg { width: 15px; height: 15px; flex-shrink: 0; }
.alert.success { background: var(--success-bg); color: var(--success); border-color: #c3ecd6; }
.alert.error { background: var(--danger-bg); color: var(--danger); border-color: #f5cbc7; }

/* ---------- Forms ---------- */
form .field { margin-bottom: 14px; }
form label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 11.8px; color: #383c4a; }
form .hint { color: var(--text-faint); font-size: 11.3px; margin-top: 4px; line-height: 1.5; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date],
select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input:disabled, select:disabled, textarea:disabled { background: var(--panel-alt); color: var(--text-faint); cursor: not-allowed; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666c80' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 28px; }
textarea { resize: vertical; }
textarea.code { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-actions { margin-top: 18px; display: flex; gap: 8px; }

.suggestion-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.suggestion-chips:empty { margin-top: 0; }
.suggestion-chip {
  font-family: inherit;
  font-size: 11.3px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: var(--panel-alt);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.suggestion-chip:hover { background: var(--primary-soft); color: var(--primary-hover); border-color: var(--primary-soft-strong); }
.suggestion-chip.active { background: var(--primary-soft); color: var(--primary-hover); border-color: var(--primary); }

/* ---------- Snippet / code boxes ---------- */
.snippet-box { position: relative; margin-bottom: 12px; }
.snippet-box pre {
  background: #12141f;
  color: #d7dae8;
  padding: 13px;
  padding-top: 28px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 11.3px;
  line-height: 1.55;
  margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.snippet-box::before {
  content: '● ● ●';
  position: absolute;
  top: 9px; left: 12px;
  color: #454a5f;
  font-size: 8px;
  letter-spacing: 3px;
  z-index: 1;
}
.snippet-box .copy-btn { position: absolute; top: 6px; right: 6px; }

/* ---------- Auth screens ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
}
.auth-brand-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 48px;
  background:
    radial-gradient(circle at 15% 15%, rgba(139, 92, 246, 0.35), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(79, 70, 229, 0.45), transparent 50%),
    linear-gradient(160deg, var(--sidebar-from), var(--sidebar-to));
  color: #fff;
  position: relative;
  overflow: hidden;
}
.auth-brand-panel .mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.5);
}
.auth-brand-panel h2 { font-size: 22px; line-height: 1.3; max-width: 16ch; margin: 0 0 10px; }
.auth-brand-panel p { color: #b7bbd6; font-size: 13px; max-width: 40ch; line-height: 1.6; }
.auth-brand-panel .feature-list { margin-top: 24px; display: flex; flex-direction: column; gap: 11px; }
.auth-brand-panel .feature-list div { display: flex; align-items: center; gap: 9px; color: #d6d8ea; font-size: 12.3px; }
.auth-brand-panel .feature-list svg { width: 15px; height: 15px; color: #a5b4fc; flex-shrink: 0; }

.auth-form-panel {
  width: 400px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--panel);
}
.auth-card { width: 100%; max-width: 320px; }
.auth-card h1 { font-size: 18px; margin: 0 0 4px; }
.auth-card p.subtitle { color: var(--text-muted); font-size: 12.3px; margin: 0 0 20px; }
.auth-card .switch { margin-top: 15px; text-align: center; font-size: 12.3px; color: var(--text-muted); }
.auth-card .btn { width: 100%; justify-content: center; padding: 8px 14px; }

@media (max-width: 900px) {
  .auth-brand-panel { display: none; }
  .auth-form-panel { width: 100%; }
}

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 36px 20px; color: var(--text-muted); font-size: 12.3px; }
.empty-state svg { width: 28px; height: 28px; color: var(--text-faint); margin-bottom: 10px; }
.empty-state p { margin: 0 0 12px; }

.text-muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; }
.mt-0 { margin-top: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d3d6e2; border-radius: 20px; border: 2px solid var(--bg); }
.sidebar ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-color: transparent; }

@media (max-width: 960px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
}
