/* AvaMed Workforce. Mobile first: a 16px gutter on phones, a sidebar from 900px wide. No scripts or fonts from outside. */
:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #17262b;
  --muted: #5b6d73;
  --line: #d9e1e4;
  --brand: #0f6b6b;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1f1;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --bad: #9b1c1c;
  --bad-soft: #fde6e6;
  --good: #17633a;
  --good-soft: #e2f4ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 40, 45, 0.08), 0 4px 14px rgba(20, 40, 45, 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1719;
    --panel: #172226;
    --ink: #e7eef0;
    --muted: #9ab0b6;
    --line: #2a3b40;
    --brand: #4fb6b6;
    --brand-ink: #062022;
    --brand-soft: #1d3a3c;
    --warn: #f0c35b;
    --warn-soft: #3a3014;
    --bad: #ff8a8a;
    --bad-soft: #3d1d1d;
    --good: #7ad7a0;
    --good-soft: #17331f;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1719;
  --panel: #172226;
  --ink: #e7eef0;
  --muted: #9ab0b6;
  --line: #2a3b40;
  --brand: #4fb6b6;
  --brand-ink: #062022;
  --brand-soft: #1d3a3c;
  --warn: #f0c35b;
  --warn-soft: #3a3014;
  --bad: #ff8a8a;
  --bad-soft: #3d1d1d;
  --good: #7ad7a0;
  --good-soft: #17331f;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
