/* CarePlatform shared styles (office portal and carer app). Light and dark mode. */
:root {
  --bg: #f3f6f8; --surface: #ffffff; --ink: #1b2631; --muted: #5a6772; --line: #d9e1e7;
  --brand: #1f5f5b; --brand-ink: #ffffff; --accent: #b8650d;
  --ok: #1b7a43; --okbg: #e3f4ea; --warn: #8a5200; --warnbg: #fff0d1; --bad: #b3261e; --badbg: #fbe2e0;
  --info: #1f3864; --infobg: #e6edf8; --mute: #55616c; --mutebg: #eceff2;
  --shadow: 0 1px 2px rgba(20, 30, 40, .08), 0 4px 14px rgba(20, 30, 40, .06);
  color-scheme: light; box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151b; --surface: #17202a; --ink: #e7edf2; --muted: #9db0bf; --line: #2a3846;
    --brand: #46b0a6; --brand-ink: #08201e; --accent: #f0a64f;
    --ok: #6fd49a; --okbg: #173326; --warn: #f0bf6a; --warnbg: #392a10; --bad: #ff9a92; --badbg: #3d1b19;
    --info: #9fbdf0; --infobg: #1a2840; --mute: #aab7c2; --mutebg: #222d38; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151b; --surface: #17202a; --ink: #e7edf2; --muted: #9db0bf; --line: #2a3846;
  --brand: #46b0a6; --brand-ink: #08201e; --accent: #f0a64f;
  --ok: #6fd49a; --okbg: #173326; --warn: #f0bf6a; --warnbg: #392a10; --bad: #ff9a92; --badbg: #3d1b19;
  --info: #9fbdf0; --infobg: #1a2840; --mute: #aab7c2; --mutebg: #222d38; --shadow: none; color-scheme: dark;
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); height: 100%; }
*, *::before, *::after { box-sizing: inherit; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; min-height: 100%; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; } h1 { font-size: 1.55rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .3em 0 .7em; } a { color: var(--brand); }
.muted { color: var(--muted); } .hint { font-size: 12.5px; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; line-height: 1.15; }
.btn:hover { border-color: var(--brand); } .btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); } .btn.ghost { background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; } .btn.block { display: block; width: 100%; text-align: center; }

/* cards, grids, tiles */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2 { margin-bottom: .55em; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } .g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); text-align: left; cursor: default; }
button.tile { cursor: pointer; width: 100%; } button.tile:hover { border-color: var(--brand); }
.tile .n { font-size: 1.8rem; font-weight: 700; line-height: 1.1; } .tile .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tile.bad .n { color: var(--bad); } .tile.warn .n { color: var(--warn); } .tile.ok .n { color: var(--ok); }
.ind { background: var(--surface); border: 1px solid var(--line); border-left-width: 6px; border-radius: 12px; padding: 10px 12px; }
.ind.ok { border-left-color: var(--ok); } .ind.warn { border-left-color: var(--accent); } .ind.bad { border-left-color: var(--bad); } .ind.mute { border-left-color: var(--line); }
.ind .v { font-size: 1.25rem; font-weight: 700; } .ind .l { font-size: 12.5px; color: var(--muted); }

/* chips and alerts */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.ok { background: var(--okbg); color: var(--ok); } .chip.warn { background: var(--warnbg); color: var(--warn); } .chip.bad { background: var(--badbg); color: var(--bad); }
.chip.info { background: var(--infobg); color: var(--info); } .chip.mute { background: var(--mutebg); color: var(--mute); }
.alert { border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.alert.warn { background: var(--warnbg); color: var(--warn); } .alert.bad { background: var(--badbg); color: var(--bad); }
.alert.info { background: var(--infobg); color: var(--info); } .alert.ok { background: var(--okbg); color: var(--ok); }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: var(--mutebg); white-space: nowrap; }
tr:last-child td { border-bottom: 0; } tr.click { cursor: pointer; } tr.click:hover td { background: var(--mutebg); }
.empty { padding: 18px; text-align: center; color: var(--muted); }

