/* ============================================================
   JET Platform — demo CRM for The Jon Egging Trust
   Brand palette sampled from joneggingtrust.org.uk:
     navy   #243746   sky #2ea3f2   red #e52528 / #671c17
   ============================================================ */

:root {
  --navy: #243746;
  --navy-2: #1b2a36;
  --navy-3: #2f4658;
  --sky: #2ea3f2;
  --sky-2: #1d8de0;
  --sky-soft: #e4f1fc;
  --red: #e52528;
  --red-dark: #671c17;
  --green: #1f9d6b;
  --amber: #e89c1c;
  --purple: #7e3bd0;

  --bg: #eef2f5;
  --panel: #ffffff;
  --line: #e1e8ed;
  --line-2: #eef2f5;
  --ink: #243746;
  --ink-soft: #5b6b78;
  --ink-faint: #8a99a5;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(36,55,70,.06), 0 4px 16px rgba(36,55,70,.06);
  --shadow-lg: 0 8px 40px rgba(36,55,70,.16);
  --sidebar-w: 244px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: .16s ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--sky-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0; color: var(--navy); font-weight: 700; }
button { font-family: var(--font); cursor: pointer; }
::selection { background: var(--sky); color: #fff; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #cdd9e1;
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 40;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #38505f; border-radius: 4px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  position: sticky; top: 0; background: var(--navy); z-index: 2; cursor: pointer;
}
.brand .brand-logo { width: 168px; max-width: 80%; height: auto; display: block; }
.brand .brand-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--sky); border: 1px solid rgba(46,163,242,.4); border-radius: 5px;
  padding: 2px 6px; align-self: flex-start; margin-top: 4px;
}
/* inline icons */
.ic { display: inline-block; vertical-align: middle; flex: none; }
.nav-item .ic { width: 17px; height: 17px; opacity: .85; }
.nav-item.active .ic, .nav-item:hover .ic { opacity: 1; }
.btn .ic { margin-right: -1px; }
.kpi .kpi-ico .ic { width: 20px; height: 20px; }
.card-head h3 .ic, .card-head h3 .title-ico { margin-right: 6px; color: var(--sky-2); vertical-align: -3px; }
.page-head h1 .ic, .page-head h1 .title-ico .ic { color: var(--sky-2); vertical-align: -2px; margin-right: 6px; }
.btn .ic { vertical-align: -3px; }
.ai-action-icon { color: var(--sky-2); display: flex; }
.lab-head .ic { color: var(--sky-2); }
.lab-feature .lab-head .lab-ico { display: flex; color: var(--sky-2); }
.topbar .pill .ic, .toast .ic { vertical-align: middle; }

.nav { padding: 6px 0 28px; }
.nav-group + .nav-group { margin-top: 2px; }
.nav-group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .13em;
  color: #6d8392; padding: 15px 20px 7px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8.5px 20px; color: #b9c7d1; font-size: 13px;
  border-left: 3px solid transparent; cursor: pointer;
  white-space: nowrap; transition: var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(46,163,242,.16); color: #fff; border-left-color: var(--sky); font-weight: 600; }
.nav-item .ico { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; opacity: .8; flex: none; }
.nav-item .count { margin-left: auto; font-size: 10.5px; font-weight: 600; background: rgba(255,255,255,.12); padding: 1px 7px; border-radius: 10px; color: #cdd9e1; }
.nav-item.active .count { background: rgba(46,163,242,.3); color: #fff; }
.nav-group--lab .nav-group-label { color: var(--sky); }
.nav-item.lab { color: #cfe6fa; }
.nav-item.lab .ico { color: var(--sky); opacity: 1; }

/* ---------- Main area ---------- */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px; position: sticky; top: 0; z-index: 30;
}
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input {
  width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); font-size: 13px;
}
.topbar .search input:focus { outline: none; border-color: var(--sky); background: #fff; }
.topbar .search .si { position: absolute; left: 11px; top: 8px; color: var(--ink-faint); }
.topbar .spacer { flex: 1; }
.topbar .pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
  color: var(--ink-soft); padding: 5px 11px; border: 1px solid var(--line);
  border-radius: 20px; background: #fff;
}
.topbar .pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.topbar .pill.ok .dot { background: var(--green); }
.topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--sky);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px;
}

