/* SPS Global CRM. Colours come from the SPS Global logo:
   navy wordmark, and the three leaves, which double as lead status colours
   (red = Hot, amber = Warm, teal = Cold). */
:root {
  --ink: #262259;
  --ink-2: #3a3670;
  --paper: #f6f6f3;
  --surface: #ffffff;
  --line: #e2e1ea;
  --line-2: #cfcde0;
  --muted: #646283;
  --hot: #e0313a;
  --warm: #f2a43a;
  --warm-ink: #8a5300;
  --cold: #16978c;
  --none: #b9b7cc;
  --good: #16978c;
  --bad: #c9252e;
  --focus: #2b62d9;
  --radius: 6px;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--focus); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }

/* ---------- Sign-in ---------- */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 440px) 1fr; }
.signin-panel { background: var(--surface); padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; gap: 22px; border-right: 1px solid var(--line); }
.signin-panel img { width: 190px; }
.signin-panel h1 { font-family: var(--serif); font-weight: 600; font-size: 28px; margin: 0; letter-spacing: -0.01em; }
.signin-panel p { margin: 0; color: var(--muted); max-width: 34ch; }
.signin-art { position: relative; overflow: hidden; background: var(--ink); color: #fff; display: flex; align-items: flex-end; padding: 48px; }
.signin-art .leaves { position: absolute; inset: 0; }
.signin-art .leaves span { position: absolute; border-radius: 4px 70% 4px 70%; opacity: .92; }
.signin-art blockquote { position: relative; font-family: var(--serif); font-size: 26px; line-height: 1.3; max-width: 22ch; margin: 0; }
.env-badge { display: inline-block; align-self: flex-start; padding: 2px 8px; border-radius: 3px; background: #fff3dc; color: var(--warm-ink); font-weight: 600; font-size: 12px; }

/* ---------- App frame ---------- */
.frame { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #e9e8f4; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.side .brand img { width: 40px; }
.side .brand b { font-family: var(--serif); font-weight: 600; font-size: 19px; color: #fff; }
.side .brand small { display: block; color: #b8b6d6; font-size: 12px; }
.side nav { flex: 1; overflow-y: auto; padding: 6px 10px 16px; }
.side nav .group { color: #9d9bc4; font-size: 12px; margin: 16px 10px 4px; }
.side nav a { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 5px; color: #e9e8f4; text-decoration: none; }
.side nav a:hover { background: var(--ink-2); }
.side nav a[aria-current="page"] { background: #fff; color: var(--ink); font-weight: 600; }
.side nav a .count { font-size: 12px; background: var(--hot); color: #fff; border-radius: 9px; padding: 0 7px; }
.side .me { border-top: 1px solid var(--ink-2); padding: 12px 18px 16px; font-size: 13px; }
.side .me b { display: block; color: #fff; }
.side .me span { color: #b8b6d6; }
.side .me .links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; white-space: nowrap; }
.side .me button { background: none; border: 0; color: #d9d8ef; padding: 0; cursor: pointer; text-decoration: underline; }
.topbar-mobile { display: none; }

main { min-width: 0; padding: 26px 32px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: 27px; margin: 0; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 19px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); padding: 7px 13px; border-radius: var(--radius); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--ink-2); }
.btn.danger { color: var(--bad); border-color: #f0c1c4; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.link { border: 0; background: none; padding: 0; color: var(--focus); text-decoration: underline; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, .field > .label { font-weight: 500; font-size: 13px; }
.field .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  border: 1px solid var(--line-2); background: #fff; border-radius: var(--radius); padding: 7px 9px; min-width: 0; width: 100%;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 2px #d6e2fb; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; cursor: pointer; border-right: 1px solid var(--line-2); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg button.hot[aria-pressed="true"] { background: var(--hot); }
.seg button.warm[aria-pressed="true"] { background: var(--warm); color: #3b2500; }
.seg button.cold[aria-pressed="true"] { background: var(--cold); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.quick button { border: 1px dashed var(--line-2); background: none; border-radius: 4px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { width: 260px; }
.filters select { width: auto; }
.error-text { color: var(--bad); font-size: 13px; }
.note { background: #fff8ea; border: 1px solid #f6dcaa; color: #5d3d00; padding: 9px 12px; border-radius: var(--radius); font-size: 13px; }
.note.info { background: #eef3fd; border-color: #cddbf7; color: #1f3b77; }

/* ---------- Lead status: the three leaves ---------- */
.leaf { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.leaf i { width: 11px; height: 11px; border-radius: 1px 9px 1px 9px; background: var(--none); flex: none; }
.leaf.hot i { background: var(--hot); }
.leaf.warm i { background: var(--warm); }
.leaf.cold i { background: var(--cold); }
.leaf.none { color: var(--muted); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: #ecebf3; color: var(--ink); white-space: nowrap; }
.pill.untouched { background: #ecebf3; }
.pill.enquiry { background: #e3eefc; color: #1f4a8f; }
.pill.not_applied { background: #fff1d9; color: var(--warm-ink); }
.pill.applicant { background: #dcf3f0; color: #0e5f58; }
.pill.bad { background: #fde3e4; color: #8e1a20; }
.pill.good { background: #dcf3f0; color: #0e5f58; }
.pill.muted { background: #efeff3; color: var(--muted); }
.attempts { font-size: 12px; color: var(--muted); }
.attempts.full { color: var(--cold); font-weight: 600; }

/* Status strip: one bar showing how a set of leads splits by status */
.strip { display: flex; height: 26px; border-radius: 4px; overflow: hidden; background: #ecebf3; }
.strip span { display: block; height: 100%; min-width: 2px; }
.strip .hot { background: var(--hot); } .strip .warm { background: var(--warm); } .strip .cold { background: var(--cold); }
.strip .never { background: repeating-linear-gradient(135deg, var(--cold) 0 5px, #8fd0c9 5px 10px); }
.strip .nostatus { background: var(--none); } .strip .untouched { background: #dcdbe8; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 13px; }
.legend b { font-variant-numeric: tabular-nums; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 1px 8px 1px 8px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Panels, tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.panel.narrow { max-width: 860px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.figures { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 4px 0 2px; }
.figures div { min-width: 78px; }
.figures b { display: block; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.figures span { color: var(--muted); font-size: 13px; }
.figures .alert b { color: var(--bad); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #fafafc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #f8f8fc; }
td .sub { display: block; color: var(--muted); font-size: 12px; }
td.num, th.num { text-align: right; }
.overdue { color: var(--bad); font-weight: 600; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; color: var(--muted); font-size: 13px; }

/* ---------- Drawer and dialogs ---------- */
.scrim { position: fixed; inset: 0; background: rgba(28, 25, 66, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--paper); z-index: 41; display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(28,25,66,.18); }
.drawer header { background: var(--surface); padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.drawer header h2 { font-size: 23px; margin: 0; }
.drawer header .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 8px; color: var(--muted); font-size: 13px; }
.drawer header .close { position: absolute; top: 12px; right: 14px; }
.drawer .body { flex: 1; overflow-y: auto; padding: 16px 22px 40px; display: flex; flex-direction: column; gap: 14px; }
.drawer .bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 5px 16px; margin: 0; font-size: 13px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); margin-left: 5px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 1px 8px 1px 8px; background: var(--line-2); }
.timeline li.hot::before { background: var(--hot); } .timeline li.warm::before { background: var(--warm); } .timeline li.cold::before { background: var(--cold); }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .what { font-weight: 600; }
.timeline .text { white-space: pre-wrap; }
dialog.modal { border: 0; border-radius: 10px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(28,25,66,.3); color: var(--ink); }
dialog.modal::backdrop { background: rgba(28, 25, 66, .4); }
dialog.modal form { display: flex; flex-direction: column; }
dialog.modal .m-head { padding: 18px 22px 0; }
dialog.modal .m-head h2 { margin: 0; }
dialog.modal .m-head p { margin: 4px 0 0; color: var(--muted); }
dialog.modal .m-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 12px; max-height: 70vh; overflow-y: auto; }
dialog.modal .m-foot { padding: 12px 22px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }

#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 90vw; }
.toast.bad { background: var(--bad); }
.notif-panel { position: fixed; left: 232px; bottom: 16px; width: 360px; max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; z-index: 45; box-shadow: 0 12px 40px rgba(28,25,66,.2); }
.notif-panel .item { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.notif-panel .item.unread { background: #f3f6fe; }
.notif-panel .item small { color: var(--muted); display: block; }
.matrix td, .matrix th { padding: 6px 8px; }
.matrix select { width: auto; padding: 3px 6px; }
.matrix .locked { color: var(--muted); }
pre.json { white-space: pre-wrap; font-size: 12px; background: #fafafc; border: 1px solid var(--line); padding: 8px; border-radius: 4px; margin: 6px 0 0; max-height: 240px; overflow: auto; }
.loading { color: var(--muted); padding: 20px 0; }

@media (prefers-reduced-motion: no-preference) {
  .drawer { animation: slidein .18s ease-out; }
  @keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}
@media (max-width: 900px) {
  .signin { grid-template-columns: 1fr; }
  .signin-art { display: none; }
  .frame { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 50; transform: translateX(-100%); transition: transform .15s; }
  .side.open { transform: none; }
  .topbar-mobile { display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 30; }
  .topbar-mobile button { background: none; border: 1px solid #6b67a3; color: #fff; border-radius: 5px; padding: 4px 10px; }
  main { padding: 18px 14px 60px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .filters input[type=search] { width: 100%; }
  .notif-panel { left: 8px; right: 8px; width: auto; }
}