/* forms */
.field { margin: 10px 0; } .field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 10px; }
textarea { min-height: 84px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; } .row > .grow { flex: 1; min-width: 140px; }
.checkline { display: flex; gap: 8px; align-items: center; margin: 8px 0; } .checkline input { width: 18px; height: 18px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 0 0 14px; }
.tabs button { border: 0; background: transparent; padding: 9px 13px; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 600; color: var(--muted); }
.tabs button.on { color: var(--brand); border-color: var(--brand); }

/* layout */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; align-self: start; height: 100vh; overflow: auto; display: flex; flex-direction: column; }
.brand { font-weight: 700; color: var(--brand); display: flex; gap: 8px; align-items: center; padding: 4px 8px 12px; font-size: 1.05rem; }
.brand i { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); display: inline-grid; place-items: center; font-style: normal; }
.nav button { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 11px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.nav button.on { background: var(--brand); color: var(--brand-ink); } .nav button:hover:not(.on) { background: var(--mutebg); }
.who { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: 13px; } .who b { display: block; }
.main { padding: 18px 20px 40px; min-width: 0; max-width: 1280px; }
.page-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; } .page-head p { margin: 0; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 5px 12px; font-size: 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.policy-text { white-space: pre-wrap; background: var(--mutebg); border-radius: 10px; padding: 12px; font-size: 14px; max-height: 50vh; overflow: auto; }
.list-line { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); } .list-line:last-child { border-bottom: 0; } .list-line .grow { flex: 1; min-width: 0; }
.spark { color: var(--brand); vertical-align: middle; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: column; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: flex; gap: 4px; overflow-x: auto; } .nav button { width: auto; white-space: nowrap; margin: 0; } .who { margin-top: 8px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
  .main { padding: 14px 12px 40px; } .kv { grid-template-columns: 1fr; }
}

/* sign in */
.auth { max-width: 440px; margin: 8vh auto; padding: 0 16px; } .auth .card { padding: 22px; }
.keybox { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.15rem; letter-spacing: 2px; background: var(--mutebg); border-radius: 10px; padding: 12px; word-break: break-all; user-select: all; }

/* modal and toast */
.overlay { position: fixed; inset: 0; background: rgba(10, 16, 22, .55); display: grid; place-items: start center; padding: 6vh 12px; overflow: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 16px; width: min(720px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; } .modal-body { padding: 14px 18px; } .modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 12px; z-index: 80; max-width: 90vw; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }
.loading { color: var(--muted); padding: 20px 0; }
@media print { .side, .btn, .tabs { display: none !important; } .app { display: block; } }

/* rota */
table.rota { table-layout: fixed; min-width: 980px; } table.rota th { text-align: center; } table.rota th.today { background: var(--brand); color: var(--brand-ink); }
table.rota th:first-child, table.rota td:first-child { width: 150px; text-align: left; } table.rota td { vertical-align: top; padding: 6px; border-right: 1px solid var(--line); height: 54px; }
table.rota td.absent { background: repeating-linear-gradient(45deg, var(--mutebg), var(--mutebg) 6px, transparent 6px, transparent 12px); }
.abs { font-size: 12px; font-weight: 700; color: var(--mute); margin-bottom: 4px; }
.rv { display: block; width: 100%; text-align: left; border: 1px solid var(--info); background: var(--infobg); color: var(--info); border-radius: 8px; padding: 4px 6px; margin-bottom: 4px; font-size: 12.5px; line-height: 1.25; cursor: pointer; }
.rv.draft { background: transparent; border-style: dashed; } .rv.done { background: var(--okbg); color: var(--ok); border-color: var(--ok); } .rv.progress { background: var(--warnbg); color: var(--warn); border-color: var(--warn); }
.rv.missed, .rv.open { background: var(--badbg); color: var(--bad); border-color: var(--bad); } .rv:hover { filter: brightness(.96); }

