:root {
  --gold-100: #FFF8ED;
  --gold-200: #FFE9C2;
  --gold-300: #F5C97A;
  --gold-400: #E8A83C;
  --gold-500: #C8791A;
  --gold-600: #9A5A0A;
  --obs-900: #080604;
  --obs-800: #0F0C07;
  --obs-700: #1A1208;
  --obs-600: #251A0C;
  --obs-500: #332513;
  --glass-border: rgba(200,121,26,0.20);
  --glass-border-bright: rgba(200,121,26,0.45);
  --text: #EFE4CE;
  --text-dim: rgba(239,228,206,0.66);
  --text-faint: rgba(239,228,206,0.42);
  --green: #22C55E;
  --amber: #E8A83C;
  --red: #E0736B;
  --blue: #6BA8E0;
  --crm-sidebar-width: 256px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--obs-900);
  color: var(--text);
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; margin: 0; }

/* ── Login ───────────────────────────────────────────── */

.crm-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.crm-login-card {
  width: min(380px, 100%);
  background: var(--obs-700);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 34px 28px;
  text-align: center;
}

.crm-login-logo { width: 54px; height: auto; margin-bottom: 14px; }
.crm-login-card h1 { font-size: 30px; color: var(--gold-300); }
.crm-login-sub { margin: 6px 0 22px; font-size: 13px; color: var(--text-dim); }

.crm-login-card input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--obs-900);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.crm-login-card input:focus {
  outline: none;
  border-color: var(--glass-border-bright);
}

.crm-login-card button {
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  border: none;
  border-radius: 10px;
  background: var(--gold-500);
  color: #1A1208;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.crm-login-card button:hover { background: var(--gold-400); }
.crm-login-error { min-height: 18px; margin: 12px 0 0; font-size: 13px; color: var(--red); }
.crm-login-back { display: inline-block; margin-top: 14px; font-size: 12px; color: var(--text-faint); text-decoration: none; }
.crm-login-back:hover { color: var(--gold-300); }

/* ── Header ──────────────────────────────────────────── */

.crm-shell { min-height: 100vh; }

.crm-workspace {
  min-width: 0;
  margin-left: var(--crm-sidebar-width);
}

.crm-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 90;
  width: var(--crm-sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 14px;
  overflow-y: auto;
  background: #100C07;
  border-right: 1px solid var(--glass-border);
  scrollbar-width: thin;
  scrollbar-color: rgba(200,121,26,.35) transparent;
}

.crm-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px 14px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--glass-border);
}

.crm-sidebar-brand img { width: 38px; height: 38px; object-fit: contain; }
.crm-sidebar-brand span { display: flex; min-width: 0; flex-direction: column; }
.crm-sidebar-brand strong { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 20px; line-height: 1.05; color: var(--gold-300); }
.crm-sidebar-brand small { margin-top: 3px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); }

.crm-sidebar-label {
  padding: 0 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.material-symbols-rounded {
  flex: 0 0 auto;
  font-size: 20px;
  line-height: 1;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.crm-admin-menu {
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  padding: 8px 0;
}

.crm-admin-menu summary {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.crm-admin-menu summary::-webkit-details-marker { display: none; }
.crm-admin-menu summary:hover { color: var(--gold-200); background: rgba(200,121,26,.08); }
.crm-admin-menu summary:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 2px; }
.crm-admin-chevron { margin-left: auto; transition: transform .18s ease; }
.crm-admin-menu[open] .crm-admin-chevron { transform: rotate(180deg); }

.crm-admin-links {
  display: grid;
  gap: 2px;
  padding: 5px 0 2px 12px;
}

.crm-admin-links a,
.crm-sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text-faint);
  font-size: 12px;
  text-decoration: none;
}

.crm-admin-links a .material-symbols-rounded,
.crm-sidebar-footer a .material-symbols-rounded { font-size: 18px; }
.crm-admin-links a:hover,
.crm-sidebar-footer a:hover { color: var(--gold-200); background: rgba(200,121,26,.08); }
.crm-admin-links a:focus-visible,
.crm-sidebar-footer a:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 1px; }

.crm-sidebar-footer {
  display: grid;
  gap: 3px;
  margin-top: auto;
  padding-top: 4px;
}

.crm-sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  border: 0;
  background: rgba(8,6,4,.72);
}

.crm-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(15,12,7,0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border);
}

.crm-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.crm-header-logo { width: 34px; height: auto; }
.crm-header-title { font-family: 'Cormorant Garamond', serif; font-size: 22px; color: var(--gold-300); line-height: 1.1; }
.crm-header-sub { font-size: 12px; color: var(--text-faint); }
.crm-header-right { display: flex; gap: 8px; flex-shrink: 0; }