h3 { font-size: 15px; margin: 14px 0 6px; }
p { margin: 0 0 10px; }
a { color: var(--brand); }
small, .muted { color: var(--muted); }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 12px; top: 12px; background: var(--panel); padding: 8px; z-index: 50; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 232px; background: var(--panel); border-right: 1px solid var(--line);
  padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex: none;
}
.brandbar { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; }
.brandbar img { width: 30px; height: 30px; }
.nav a {
  display: block; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none;
}
.nav a:hover { background: var(--brand-soft); }
.nav a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }
.nav h4 { margin: 14px 8px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.main { flex: 1; min-width: 0; padding: 18px 22px 80px; }
.topbar { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.topbar .who { font-size: 13px; color: var(--muted); }
.search { flex: 1; max-width: 380px; }

@media (max-width: 899px) {
  .shell { display: block; }
  .side {
    position: static; width: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--line);
    padding: 8px 10px; overflow-x: auto;
  }
  .brandbar { padding: 4px 4px 8px; }
  .nav { display: flex; gap: 4px; }
  .nav h4 { display: none; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .main { padding: 14px 16px 40px; }
  .search { max-width: none; width: 100%; }
}

/* Controls */
button, .button {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 13px; border-radius: 8px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px;
}
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.danger { color: var(--bad); }
button.quiet { border-color: transparent; background: transparent; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.small, .button.small { min-height: 32px; padding: 4px 9px; font-size: 13px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-height: 40px; width: 100%; max-width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; margin-right: 6px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
label.check { display: flex; align-items: center; color: var(--ink); font-size: 14px; min-height: 40px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.row > .shrink { flex: 0 0 auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.error { color: var(--bad); background: var(--bad-soft); padding: 8px 10px; border-radius: 8px; margin: 8px 0; }
.notice { color: var(--warn); background: var(--warn-soft); padding: 8px 10px; border-radius: 8px; margin: 8px 0; }
.ok { color: var(--good); background: var(--good-soft); padding: 8px 10px; border-radius: 8px; margin: 8px 0; }

/* Cards and tables */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi b { display: block; font-size: 24px; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi.alert b { color: var(--bad); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--bg); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--brand-soft); }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--ink); border: 1px solid var(--line); white-space: nowrap; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 220px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; min-height: 42px; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--brand); font-weight: 600; }
dl.facts { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 13px; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.stage-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.stage { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.stage h3 { display: flex; justify-content: space-between; margin: 2px 2px 8px; font-size: 13px; text-transform: uppercase; color: var(--muted); }
.card-mini { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.card-mini b { display: block; }
.repeat { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.drawer-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; z-index: 40; }
.modal {
  background: var(--panel); color: var(--ink); width: min(680px, 100%); max-height: 90vh; overflow-y: auto;
  border-radius: 14px 14px 0 0; padding: 16px; box-shadow: var(--shadow);
}
@media (min-width: 700px) {
  .drawer-bg { align-items: center; }
  .modal { border-radius: 14px; }
}
.modal header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.toast-wrap { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60; display: grid; gap: 8px; max-width: 460px; margin: 0 auto; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 12px; border-radius: 10px; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 8px; border: 1px solid var(--line); }
.signing { max-width: 640px; margin: 24px auto; padding: 0 16px; }
.center-card { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.inline-list { display: flex; flex-wrap: wrap; gap: 6px; }
.stack > * + * { margin-top: 10px; }
.hide { display: none !important; }
@media print {
  .side, .topbar, .actions, .toolbar, button { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; color: #000; }
}

/* ---- additions for the screens ---- */
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0 0 2px; }
.page-head p { margin: 0; }
.page-head .toolbar { margin: 0; }
a.kpi { display: block; text-decoration: none; color: var(--ink); }
a.kpi:hover { border-color: var(--brand); }
a.kpi b { color: var(--ink); text-decoration: none; }
/* minmax(0, 1fr): a wide table inside a card scrolls within the card instead of widening the whole page. */
.two-up { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); margin-top: 14px; }
@media (min-width: 900px) { .two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card-title { margin-top: 0; font-size: 16px; }
.stack-list { list-style: none; margin: 0; padding: 0; }
.stack-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.stack-item:last-child { border-bottom: 0; }
.stack-item > div { min-width: 0; overflow-wrap: anywhere; }
.filter { flex: 0 1 180px; min-width: 150px; }
.filter select, .filter input { min-width: 0; }
.picker { display: grid; gap: 6px; }
.picked { font-size: 14px; }
.picker-results { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; max-height: 260px; overflow-y: auto; background: var(--panel); }
.picker-results:empty { display: none; }
.picker-results li { border-bottom: 1px solid var(--line); }
.picker-results li:last-child { border-bottom: 0; }
button.pick { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; border: 0; border-radius: 0; min-height: 44px; }
button.pick small { color: var(--muted); }
.picker-results .muted { padding: 10px; display: block; }
.field-error { color: var(--bad); font-size: 13px; margin-top: 4px; }
[aria-invalid="true"] { border-color: var(--bad) !important; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label.check { min-height: 36px; }
.group { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0 0 12px; min-width: 0; }
.group legend { padding: 0 6px; font-size: 13px; color: var(--muted); }
.group-title { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.grid-fields { display: grid; gap: 0 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .grid-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.group-field .repeat { margin-bottom: 10px; }
.group-field .repeat .grid-fields .field { margin-bottom: 8px; }
.form { display: block; }
.form .actions { position: sticky; bottom: 0; background: var(--panel); padding: 10px 0 2px; }
.intro { color: var(--muted); margin-bottom: 10px; }
.copybox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.copybox input { flex: 1 1 260px; }
.empty { color: var(--muted); padding: 10px 0; }
.list-screen .table-wrap { margin-top: 4px; }
.list-body { min-height: 80px; }
.error:empty, .notice:empty, .ok:empty { display: none; }
input[readonly] { background: var(--bg); }
.stat-row { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; }
.stat-row b { font-size: 18px; display: block; }
.stat-row span { color: var(--muted); font-size: 13px; }
.card .actions { margin-top: 10px; }
.section-gap { margin-top: 18px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.tabs button[role="tab"] { white-space: nowrap; }
.tabs { overflow-x: auto; }
.banner-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
@media (max-width: 899px) { .main { padding-bottom: 60px; } .toast-wrap { bottom: 16px; } }

/* Activity timeline: notes, calls and events, newest first. The dot sits on the left rule. */
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.tl-item { position: relative; padding: 0 0 16px 14px; min-width: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -22px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--panel);
}
.tl-item .tl-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.tl-item .tl-title { font-weight: 600; overflow-wrap: anywhere; }
.tl-item .tl-body { overflow-wrap: anywhere; margin-top: 2px; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.tab-body { min-height: 120px; }
.tab-body > .card:first-child { margin-top: 0; }

/* Pipeline board: one column per stage. It scrolls sideways on phones. */
.board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 8px; }
.board-col { flex: 0 0 240px; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.board-col h3 { font-size: 14px; margin: 0 0 8px; display: flex; justify-content: space-between; gap: 8px; }
.board-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; overflow-wrap: anywhere; }
.board-name { font-weight: 600; }
.board-card .actions { margin-top: 6px; }
.note-form { margin-bottom: 14px; }
