/* Prudent Chartered Case Manager — styles matching the signed-off mockups. */
:root {
  --bg: #F5F6F8; --surface: #FFFFFF; --border: #E2E5EA; --text: #18212D; --muted: #5A6474;
  --accent: #1D5FB0; --accent-weak: #E9F1FB; --accent-text: #174E91;
  --danger: #A3221B; --danger-strong: #B42318; --ok: #1A6B42; --ok-weak: #E6F4EC;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Overall size of the app. 1 = full size; 0.8 = everything at 80%. Change this one number to resize. */
  --ui-scale: 0.8;
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; zoom: var(--ui-scale); }
a { color: var(--accent); }
a:hover { color: var(--accent-text); }
h1, h2, h3 { margin: 0; }
.ic { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Layout */
.shell { display: flex; min-height: calc(100vh / var(--ui-scale)); }
.nav { flex: 0 0 232px; background: var(--surface); border-right: 1px solid var(--border); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-head { display: flex; align-items: center; gap: 8px; padding: 4px 0 20px; }
.brand { display: flex; flex: 1; align-items: center; gap: 10px; padding: 0 4px; text-decoration: none; min-width: 0; }
.logo { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; flex: none; }
.brand .txt b { display: block; font-size: 14px; color: var(--text); white-space: nowrap; }
.brand .txt span { display: block; font-size: 12px; color: var(--muted); }
.nav-toggle { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.nav a.item, .nav span.item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 42px; border-radius: 8px; text-decoration: none; font-weight: 500; color: var(--muted); }
.nav a.item:hover { background: var(--bg); color: var(--text); }
.nav a.item[aria-current="page"] { background: var(--accent-weak); color: var(--accent-text); font-weight: 600; }
.nav span.item { opacity: .55; cursor: default; }
.nav .soon { margin-left: auto; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
body.nav-hidden .nav { flex-basis: 72px; }
body.nav-hidden .nav .label, body.nav-hidden .brand .txt, body.nav-hidden .nav .soon { display: none; }
body.nav-hidden .nav-head { flex-direction: column; }
body.nav-hidden .nav-toggle svg { transform: rotate(180deg); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 20px; }
.topbar .grow { flex: 1 1 180px; min-width: 0; }
.me { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.content { padding: 24px 28px 40px; display: flex; flex-direction: column; gap: 20px; max-width: 1760px; width: 100%; }

/* Pieces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; min-width: 0; }
.card h2 { font-size: 15px; margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.av { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; color: #fff; font-weight: 700; flex: none; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn:hover { background: var(--bg); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-text); color: #fff; }
.btn.danger { color: var(--danger); border-color: #F3C7C3; }
.btn.small { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--accent-text); padding: 0 4px; }
.seg { display: inline-flex; width: fit-content; padding: 3px; border-radius: 10px; background: #E9ECF0; gap: 2px; }
.seg a { height: 32px; padding: 0 12px; display: inline-flex; align-items: center; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg a[aria-current="true"] { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 10px 14px; text-decoration: none; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a[aria-current="page"] { color: var(--accent-text); font-weight: 600; border-bottom-color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 10px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person > div > b { display: block; font-weight: 600; }
.person > div > span { display: block; font-size: 12px; color: var(--muted); }

/* Forms */
label { font-weight: 600; font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input:not([type]), select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; color: var(--text); background: #fff;
}
textarea { height: auto; padding: 10px 12px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label, .checks li { font-weight: 500; list-style: none; }
.checks ul { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 0; }
.help { font-size: 12px; color: var(--muted); font-weight: 400; }
.errorlist { margin: 4px 0 0; padding: 0; list-style: none; color: var(--danger); font-size: 12px; }

/* Menus (details/summary, no JavaScript needed) */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu .menu-list { position: absolute; right: 0; top: 40px; z-index: 5; min-width: 240px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 24px rgba(16,24,40,.14); padding: 4px 0; }
.menu-list form { margin: 0; }
.menu-list button { display: block; width: 100%; padding: 9px 14px; border: 0; background: none; text-align: left; font: inherit; cursor: pointer; color: var(--text); }
.menu-list button:hover { background: var(--bg); }
.menu-list button.danger { color: var(--danger); }
.menu-list .sep { border-top: 1px solid var(--border); margin: 4px 0; }

/* Messages */
.messages { display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 10px 14px; border-radius: 10px; font-weight: 500; overflow-wrap: anywhere; }
.msg.success { background: var(--ok-weak); color: var(--ok); }
.msg.error { background: #FDECEC; color: var(--danger); }
.msg.info, .msg.warning { background: var(--accent-weak); color: var(--accent-text); }

/* Sign-in pages */
.auth { min-height: calc(100vh / var(--ui-scale)); display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 420px; max-width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(16,24,40,.06); }
.auth-card h1 { font-size: 20px; margin: 16px 0 6px; }
.auth-card form p, .auth-card form > div { margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.auth-card button[type=submit], .auth-card form button { height: 40px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; padding: 0 16px; }
.auth-card .google { display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px; height: 44px; border: 1px solid var(--border) !important; background: #fff !important; color: var(--text) !important; }
.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-card img { max-width: 220px; }
.auth-card code { word-break: break-all; }

/* Roles matrix */
.matrix td:first-child { font-weight: 600; }
.matrix td { font-size: 13px; }

@media (max-width: 800px) {
  .nav { display: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}
.help ul { margin: 4px 0 0; padding-left: 18px; }

/* Stage 2: clients */
.tagchip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; text-decoration: none; }
.cav { display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--accent-weak); color: var(--accent-text); font-weight: 700; flex: none; }
.two-col { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.two-col > .main-col { flex: 999 1 620px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.two-col > .side-col { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
dl.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px 24px; }
dl.facts dt { font-size: 12px; font-weight: 600; color: var(--muted); }
dl.facts dd { margin: 4px 0 0; white-space: pre-line; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.rte { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.rte-body { min-height: 200px; max-height: 520px; overflow-y: auto; padding: 14px 16px; line-height: 1.6; outline: none; }
.rte-body.small { min-height: 72px; max-height: 240px; }
.rte-body:empty::before { content: attr(data-placeholder); color: #6B7483; }
.rte-body h3 { font-size: 15px; margin: 10px 0 6px; }
.rte-body ul, .rte-body ol, .rich ul, .rich ol { padding-left: 22px; margin: 4px 0 8px; }
.rte-body p, .rich p { margin: 0 0 8px; }
.rte-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 6px; background: #F7F8FA; border-top: 1px solid var(--border); }
.rte-bar button { min-width: 34px; height: 34px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; font: inherit; cursor: pointer; color: var(--text); }
.rte-bar button:hover { background: #E9ECF0; }
.rte-bar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.rich { line-height: 1.55; }
.rich h3 { font-size: 15px; margin: 8px 0 4px; }
.comment { display: flex; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.comment .who { font-weight: 600; font-size: 13px; }
dialog.modal { width: 640px; max-width: calc(100% - 32px); max-height: calc(86vh / var(--ui-scale)); padding: 0; border: 0; border-radius: 14px; box-shadow: 0 20px 48px rgba(16,24,40,.28); }
dialog.modal::backdrop { background: rgba(16,24,40,.45); }
dialog.modal .mhead { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; }
dialog.modal .mbody { padding: 14px 20px 18px; }
.taginput { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 38px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.taginput input { flex: 1 1 120px; min-width: 120px; border: 0 !important; height: 28px !important; padding: 0 4px !important; outline: none; }
.taginput .tagchip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 4px; font-size: 14px; line-height: 1; }
.activity li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13px; }
.activity li:first-child { border-top: 0; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.statgrid { display: flex; flex-wrap: wrap; gap: 12px; }
.stat { flex: 1 1 140px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.stat b { display: block; font-size: 22px; }
.problem-error { color: var(--danger); }
.problem-warning { color: #8A4B00; }
.colour-choices ul, .colour-choices > div { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 0; list-style: none; }
.colour-choices label { font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }

/* Stage 3: cases */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kcol { background: #EEF0F3; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 160px; transition: background .12s; }
.kcol.drop { background: #DDE7F5; outline: 2px dashed #1D5FB0; outline-offset: -2px; }
.khead { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; }
.kcard { display: block; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-decoration: none; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.kcard:hover { border-color: #B8C2CF; }
.kcard[draggable="true"] { cursor: grab; }
.kcard.dragging { opacity: .5; }
.kempty { text-align: center; padding: 18px 0; }
.checks > div { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.checks > div > div label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.pill { white-space: nowrap; flex-shrink: 0; }

.repeat-summary:not(:empty) { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: #E9F1FB; color: #174E91; font-size: 13px; line-height: 1.5; }
.repeat-btn.on { border-color: #1D5FB0; color: #174E91; background: #F4F8FD; }
.rep-icon { display: inline-flex; vertical-align: -2px; margin-left: 4px; color: #1D5FB0; }
[hidden] { display: none !important; }