.crm-menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: transparent;
  color: var(--gold-300);
  cursor: pointer;
}

.crm-menu-toggle:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 2px; }

.crm-ghost-btn {
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.crm-ghost-btn:hover { border-color: var(--glass-border-bright); color: var(--gold-300); }

/* ── Layout ──────────────────────────────────────────── */

.crm-main { max-width: 1320px; margin: 0 auto; padding: 20px 22px 80px; }
.crm-loading { padding: 60px 0; text-align: center; color: var(--text-faint); }

.crm-panel {
  background: var(--obs-800);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}

.crm-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.crm-panel-head h2 { font-size: 20px; color: var(--gold-200); }
.crm-panel-note { font-size: 12px; color: var(--text-faint); }

/* ── Today command centre ────────────────────────────────
   Colour carries one meaning throughout, so it can be read at a glance:
     red   = money or goodwill leaving right now
     amber = will cost you if ignored this week
     green = an opportunity, nothing broken
   Nothing decorative is coloured, so colour always means something.        */

.crm-headline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.crm-headline-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 15px 17px;
  background: var(--obs-700);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
}

.crm-headline-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }
.crm-headline-value { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--gold-200); font-variant-numeric: tabular-nums; }
.crm-headline-value.is-danger { color: var(--red); }
.crm-headline-value.is-warn { color: var(--amber); }
.crm-headline-value.is-good { color: var(--green); }
.crm-headline-note { font-size: 12px; color: var(--text-faint); }

.crm-action {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 18px;
  margin-bottom: 10px;
  background: var(--obs-800);
  border: 1px solid var(--glass-border);
  border-left: 4px solid var(--text-faint);
  border-radius: 14px;
}

.crm-action-danger { border-left-color: var(--red);   background: linear-gradient(90deg, rgba(224,115,107,.09), transparent 55%), var(--obs-800); }
.crm-action-warn   { border-left-color: var(--amber); background: linear-gradient(90deg, rgba(232,168,60,.09), transparent 55%), var(--obs-800); }
.crm-action-good   { border-left-color: var(--green); background: linear-gradient(90deg, rgba(34,197,94,.08), transparent 55%), var(--obs-800); }

.crm-action-main { flex: 1; min-width: 220px; }
.crm-action-title { font-size: 17px; font-weight: 600; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.crm-action-value { font-size: 15px; font-weight: 700; color: var(--gold-300); font-variant-numeric: tabular-nums; }
.crm-action-body { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin-top: 4px; }

.crm-action-cta {
  padding: 11px 18px;
  border-radius: 10px;
  border: none;
  background: var(--gold-500);
  color: #1A1208;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.crm-action-cta:hover { background: var(--gold-400); }

.crm-allclear {
  padding: 40px 22px;
  text-align: center;
  background: var(--obs-800);
  border: 1px solid rgba(34,197,94,0.28);
  border-radius: 16px;
}

.crm-allclear-title { font-family: 'Cormorant Garamond', serif; font-size: 24px; color: var(--green); }
.crm-allclear-body { font-size: 14px; color: var(--text-dim); margin-top: 6px; line-height: 1.6; }

.crm-lift {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  background: rgba(200,121,26,0.18);
  color: var(--gold-300);
  font-weight: 700;
  font-size: 13px;
}

/* ── View navigation ─────────────────────────────────── */

.crm-nav {
  display: grid;
  gap: 3px;
}

.crm-nav-btn {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  text-align: left;
}

.crm-nav-btn:hover { color: var(--gold-200); background: rgba(200,121,26,.08); }
.crm-nav-btn.active { background: var(--gold-500); color: #1A1208; }
.crm-nav-btn:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 2px; }
.crm-nav-btn > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.crm-nav-badge {
  display: inline-block;
  min-width: 19px;
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--red);
  color: #FFF;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}

.crm-nav-btn.active .crm-nav-badge { background: #1A1208; color: var(--gold-300); }

.crm-view { display: none; }
.crm-view.active { display: block; }

/* ── Filter bar ──────────────────────────────────────── */

.crm-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--obs-800);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
}

.crm-filterbar-note { font-size: 12px; color: var(--text-faint); margin-left: auto; }
.crm-filterbar .crm-seg.active::before { content: '✓ '; }
.crm-filterbar-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.crm-filterbar-divider { width: 1px; height: 22px; background: var(--glass-border); }
.crm-pill.season { background: rgba(200,121,26,0.16); color: var(--gold-300); }

/* ── Plan board ──────────────────────────────────────── */

.crm-plan-add { display: flex; gap: 8px; flex-wrap: wrap; }
.crm-plan-add .crm-field { flex: 1; min-width: 200px; }

.crm-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  align-items: start;
}

