:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1f4ed8;
  --primary-dark: #173fb1;
  --danger: #b91c1c;
  --warning: #b45309;
  --success: #047857;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 250px; background: #111827; color: #fff; padding: 24px 18px; display: flex; flex-direction: column; }
.brand { font-weight: 800; font-size: 1.2rem; margin-bottom: 30px; letter-spacing: -0.02em; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar a { color: #d1d5db; padding: 12px 14px; border-radius: 12px; text-decoration: none; font-weight: 600; }
.sidebar a.active, .sidebar a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.logout { margin-top: auto; }
.main { margin-left: 250px; padding: 28px; max-width: 1500px; }
.main.no-nav { margin-left: 0; max-width: none; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.hero h1, .card h1 { margin: 0 0 8px; letter-spacing: -0.03em; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card.wide { width: 100%; }
.card-title-row { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.stat-value { font-size: 2rem; font-weight: 800; }
.stat-label { color: var(--muted); text-transform: capitalize; font-size: 0.9rem; }
.button { border: 0; border-radius: 999px; padding: 10px 15px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: #e5e7eb; color: #111827; text-decoration: none; line-height: 1.2; }
.button:hover { text-decoration: none; filter: brightness(0.98); }
.button.primary { background: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { background: #eef2ff; color: #1e40af; }
.button.danger { background: #fee2e2; color: var(--danger); }
.button.warning { background: #ffedd5; color: var(--warning); }
.button.small { padding: 7px 10px; font-size: 0.85rem; }
.button.full { width: 100%; }
.button-row, .hero-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 0; flex-wrap: wrap; }
.inline-form input[type="datetime-local"], .inline-form input[type="number"] { width: auto; min-width: 120px; padding: 7px 9px; }
.alert { border-radius: 14px; padding: 12px 14px; margin: 0 0 14px; border: 1px solid var(--line); background: #f9fafb; }
.alert.success { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.alert.danger { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.alert.warning { border-color: #fed7aa; background: #fff7ed; color: #9a3412; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; background: #f3f4f6; color: #374151; font-size: 0.78rem; font-weight: 800; vertical-align: middle; margin: 1px; }
.pill.success { background: #d1fae5; color: #065f46; }
.pill.warning, .risk-medium, .priority-high { background: #ffedd5; color: #9a3412; }
.pill.danger, .risk-high, .priority-urgent { background: #fee2e2; color: #991b1b; }
.risk-low, .priority-low { background: #ecfdf5; color: #047857; }
.priority-medium { background: #eef2ff; color: #3730a3; }
.list-item, .email-item, .rep-hit, .draft, .task-row { border-top: 1px solid var(--line); padding: 14px 0; }
.list-item:first-of-type, .email-item:first-of-type, .rep-hit:first-of-type, .draft:first-of-type, .task-row:first-of-type { border-top: 0; }
.email-item p, .rep-hit p, .list-item p { margin-bottom: 0; }
.task-row.done { opacity: 0.65; }
.connection-list { display: grid; gap: 10px; }
.connection-list > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.connection-list > div:last-child { border-bottom: 0; }
form label { display: grid; gap: 6px; font-weight: 700; margin-bottom: 14px; }
input, select, textarea { width: 100%; border: 1px solid #d1d5db; border-radius: 12px; padding: 11px 12px; font: inherit; color: var(--text); background: #fff; }
textarea { resize: vertical; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; }
.grid-form h2, .grid-form .full-row, .form-actions { grid-column: 1 / -1; }
.grid-form h2 { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 12px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
code { background: #f3f4f6; border-radius: 8px; padding: 2px 5px; }
pre { background: #0f172a; color: #e5e7eb; padding: 16px; border-radius: 14px; overflow: auto; white-space: pre-wrap; }
.markdown h1 { font-size: 1.6rem; }
.markdown h2 { margin-top: 22px; padding-top: 4px; }
.markdown ul { padding-left: 22px; }
.login-wrap, .install-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); }
.install-body { background: linear-gradient(135deg, #f8fafc, #eef2ff); }
.install-wrap .wide { width: min(1000px, 100%); }
@media (max-width: 900px) {
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; overflow-x: auto; padding: 12px; align-items: center; }
  .brand { margin: 0 14px 0 0; white-space: nowrap; }
  .sidebar nav { display: flex; gap: 4px; }
  .sidebar a { white-space: nowrap; padding: 9px 10px; }
  .logout { margin-top: 0; margin-left: auto; }
  .main { margin-left: 0; padding: 16px; }
  .grid.two, .stats, .grid-form { grid-template-columns: 1fr; }
  .hero { align-items: stretch; flex-direction: column; }
  .card-title-row { flex-direction: column; }
}