.view { padding: 24px 26px 60px; max-width: 1400px; width: 100%; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .titles h1 { font-size: 24px; letter-spacing: -.4px; }
.page-head .titles p { margin: 6px 0 0; color: var(--ink-soft); font-size: 13px; line-height: 1.6; max-width: 78ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumbs { font-size: 12px; color: var(--ink-faint); margin-bottom: 7px; }
.crumbs a { color: var(--ink-faint); }
.crumbs a:hover { color: var(--sky-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  transition: var(--transition); line-height: 1.2;
}
.btn:hover { border-color: var(--sky); color: var(--sky-2); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(46,163,242,.28); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--sky); border-color: var(--sky); color: #fff; box-shadow: 0 1px 2px rgba(29,141,224,.25); }
.btn-primary:hover { background: var(--sky-2); border-color: var(--sky-2); color: #fff; }
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-2); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-head {
  padding: 14px 18px 13px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.card-head h3 { font-size: 14px; font-weight: 700; letter-spacing: -.1px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-head > .count-note:last-child { margin-left: auto; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 720px) { .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; } }

/* ---------- KPI tiles ---------- */
.kpi { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi .label { font-size: 11px; color: var(--ink-faint); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 27px; font-weight: 800; color: var(--navy); letter-spacing: -.6px; line-height: 1.1; margin-top: 2px; }
.kpi .delta { font-size: 12px; font-weight: 600; margin-top: 1px; }
.kpi .delta.up { color: var(--green); }
.kpi .delta.down { color: var(--red); }
.kpi .kpi-sub { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.kpi .spark { position: absolute; right: 14px; bottom: 14px; opacity: .9; }
.kpi .kpi-ico { position: absolute; top: 15px; right: 16px; opacity: .3; color: var(--sky); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 11px 16px; color: var(--ink-faint);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--line); font-weight: 700; white-space: nowrap;
  background: var(--line-2); position: sticky; top: 0;
}
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { cursor: pointer; transition: background .12s; }
table.data tbody tr:hover { background: var(--sky-soft); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .muted { color: var(--ink-faint); }

.toolbar { display: flex; gap: 9px; align-items: center; padding: 13px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.toolbar input[type=search], .toolbar select {
  padding: 7px 11px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; background: #fff; color: var(--ink);
}
.toolbar input[type=search]:focus, .toolbar select:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(46,163,242,.14); }
.toolbar input[type=search] { min-width: 220px; }
.toolbar .count-note { margin-left: auto; color: var(--ink-faint); font-size: 12px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; line-height: 1.4; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-sky { background: var(--sky-soft); color: var(--sky-2); }
.b-green { background: #e3f5ec; color: var(--green); }
.b-amber { background: #fdf2dd; color: #b9760a; }
.b-red { background: #fde6e6; color: var(--red); }
.b-grey { background: #eef2f5; color: var(--ink-soft); }
.b-navy { background: #e3e9ee; color: var(--navy); }
.b-purple { background: #f0e7fb; color: var(--purple); }

.avatar-sm {
  width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; flex: none;
}
.cell-person { display: inline-flex; align-items: center; gap: 9px; }

/* ---------- Detail view ---------- */
.detail-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.detail-head .big-avatar {
  width: 58px; height: 58px; border-radius: 14px; display: grid; place-items: center;
  font-size: 22px; font-weight: 800; color: #fff; flex: none;
}
.detail-head .meta h1 { font-size: 22px; }
.detail-head .meta .sub { color: var(--ink-soft); font-size: 13px; margin-top: 3px; }
.field-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 2px 28px; }
@media (max-width:720px){ .field-grid { grid-template-columns: 1fr; } }
.field { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.field .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-weight: 700; }
.field .v { font-size: 14px; margin-top: 3px; color: var(--ink); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 9px 14px; font-size: 13px; color: var(--ink-soft); border-bottom: 2px solid transparent; font-weight: 600; cursor: pointer; }
.tab:hover { color: var(--navy); }
.tab.active { color: var(--sky-2); border-bottom-color: var(--sky); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px 20px; }
@media (max-width:720px){ .form-grid { grid-template-columns: 1fr; } }
.form-field.full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: 12px; font-weight: 700; color: var(--navy); margin-bottom: 5px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; background: #fff; color: var(--ink);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(46,163,242,.14); }
.form-field .hint { font-size: 11px; color: var(--ink-faint); margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(27,42,54,.5); display: grid; place-items: center; z-index: 80; padding: 20px; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 640px; max-height: 90vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 900px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-head .x { margin-left: auto; border: none; background: none; font-size: 20px; color: var(--ink-faint); cursor: pointer; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 9px; box-shadow: var(--shadow-lg);
  font-size: 13px; display: flex; align-items: center; gap: 10px; min-width: 240px; animation: toastin .2s ease;
}
.toast.ok { border-left: 4px solid var(--green); }
.toast.err { border-left: 4px solid var(--red); }
.toast.info { border-left: 4px solid var(--sky); }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Misc ---------- */
.progress { height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--sky); border-radius: 6px; }
.progress.green > span { background: var(--green); }
.progress.amber > span { background: var(--amber); }
.empty { text-align: center; padding: 50px 20px; color: var(--ink-faint); }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); font-weight: 700; margin: 26px 0 12px; }
.lab-flag {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600;
  background: linear-gradient(90deg, #fdf2dd, #fff); border: 1px dashed var(--amber); color: #946008;
  padding: 6px 12px; border-radius: 20px;
}
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--line-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; }

/* generic muted/hint text (used widely, incl. inside link cards) */
.hint { font-size: 12px; color: var(--ink-faint); }
.muted { color: var(--ink-faint); }

/* card-style block links (programme cards, etc.) */
.section-card {
  display: block; padding: 13px 15px; background: #fff; text-decoration: none;
  border: 1px solid var(--line); border-left: 3px solid var(--sky);
  border-radius: var(--radius-sm); transition: var(--transition);
}
.section-card:hover { background: var(--sky-soft); border-left-color: var(--sky-2); text-decoration: none; }
.section-card h3 { color: var(--navy); }

/* checklist with sky ticks */
ul.checklist { list-style: none; padding: 0; margin: 0; }
ul.checklist li { position: relative; padding: 6px 0 6px 26px; }
ul.checklist li::before {
  content: ""; position: absolute; left: 2px; top: 9px; width: 13px; height: 8px;
  border-left: 2px solid var(--green); border-bottom: 2px solid var(--green);
  transform: rotate(-45deg);
}
.note-box { background: var(--sky-soft); border: 1px solid #c9e3f8; border-radius: 9px; padding: 13px 15px; font-size: 13px; color: var(--navy-3); }
.warn-box { background: #fdf2dd; border: 1px solid #f3dca3; border-radius: 9px; padding: 13px 15px; font-size: 13px; color: #7a5410; }

/* hamburger for small screens */
.menu-btn { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
}