.crm-column { margin-bottom: 0; }
.crm-column h2 { font-size: 18px; }

.crm-task {
  padding: 12px 13px;
  margin-bottom: 8px;
  background: var(--obs-700);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--gold-500);
  border-radius: 0 10px 10px 0;
}

.crm-task-title { font-size: 14px; font-weight: 500; line-height: 1.45; }
.crm-task-notes { font-size: 12px; color: var(--text-faint); line-height: 1.6; margin-top: 5px; }
.crm-task-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.crm-task-btn {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}

.crm-task-btn:hover { border-color: var(--glass-border-bright); color: var(--gold-200); }
.crm-task-btn.done:hover { border-color: var(--green); color: var(--green); }
.crm-task-btn.danger:hover { border-color: var(--red); color: var(--red); }

/* ── Campaign composer ───────────────────────────────── */

.crm-field-label { display: block; margin: 16px 0 6px; font-size: 13px; font-weight: 600; color: var(--text-dim); }

.crm-field {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--obs-900);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}

.crm-field:focus { outline: none; border-color: var(--glass-border-bright); }
.crm-camp-count { margin-top: 8px; font-size: 13px; color: var(--text-dim); }
.crm-camp-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.crm-camp-status { min-height: 20px; margin-top: 10px; font-size: 13px; font-weight: 600; }

/* ── Tags and notes ──────────────────────────────────── */

.crm-tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

.crm-tag {
  padding: 6px 12px;
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.crm-tag:hover { border-color: var(--glass-border-bright); color: var(--gold-200); }
.crm-tag.on { background: var(--gold-500); border-color: var(--gold-500); color: #1A1208; font-weight: 600; }

.crm-notes {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--obs-900);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}

.crm-notes:focus { outline: none; border-color: var(--glass-border-bright); }
.crm-notes-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.crm-notes-status { font-size: 12px; }

/* ── Season cohort ───────────────────────────────────── */

.crm-panel-season { border-color: rgba(232,168,60,0.34); }

.crm-variety-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}

.crm-variety-name { flex: 0 0 150px; color: var(--text-dim); }
/* These must be block: width and height do not apply to inline elements, so
   as spans the bars rendered with zero height and never appeared. */
.crm-variety-bar-wrap { display: block; flex: 1; min-width: 40px; height: 16px; background: rgba(239,228,206,0.06); border-radius: 8px; overflow: hidden; }
.crm-variety-bar { display: block; height: 100%; min-width: 3px; background: var(--gold-500); border-radius: 8px; }
.crm-variety-qty { flex: 0 0 62px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

.crm-season-note {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 10px;
  background: rgba(200,121,26,0.10);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
}

/* ── Unpaid checkouts ────────────────────────────────── */

.crm-panel-alert { border-color: rgba(232,168,60,0.42); }

.crm-unpaid-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid rgba(200,121,26,0.14);
}

