:root {
  --ink: #111111;
  --ink-2: #1c1c1c;
  --paper: #ffffff;
  --paper-2: #f7f5f2;
  --paper-3: #efece7;
  --text: #161616;
  --text-2: #3a3a3a;
  --muted: #6d6a64;
  --red: #b5121b;
  --red-deep: #8f0e16;
  --red-wash: rgba(181, 18, 27, 0.08);
  --line: rgba(22, 22, 22, 0.12);
  --shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.35);
  --r: 14px;
  --sidebar-w: 240px;
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-sans: "Source Sans 3", "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper-2);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 0.98rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 0 0 0.4rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
p { margin: 0 0 0.85rem; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #171717 0%, #0d0d0d 100%);
  color: #f4f1ea;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.4rem 0.55rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 1rem;
}
.brand strong, .auth-brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: #fff;
}
.brand small, .auth-brand small { color: rgba(255,255,255,0.65); font-size: 0.78rem; }
.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--red);
  flex: none;
}
.brand-mark svg {
  width: 1.85rem;
  height: auto;
  display: block;
}
.auth-brand .brand-mark {
  width: 2.8rem;
  height: 2.8rem;
}
.auth-brand .brand-mark svg {
  width: 2.2rem;
}
.nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.nav-link {
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  color: rgba(255,255,255,0.78);
  font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.is-active { background: var(--red); color: #fff; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 0.7rem 0; }
.sidebar-foot { padding-top: 1rem; font-size: 0.85rem; color: rgba(255,255,255,0.55); }
.sidebar-foot a:hover { color: #fff; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 1.7rem; }
.userchip { text-align: right; }
.userchip-name { display: block; font-weight: 600; color: var(--text); }
.userchip-meta { color: var(--muted); font-size: 0.85rem; }
.content { padding: 1.35rem 1.5rem 2.5rem; }

.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 980px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-4, .grid-2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 1rem; padding-right: 1rem; }
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.stat-label { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.25rem; }
.stat-value { font-family: var(--font-display); font-size: 2rem; color: var(--text); line-height: 1.1; }

.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  border: 0; border-radius: 999px;
  padding: 0.65rem 1.1rem;
  font: inherit; font-weight: 600;
  cursor: pointer;
  background: var(--red); color: #fff;
}
.btn:hover { background: var(--red-deep); }
.btn-secondary { background: var(--ink); }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--paper-3); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.55rem; margin: 0.8rem 0 1rem; }

label { display: block; font-weight: 600; color: var(--text); margin: 0.7rem 0 0.3rem; font-size: 0.92rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 120px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.help { color: var(--muted); font-size: 0.88rem; margin-top: 0.25rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem 0.55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: rgba(0,0,0,0.015); }

.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--paper-3);
  color: var(--text);
}
.badge-hot { background: #ffe5e5; color: #9b1212; }
.badge-warm { background: #fff1d6; color: #8a5a00; }
.badge-cold { background: #e8eef8; color: #274a7a; }
.badge-pending { background: #fff1d6; color: #8a5a00; }
.badge-active { background: #e5f6ea; color: #146c2e; }
.badge-suspended { background: #ffe5e5; color: #9b1212; }

.alert {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
}
.alert-success { background: #e8f7ee; border-color: #b7e0c4; color: #146c2e; }
.alert-error { background: #fdecec; border-color: #f3c1c1; color: #9b1212; }
.alert-info { background: #eef3ff; border-color: #c9d6f5; color: #274a7a; }

.timeline { display: grid; gap: 0.8rem; }
.note {
  border-left: 3px solid var(--red);
  padding: 0.75rem 0.9rem;
  background: var(--paper);
  border-radius: 0 var(--r) var(--r) 0;
  border: 1px solid var(--line);
  border-left-width: 3px;
}
.note-meta { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.35rem; }
.ai-panel {
  background: linear-gradient(180deg, #fff 0%, #fff8f8 100%);
  border: 1px solid rgba(181, 18, 27, 0.18);
  border-radius: var(--r);
  padding: 1rem;
}
.ai-result {
  white-space: pre-wrap;
  background: var(--paper-2);
  border-radius: 10px;
  padding: 0.9rem;
  margin-top: 0.75rem;
  border: 1px solid var(--line);
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at top right, rgba(181,18,27,0.14), transparent 40%),
    linear-gradient(160deg, #f7f5f2 0%, #ebe7e0 100%);
}
.auth-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 1.6rem 1.5rem 1.8rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.1rem; }
.auth-card h1 { font-size: 2rem; margin-bottom: 0.8rem; }
.auth-card .btn { width: 100%; margin-top: 1rem; }
.auth-links { margin-top: 1rem; text-align: center; color: var(--muted); }
.auth-links a { color: var(--red); font-weight: 600; }

.muted { color: var(--muted); }
.stack > * + * { margin-top: 0.85rem; }
.section-head {
  display: flex; justify-content: space-between; align-items: end; gap: 1rem;
  margin-bottom: 0.9rem;
}
.section-head p { margin: 0; color: var(--muted); }