table.rota td.unusual { background: repeating-linear-gradient(90deg, transparent, transparent 4px, var(--mutebg) 4px, var(--mutebg) 5px); }

/* print views (reports) */
.printview { position: fixed; inset: 0; z-index: 90; background: #fff; color: #000; overflow: auto; }
.printbar { position: sticky; top: 0; display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: #f3f3f3; border-bottom: 1px solid #999; }
.sheet-holder { padding: 14px 16px 40px; }
.printview .sheet { max-width: 1000px; margin: 0 auto; font-size: 13px; line-height: 1.35; }
.printview .sheet.landscape { max-width: 1250px; }
.printview .sheet *, .printview .sheet-holder { color: #000; }
.sheet-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; }
.sheet-head h1 { font-size: 20px; margin: 0; } .sheet-brand { font-weight: 700; letter-spacing: 1px; font-size: 11px; text-transform: uppercase; } .sheet-meta { font-size: 11px; text-align: right; white-space: nowrap; }
.sheet h2 { font-size: 14px; margin: 14px 0 4px; border-bottom: 1px solid #000; }
.sheet table.rt { width: 100%; border-collapse: collapse; margin: 6px 0; } .sheet table.rt th, .sheet table.rt td { border: 1px solid #000; padding: 3px 6px; text-align: left; vertical-align: top; font-size: 12px; background: #fff; }
.sheet table.rt th { background: #e6e6e6; text-transform: none; letter-spacing: 0; font-size: 12px; } .sheet table.wk td { height: 46px; } .sheet table.wk td:first-child { width: 120px; }
.sheet tr.needs td { border-width: 2px; font-weight: 600; } .sheet .abs { font-weight: 700; } .sheet .small { font-size: 11px; } .sheet-foot { margin-top: 14px; font-size: 11px; border-top: 1px solid #000; padding-top: 4px; }
@media print {
  #root, .overlay, .toast { display: none !important; }
  .printview { position: static; overflow: visible; background: #fff; }
  .printbar { display: none !important; } .sheet-holder { padding: 0; } .printview .sheet, .printview .sheet.landscape { max-width: none; }
  .sheet.landscape { page: land; } @page land { size: A4 landscape; margin: 10mm; } @page { size: A4; margin: 12mm; }
  .sheet table.rt tr { break-inside: avoid; } .sheet-head { break-after: avoid; }
}

/* ---- documents made from templates: shown on screen, in the print view, and on paper ---- */
.doc-text, .printview .sheet.doc { font-family: Aptos, Calibri, 'Segoe UI', -apple-system, 'Helvetica Neue', Arial, sans-serif; }
.doc-text { font-size: 13px; line-height: 1.5; }
.doc-text h1 { font-size: 22px; margin: 4px 0 14px; } .doc-text h2 { font-size: 15px; margin: 18px 0 6px; padding-bottom: 2px; border-bottom: 1px solid currentColor; } .doc-text h3 { font-size: 13px; margin: 12px 0 4px; }
.doc-text p { margin: 0 0 8px; } .doc-text ul { margin: 0 0 8px; padding-left: 22px; }
.doc-text table.doc-table { border-collapse: collapse; width: 100%; margin: 6px 0 12px; font-size: 12px; } .doc-table th, .doc-table td { border: 1px solid #000; padding: 4px 6px; text-align: left; vertical-align: top; } .doc-table th { background: #e6e6e6; }
.doc-blank { background: #e6e6e6; border: 1px dashed #666; padding: 0 2px; border-radius: 2px; }
.doc-text .pagebreak { break-after: page; height: 0; border-top: 1px dashed #999; margin: 14px 0; }
.printview .sheet.doc { max-width: 820px; padding-top: 6px; }
@media print { .doc-text .pagebreak { border: 0; margin: 0; } .printview .sheet.doc { max-width: none; font-size: 12px; } }
