:root {
  --navy: #041E42;
  --burgundy: #73272D;
  --gray: #5A5A5A;
  --hairline: #D9D9D9;
  --bg: #FFFFFF;
  --bg-alt: #F7F7F8;
  --green: #1E7A3E;
  --amber: #A5680E;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--navy);
  background: var(--bg-alt);
  line-height: 1.5;
  font-size: 14.5px;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--burgundy); }

h1, h2, h3 { color: var(--navy); margin: 0 0 12px; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 10px; color: var(--gray); }

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 20px 20px;
  font-weight: 800;
  font-size: 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 12px;
}
.sidebar-brand span { display: block; font-size: 0.7rem; font-weight: 500; opacity: 0.7; letter-spacing: 0.06em; text-transform: uppercase; margin-top: 2px; }

.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-nav a {
  color: rgba(255,255,255,0.82);
  padding: 11px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.sidebar-nav a.active { color: #fff; background: rgba(255,255,255,0.1); border-left-color: var(--burgundy); }

.sidebar-footer { margin-top: auto; padding: 12px 20px 0; }
.sidebar-footer a { color: rgba(255,255,255,0.6); font-size: 0.82rem; }

.main { flex: 1; padding: 32px 40px; max-width: 1100px; }

/* Topbar within main */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
}
.btn-primary { background: var(--burgundy); color: #fff; }
.btn-primary:hover { background: #5c1f24; color: #fff; }
.btn-ghost { border-color: var(--hairline); color: var(--navy); background: #fff; }
.btn-ghost:hover { border-color: var(--navy); }
.btn-danger { color: #a5252c; border-color: #e3c3c3; background: #fff; }
.btn-danger:hover { background: #fdf1f1; }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }

/* Cards / stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--burgundy); font-weight: 700; margin-bottom: 6px; }
.stat-card .value { font-size: 1.5rem; font-weight: 800; color: var(--navy); }

.panel {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}

/* Tables */
table.data { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden; }
table.data th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
  background: var(--bg-alt);
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
}
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--hairline); font-size: 0.92rem; color: var(--navy); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--bg-alt); }

/* Pills */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; text-transform: capitalize; }
.pill-new, .pill-draft, .pill-todo, .pill-planning { background: #e9edf2; color: var(--navy); }
.pill-contacted, .pill-sent, .pill-in_progress, .pill-active { background: #fde9d9; color: var(--amber); }
.pill-qualified { background: #dbe7ff; color: #1a4fa0; }
.pill-won, .pill-paid, .pill-done, .pill-completed { background: #dcf3e3; color: var(--green); }
.pill-lost, .pill-cancelled { background: #f2dcdc; color: #a5252c; }
.pill-overdue, .pill-on_hold { background: #f7d3d3; color: #a5252c; }

/* Forms */
form.stack { display: flex; flex-direction: column; gap: 16px; max-width: 640px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8rem; font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select, .field textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 9px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--navy);
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--burgundy); }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }

/* Flash messages */
.flash { padding: 10px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem; font-weight: 600; }
.flash-success { background: #dcf3e3; color: var(--green); }
.flash-error { background: #f7d3d3; color: #a5252c; }

/* Filters */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar a { padding: 6px 13px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; border: 1px solid var(--hairline); color: var(--gray); }
.filter-bar a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Login page */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 360px; }
.login-card h1 { font-size: 1.3rem; }
.login-card .eyebrow { color: var(--burgundy); font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }

.empty-state { color: var(--gray); font-style: italic; padding: 24px; text-align: center; }

.text-muted { color: var(--gray); font-size: 0.85rem; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 12px 0; }
  .sidebar-brand { display: none; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .main { padding: 20px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .field-row { flex-direction: column; }
}