.crm-unpaid-main { flex: 1; min-width: 190px; }
.crm-unpaid-name { font-weight: 600; }
.crm-unpaid-meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.crm-unpaid-value { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.crm-unpaid-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.crm-action-btn {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.crm-action-btn:hover:not(:disabled) { border-color: var(--glass-border-bright); color: var(--gold-300); }
.crm-action-btn:disabled { opacity: .45; cursor: not-allowed; }
.crm-action-btn.primary { background: var(--gold-500); border-color: var(--gold-500); color: #1A1208; font-weight: 600; }
.crm-action-btn.primary:hover:not(:disabled) { background: var(--gold-400); color: #1A1208; }
.crm-unpaid-sent { font-size: 12px; color: var(--green); white-space: nowrap; }
.crm-unpaid-row.is-test { opacity: .55; }
.crm-test-badge {
  display: inline-block;
  padding: 2px 8px;
  margin-left: 6px;
  border-radius: 12px;
  background: rgba(239,228,206,0.10);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
}

/* ── Metric cards ────────────────────────────────────── */

.crm-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.crm-metric {
  background: var(--obs-700);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 16px;
}

.crm-metric-label { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; }
.crm-metric-value { font-size: 27px; font-weight: 600; margin-top: 5px; line-height: 1.1; }
.crm-metric-note { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.crm-metric.is-warn .crm-metric-value { color: var(--amber); }
.crm-metric.is-good .crm-metric-value { color: var(--green); }

/* ── Chart ───────────────────────────────────────────── */

.crm-chart-wrap { position: relative; width: 100%; height: 220px; }
.crm-chart-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; font-size: 12px; color: var(--text-dim); }
.crm-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.crm-legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ── Segments ────────────────────────────────────────── */

.crm-segments { display: flex; flex-wrap: wrap; gap: 8px; }

.crm-seg {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.crm-seg:hover { border-color: var(--glass-border-bright); color: var(--gold-200); }
.crm-seg.active { background: var(--gold-500); border-color: var(--gold-500); color: #1A1208; font-weight: 600; }
.crm-seg-count { opacity: .75; margin-left: 5px; }

/* ── List tools ──────────────────────────────────────── */

.crm-list-tools { display: flex; gap: 8px; flex-wrap: wrap; }

.crm-list-tools input,
.crm-list-tools select {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--glass-border);
  background: var(--obs-900);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.crm-list-tools input { min-width: 200px; }
.crm-list-tools input:focus, .crm-list-tools select:focus { outline: none; border-color: var(--glass-border-bright); }

/* ── Table ───────────────────────────────────────────── */

.crm-table-wrap { overflow-x: auto; }
.crm-table { width: 100%; border-collapse: collapse; font-size: 14px; }

.crm-table th {
  text-align: left;
  padding: 9px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--glass-border);
  font-weight: 500;
  white-space: nowrap;
}

.crm-table td { padding: 11px 10px; border-bottom: 1px solid rgba(200,121,26,0.10); vertical-align: middle; }
.crm-table tbody tr { cursor: pointer; }
.crm-table tbody tr:hover { background: rgba(200,121,26,0.07); }

.crm-cust-name { font-weight: 600; }
.crm-cust-meta { font-size: 12px; color: var(--text-faint); }
.crm-num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.crm-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.crm-pill.ok    { background: rgba(34,197,94,0.15);  color: #7EE2A8; }
.crm-pill.due   { background: rgba(232,168,60,0.16); color: var(--amber); }
.crm-pill.over  { background: rgba(224,115,107,0.16); color: var(--red); }
.crm-pill.new   { background: rgba(107,168,224,0.16); color: var(--blue); }
.crm-pill.muted { background: rgba(239,228,206,0.08); color: var(--text-faint); }

.crm-list-footer { margin-top: 12px; font-size: 12px; color: var(--text-faint); }
.crm-empty { padding: 34px 10px; text-align: center; color: var(--text-faint); }

/* ── Detail modal ────────────────────────────────────── */

.crm-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8,6,4,0.86);
  backdrop-filter: blur(8px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.crm-modal.open { display: flex; }

.crm-modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--obs-700);
  border: 1px solid var(--glass-border-bright);
  border-radius: 18px;
}

.crm-modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  background: var(--obs-700);
  border-bottom: 1px solid var(--glass-border);
}

.crm-modal-head h3 { font-size: 23px; color: var(--gold-200); }
.crm-modal-head p { margin: 3px 0 0; font-size: 13px; color: var(--text-dim); }

.crm-modal-close {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.crm-modal-close:hover { color: var(--gold-300); }
.crm-modal-body { padding: 18px 20px 24px; }

.crm-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.crm-detail-stat { background: var(--obs-800); border-radius: 12px; padding: 12px; }
.crm-detail-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.crm-detail-stat-value { font-size: 19px; font-weight: 600; margin-top: 3px; }

.crm-detail-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  margin: 18px 0 8px;
}

.crm-order-row {
  padding: 11px 0;
  border-top: 1px solid rgba(200,121,26,0.14);
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.crm-order-meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.crm-fav { display: flex; flex-wrap: wrap; gap: 6px; }

.crm-fav-item {
  padding: 4px 10px;
  border-radius: 14px;
  background: rgba(200,121,26,0.12);
  font-size: 12px;
  color: var(--gold-200);
}

@media (max-width: 640px) {
  .crm-main { padding: 14px 10px 60px; }
  .crm-panel { padding: 14px; border-radius: 14px; }
  .crm-list-tools { width: 100%; }
  .crm-list-tools input { flex: 1; min-width: 0; }
  .crm-metric-value { font-size: 23px; }
  .crm-header-title { font-size: 19px; }
}

@media (max-width: 900px) {
  .crm-workspace { margin-left: 0; }

  .crm-sidebar {
    width: min(286px, calc(100vw - 48px));
    transform: translateX(-105%);
    box-shadow: 18px 0 40px rgba(0,0,0,.35);
    transition: transform .2s ease;
  }

  body.crm-sidebar-open { overflow: hidden; }
  body.crm-sidebar-open .crm-sidebar { transform: translateX(0); }
  body.crm-sidebar-open .crm-sidebar-scrim { display: block; }
  .crm-menu-toggle { display: inline-flex; }
  .crm-header { padding: 11px 12px; }
  .crm-header-logo { display: none; }
  .crm-header-sub { max-width: min(58vw, 460px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .crm-sidebar,
  .crm-admin-chevron { transition: none; }
}
