/* ==========================================================================
   Cognitive Steps — calm clinical interface
   Palette: navy · teal · warm white · muted sage
   ========================================================================== */

:root {
    /* Cognitive Steps brand: yellow + charcoal on white */
    --brand: #F2E91C;
    --brand-dark: #D8CF00;
    --brand-deep: #B8B000;
    --brand-soft: #FBF7D2;
    --brand-ink: #6B6500;      /* text on yellow: 6.2:1 on #F2E91C */
    --brand-panel: #FFFDF2;    /* light panel top */
    --brand-panel-end: #F7F2D6;/* light panel bottom */
    --brand-wash: #FDFBEB;
    --ink: #2D2D2D;
    --ink-deep: #1C1C1C;
    --ink-soft: #3D3D3D;
    --paper: #FFFFFF;
    --paper-deep: #F7F6F1;
    --line: #E4E2D9;
    --line-strong: #CBC8BC;
    --muted: #5F5F5A;
    --white: #ffffff;
    --danger: #B4472F;
    --danger-soft: #FBEDE8;
    --amber: #8A6A08;
    --amber-soft: #FBF3D9;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(28, 28, 28, .05), 0 3px 12px rgba(28, 28, 28, .05);
    --shadow: 0 8px 26px rgba(28, 28, 28, .08);
    --shadow-lg: 0 18px 46px rgba(28, 28, 28, .14);
    --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

    /* Aliases kept so older rules keep working (brand mapping) */
    --navy: var(--ink);
    --navy-deep: #1C1C1C;
    --navy-soft: #3D3D3D;
    --teal: var(--brand-dark);
    --teal-dark: var(--brand-deep);
    --teal-soft: var(--brand-soft);
    --sage: #D8D5C6;
    --sage-soft: #F4F2E6;
    --warm: #FBFAF4;
    --warm-deep: #F2F0E6;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--warm);
    font-size: 15.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 2.4vw, 1.85rem); }
h2 { font-size: clamp(1.28rem, 1.9vw, 1.5rem); }
h3 { font-size: 1.06rem; }
p { margin: 0 0 1em; }
a { color: var(--teal-dark); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--teal); }
small { font-size: .82rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 999;
    background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 0 0 10px 10px;
    transition: top .15s ease; text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 0; color: #fff; }

:focus-visible {
    outline: 3px solid rgba(45, 45, 45, .45);
    outline-offset: 2px;
    border-radius: 6px;
}

.icon { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.center-block { max-width: 560px; margin: 8vh auto; text-align: center; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 14px; } .mt-4 { margin-top: 22px; }
.mb-0 { margin-bottom: 0; } .mb-3 { margin-bottom: 14px; } .mb-4 { margin-bottom: 22px; }
.stack { display: grid; gap: 20px; }
.stack--tight { gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------------------------------------------------------------- Buttons */
.btn {
    --btn-bg: var(--white);
    --btn-fg: var(--navy);
    --btn-bd: var(--line-strong);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: 10px; border: 1px solid var(--btn-bd);
    background: var(--btn-bg); color: var(--btn-fg); font: inherit; font-weight: 600;
    font-size: .92rem; text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); color: var(--btn-fg); }
.btn:active { transform: translateY(0); }
.btn--primary { --btn-bg: var(--brand); --btn-fg: var(--ink-deep); --btn-bd: var(--brand-dark); box-shadow: 0 4px 14px rgba(184, 176, 0, .28); }
.btn--primary:hover { --btn-bg: var(--brand-dark); --btn-bd: var(--brand-deep); color: var(--ink-deep); }
.btn--navy { --btn-bg: var(--ink); --btn-fg: #fff; --btn-bd: var(--ink); }
.btn--navy { --btn-bg: var(--navy); --btn-fg: #fff; --btn-bd: var(--navy); }
.btn--navy:hover { color: #fff; --btn-bg: var(--navy-soft); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--navy); }
.btn--ghost:hover { --btn-bg: rgba(16,41,63,.06); }
.btn--outline { --btn-bg: transparent; --btn-bd: var(--line-strong); }
.btn--danger { --btn-bg: transparent; --btn-bd: rgba(180,71,47,.4); --btn-fg: var(--danger); }
.btn--danger:hover { --btn-bg: var(--danger-soft); }
.btn--sm { padding: 7px 12px; font-size: .85rem; border-radius: 8px; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.btn--link { border: 0; background: none; padding: 0; color: var(--teal-dark); font-weight: 600; text-decoration: underline; cursor: pointer; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
    border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--navy); cursor: pointer;
}
.icon-btn:hover { background: rgba(16,41,63,.07); }
button { font-family: inherit; }

/* ---------------------------------------------------------------- Badges */
.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
    font-size: .76rem; font-weight: 600; letter-spacing: .01em; border: 1px solid transparent;
    background: var(--warm-deep); color: var(--muted); white-space: nowrap;
}
.badge--teal { background: var(--teal-soft); color: var(--teal-dark); border-color: rgba(184, 176, 0, .45); }
.badge--sage { background: var(--sage-soft); color: #4A4A42; border-color: rgba(203, 200, 188, .7); }
.badge--amber { background: var(--amber-soft); color: var(--amber); border-color: rgba(154,107,18,.22); }
.badge--red { background: var(--danger-soft); color: var(--danger); border-color: rgba(180,71,47,.22); }
.badge--muted { background: #eef0ea; color: var(--muted); }
.badge--neutral { background: #f1f2ee; color: #4A4A48; }
.badge--dark { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.2); }

/* ---------------------------------------------------------------- Cards */
.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card--pad { padding: 22px; }
.card--flush { overflow: hidden; }
.card__head {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.card__head h2, .card__head h3 { margin: 0; font-size: 1rem; }
.card__body { padding: 22px; }
.card__body--tight { padding: 14px 18px; }
.card__foot { padding: 14px 22px; border-top: 1px solid var(--line); background: #fcfbf7; }
.card--tinted { background: linear-gradient(180deg, #fff, #fbfaf5); }
.card--navy { background: linear-gradient(150deg, var(--navy) 0%, #2D2D2D 60%, #3A3A3A 100%); color: #fff; border-color: transparent; }
.card--navy h2, .card--navy h3 { color: #fff; }
.card--navy .muted { color: rgba(255,255,255,.72); }

.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.stat {
    display: flex; flex-direction: column; gap: 6px; padding: 20px 22px;
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); text-decoration: none; color: inherit;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
a.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); color: inherit; }
.stat__label { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; }
.stat__value { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; color: var(--navy); line-height: 1.1; }
.stat__meta { font-size: .84rem; color: var(--muted); }
.stat--teal .stat__value { color: var(--teal-dark); }
.stat--amber .stat__value { color: var(--amber); }

/* ---------------------------------------------------------------- Shell */
.shell { display: flex; min-height: 100vh; }
/* App sidebar: light brand panel (was near-black, which hid the yellow logo).
   Text tokens below are checked at >= 7:1 against #FFFDF2 -> #F7F2D6. */
.sidebar {
    width: 258px; flex: none;
    background:
        radial-gradient(520px 320px at 100% -8%, rgba(242, 233, 28, .30), transparent 62%),
        linear-gradient(185deg, #FFFDF2 0%, #FCF9EA 55%, #F7F2D6 100%);
    color: var(--ink);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column; padding: 20px 16px;
    position: sticky; top: 0; height: 100vh; z-index: 30;
}
.sidebar::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 55%, var(--ink) 100%);
}
.sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 6px 6px 20px; }
.brand-mark {
    width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center;
    background: var(--brand); color: var(--ink-deep); font-weight: 800;
    font-size: .95rem; letter-spacing: .02em; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1rem; letter-spacing: .01em; color: var(--ink-deep); }
.brand-text small { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.sidebar__close { display: none; margin-left: auto; color: var(--ink); background: transparent; border: 0; cursor: pointer; }
.sidebar__nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.sidebar__nav a {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
    color: #3F3F3A; text-decoration: none; font-size: .93rem; font-weight: 550;
    transition: background .15s ease, color .15s ease;
}
.sidebar__nav a:hover { background: rgba(45, 45, 45, .07); color: var(--ink-deep); }
.sidebar__nav a.is-active {
    background: var(--brand); color: var(--ink-deep); font-weight: 700;
    box-shadow: inset 3px 0 0 var(--ink), 0 2px 8px rgba(184, 176, 0, .28);
}
.sidebar__nav .icon { width: 19px; height: 19px; opacity: .95; }
.sidebar__foot { margin-top: auto; display: grid; gap: 10px; padding-top: 18px; border-top: 1px solid var(--line-strong); }
.sidebar__public { display: flex; align-items: center; gap: 9px; color: #4A4A42; text-decoration: none; font-size: .85rem; padding: 6px 4px; }
.sidebar__public:hover { color: var(--ink-deep); }
.who { display: flex; align-items: center; gap: 10px; padding: 8px 6px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: var(--brand); color: var(--ink-deep); font-weight: 700; font-size: .8rem;
    border: 1px solid rgba(0,0,0,.08);
}
.who__text { display: flex; flex-direction: column; min-width: 0; }
.who__text strong { color: var(--ink-deep); font-size: .88rem; font-weight: 650; }
.who__text small { color: var(--muted); font-size: .76rem; }
.sidebar__foot .btn--ghost { color: var(--ink); justify-content: flex-start; border: 1px solid var(--line-strong); }
.sidebar__foot .btn--ghost:hover { background: rgba(45,45,45,.05); color: var(--ink-deep); }
.sidebar-scrim { display: none; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: var(--warm); }
.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
    padding: 12px clamp(16px, 3vw, 34px); background: rgba(250,247,241,.9);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar__menu { display: none; }
.search { position: relative; display: flex; align-items: center; flex: 0 1 420px; }
.search .icon { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); }
.search input {
    width: 100%; padding: 10px 14px 10px 38px; border-radius: 10px; border: 1px solid var(--line-strong);
    background: var(--white); font: inherit; font-size: .9rem; color: var(--ink);
}
.search input:focus { border-color: var(--teal); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar__privacy { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); font-weight: 600; }
.topbar__privacy .icon { width: 15px; height: 15px; }
.lang-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--white); }
.lang-switch a { padding: 4px 9px; font-size: .74rem; font-weight: 700; color: var(--muted); text-decoration: none; letter-spacing: .04em; }
.lang-switch a.is-active { background: var(--navy); color: #fff; }
.app .lang-switch { background: transparent; border-color: rgba(255,255,255,.2); }
.content { padding: clamp(20px, 3vw, 34px); flex: 1 1 auto; }
.appfoot {
    display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap;
    padding: 18px clamp(16px, 3vw, 34px); border-top: 1px solid var(--line);
    color: var(--muted); font-size: .78rem;
}

/* ---------------------------------------------------------------- Page head */
.page-head { margin-bottom: 24px; }
.crumbs { display: flex; gap: 8px; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--teal-dark); text-decoration: underline; }
.page-head__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; }
.page-sub { margin: 0; color: var(--muted); font-size: .92rem; max-width: 70ch; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Tables */
.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
    font-weight: 700; background: #fcfbf7; position: sticky; top: 0; z-index: 1;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fdfcf8; }
.table td .row { gap: 8px; }
.table a.person { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; }
.table a.person:hover { color: var(--teal-dark); }
.person .avatar { background: var(--teal-soft); color: var(--teal-dark); border-color: rgba(184, 176, 0, .3); width: 32px; height: 32px; font-size: .74rem; }
.person small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; }

/* ---------------------------------------------------------------- Alerts */
.alert { padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line-strong); background: #fff; margin-bottom: 18px; font-size: .9rem; }
.alert--success { background: var(--teal-soft); border-color: rgba(184, 176, 0, .35); color: var(--teal-dark); }
.alert--error { background: var(--danger-soft); border-color: rgba(180,71,47,.3); color: #8a3524; }
.alert--warning { background: var(--amber-soft); border-color: rgba(154,107,18,.28); color: #7a5510; }
.alert--info { background: var(--sage-soft); border-color: rgba(203, 200, 188, .8); color: #4A4A42; }
.nl-note { border-left: 3px solid var(--sage); padding: 4px 0 4px 14px; color: var(--muted); font-size: .88rem; }

/* ---------------------------------------------------------------- Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field label, .field > label { font-size: .84rem; font-weight: 650; color: var(--navy); }
.req { color: var(--danger); margin-left: 3px; }
.help { margin: 0; font-size: .78rem; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="date"],
input[type="datetime-local"], input[type="number"], input[type="search"], input[type="time"], select, textarea {
    width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
    background: #fff; font: inherit; font-size: .92rem; color: var(--ink); transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(242, 233, 28, .35); outline: none; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--teal); }
.check label { font-size: .88rem; font-weight: 500; color: var(--ink); display: grid; gap: 4px; }
.check .help { font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 20px; background: #fff; }
legend { padding: 0 8px; font-weight: 700; font-size: .92rem; color: var(--navy); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.inline-form { display: inline-flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 22px; padding-bottom: 2px; }
.tabs a {
    padding: 9px 14px; border-radius: 9px 9px 0 0; font-size: .87rem; font-weight: 600; color: var(--muted);
    text-decoration: none; white-space: nowrap; border: 1px solid transparent; border-bottom: 2px solid transparent;
}
.tabs a:hover { background: var(--warm-deep); color: var(--navy); }
.tabs a.is-active { color: var(--teal-dark); border-bottom-color: var(--teal); background: #fff; }

/* ---------------------------------------------------------------- Wizard */
.wizard-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; padding: 0; list-style: none; }
.wizard-steps li { flex: 1 1 120px; }
.wizard-steps a, .wizard-steps span {
    display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 10px;
    font-size: .83rem; text-decoration: none; color: var(--muted); border: 1px solid var(--line); background: #fff;
}
.wizard-steps .num {
    width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: var(--warm-deep); color: var(--muted); font-size: .76rem; font-weight: 700;
}
.wizard-steps .is-current a, .wizard-steps .is-current span { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-dark); font-weight: 650; }
.wizard-steps .is-current .num { background: var(--teal); color: #fff; }
.wizard-steps .is-done .num { background: var(--sage); color: #26331a; }
.wizard-steps .is-done a { color: var(--navy); }

/* ---------------------------------------------------------------- Key/value */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px 24px; margin: 0; }
.kv > div { min-width: 0; }
.kv dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.kv dd { margin: 0; font-size: .92rem; color: var(--ink); overflow-wrap: anywhere; }
.section-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 0 0 10px; }
.section-block { margin-bottom: 26px; }
.section-block:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline li::before {
    content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px;
    border-radius: 50%; background: #fff; border: 2px solid var(--teal);
}
.timeline time { display: block; font-size: .76rem; color: var(--muted); font-weight: 600; }
.timeline strong { font-size: .9rem; }
.timeline p { margin: 2px 0 0; font-size: .86rem; color: var(--muted); }

/* ---------------------------------------------------------------- Empty */
.empty { text-align: center; padding: 40px 22px; }
.empty__icon { width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 14px; display: grid; place-items: center; background: var(--sage-soft); color: #6B6A5C; }
.empty h3 { margin-bottom: 4px; }
.empty p { color: var(--muted); margin: 0 auto 16px; max-width: 46ch; }

/* ---------------------------------------------------------------- Notes */
.note-sections { display: grid; gap: 18px; }
.note-block { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.note-block__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; background: var(--sage-soft); border-bottom: 1px solid var(--line); }
.note-block__head h3 { margin: 0; font-size: .92rem; }
.note-block__head .letter { width: 26px; height: 26px; border-radius: 8px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.note-block textarea { border: 0; border-radius: 0; min-height: 130px; box-shadow: none; }
.note-block textarea:focus { box-shadow: inset 0 0 0 2px rgba(45, 45, 45, .28); }
.note-block[data-readonly] { background: #fcfbf7; }
.note-body { white-space: pre-wrap; padding: 16px 18px; font-size: .92rem; }
.autosave { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; color: var(--muted); }
.autosave .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sage); }
.autosave[data-state="saving"] .dot { background: var(--amber); }
.autosave[data-state="error"] .dot { background: var(--danger); }
.autosave[data-state="saved"] .dot { background: var(--teal); }
.locked-note { background: var(--sage-soft); border: 1px solid rgba(203, 200, 188, .9); border-radius: 12px; padding: 12px 16px; font-size: .86rem; color: #4A4A42; }

/* ---------------------------------------------------------------- Privacy mode */
body.privacy-mode .ident { filter: blur(5px); user-select: none; }
.privacy-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); font-weight: 600; }

/* ---------------------------------------------------------------- Public site */
body.public { background: var(--warm); }
.pubhead { position: sticky; top: 0; z-index: 40; background: rgba(250,247,241,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.pubhead__inner { max-width: 1160px; margin: 0 auto; padding: 14px clamp(16px, 4vw, 32px); display: flex; align-items: center; gap: 20px; }
.pubbrand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--navy); }
.pubbrand .brand-text strong { color: var(--navy); }
.pubbrand .brand-text small { color: var(--muted); }
.pubnav { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.pubnav a { color: var(--navy); text-decoration: none; font-size: .9rem; font-weight: 550; }
.pubnav a:hover { color: var(--teal-dark); }
.pubhead__toggle { display: none; margin-left: auto; }
.pubfoot { background: var(--navy-deep); color: rgba(255,255,255,.76); margin-top: 0; }
.pubfoot__inner { max-width: 1160px; margin: 0 auto; padding: 44px clamp(16px, 4vw, 32px) 20px; display: flex; gap: 32px; justify-content: space-between; flex-wrap: wrap; }
.pubfoot strong { color: #fff; font-size: 1.05rem; }
.pubfoot p { margin: 6px 0 0; max-width: 46ch; font-size: .88rem; }
.pubfoot nav { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
.pubfoot nav a { color: rgba(255,255,255,.8); text-decoration: none; font-size: .88rem; }
.pubfoot nav a:hover { color: #fff; text-decoration: underline; }
.pubfoot__legal { max-width: 1160px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px) 34px; font-size: .78rem; color: rgba(255,255,255,.55); }

.container { max-width: 1160px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); }
.section { padding: clamp(44px, 7vw, 84px) 0; }
.section--alt { background: linear-gradient(180deg, var(--warm) 0%, #f4f1e9 100%); }
.section-head { max-width: 62ch; margin-bottom: 32px; }
.section-head h2 { margin-bottom: 10px; }
.section-head p { color: var(--muted); margin: 0; }
.eyebrow { display: inline-block; font-size: .76rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: var(--teal-dark); margin-bottom: 10px; }

.hero { position: relative; overflow: hidden; background: radial-gradient(1000px 520px at 82% -10%, rgba(216, 213, 198, .45), transparent 62%), linear-gradient(150deg, #1C1C1C 0%, #333333 62%, #3A3A3A 100%); color: #fff; }
.hero__inner { max-width: 1160px; margin: 0 auto; padding: clamp(48px, 8vw, 96px) clamp(16px, 4vw, 32px); display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center; position: relative; z-index: 1; }
.hero h1 { font-size: clamp(2.1rem, 4.4vw, 3.15rem); letter-spacing: -.02em; margin-bottom: 18px; color: #fff; }
.hero p.lead { font-size: clamp(1rem, 1.5vw, 1.16rem); color: rgba(255,255,255,.82); max-width: 46ch; margin-bottom: 28px; }
.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .btn--outline { --btn-bd: rgba(255,255,255,.38); --btn-fg: #fff; --btn-bg: rgba(255,255,255,.06); }
.hero .btn--outline:hover { --btn-bg: rgba(255,255,255,.16); color: #fff; }
.hero__panel { background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius-lg); padding: 26px; backdrop-filter: blur(14px); box-shadow: var(--shadow-lg); }
.hero__panel h2 { font-size: 1rem; color: #fff; letter-spacing: .02em; }
.hero__panel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.hero__panel li { display: flex; gap: 11px; align-items: flex-start; font-size: .9rem; color: rgba(255,255,255,.86); }
.hero__panel .icon { width: 18px; height: 18px; color: var(--brand); margin-top: 2px; }
.hero__note { margin-top: 18px; font-size: .78rem; color: rgba(255,255,255,.62); border-top: 1px solid rgba(255,255,255,.16); padding-top: 14px; }

.svc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.svc { display: flex; flex-direction: column; gap: 10px; padding: 24px; }
.svc__icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal-dark); margin-bottom: 4px; }
.svc h3 { margin: 0; }
.svc p { margin: 0; color: var(--muted); font-size: .9rem; }
.svc ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: .87rem; display: grid; gap: 4px; }
.steps { counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; list-style: none; margin: 0; padding: 0; }
.steps li { counter-increment: step; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; position: relative; }
.steps li::before {
    content: counter(step, decimal-leading-zero); font-size: .8rem; font-weight: 700; color: var(--teal-dark);
    background: var(--teal-soft); border-radius: 8px; padding: 3px 8px; display: inline-block; margin-bottom: 10px;
}
.steps h3 { font-size: .98rem; margin-bottom: 6px; }
.steps p { margin: 0; font-size: .87rem; color: var(--muted); }
.people { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.person-card { padding: 22px; display: grid; gap: 6px; }
.person-card .avatar { background: var(--sage-soft); color: #4A4A42; width: 52px; height: 52px; font-size: 1rem; margin-bottom: 6px; }
.person-card h3 { margin: 0; font-size: 1rem; }
.person-card p { margin: 0; font-size: .87rem; color: var(--muted); }
.faq { display: grid; gap: 12px; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }
.faq summary { cursor: pointer; font-weight: 600; font-size: .95rem; }
.faq summary::marker { color: var(--teal); }
.faq details[open] summary { margin-bottom: 10px; }
.faq p { margin: 0; color: var(--muted); font-size: .9rem; }
.contact-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 28px; align-items: start; }
.contact-card { padding: 26px; }
.notice { border: 1px solid rgba(180,71,47,.28); background: var(--danger-soft); color: #7d3222; border-radius: 12px; padding: 14px 16px; font-size: .87rem; margin-bottom: 18px; }
.notice strong { display: block; margin-bottom: 4px; }

/* ---------------------------------------------------------------- Login */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
/* Login side panel: warm light brand panel.
   Endpoint colours: #FFFDF2 (top) and #F7F2D6 (bottom); text tokens below are
   verified at >= 7:1 against both. The brand mark sits on a white plate so the
   yellow "C" never disappears into the pale background. */
.auth-aside {
    background:
        radial-gradient(760px 460px at 92% -12%, rgba(242, 233, 28, .34), transparent 64%),
        linear-gradient(165deg, var(--brand-panel) 0%, #FCF8E6 58%, var(--brand-panel-end) 100%);
    color: var(--ink);
    border-right: 1px solid var(--line);
    padding: clamp(28px, 5vw, 56px);
    display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 6px;
    background: linear-gradient(90deg, var(--brand) 0%, var(--brand-dark) 55%, var(--ink) 100%);
}
.auth-aside { position: relative; overflow: hidden; }
.auth-aside h1 { color: var(--ink-deep); font-size: clamp(1.6rem, 2.6vw, 2.1rem); max-width: 24ch; }
.auth-aside p { color: #4A4A42; max-width: 40ch; }
.auth-aside ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
.auth-aside li { display: flex; gap: 10px; color: var(--ink-soft); font-size: .9rem; }
.auth-aside .icon { color: var(--brand-ink); width: 18px; height: 18px; margin-top: 2px; }
.auth-aside .eyebrow { color: var(--brand-ink); }
.auth-aside .pubbrand {
    display: inline-flex; align-items: center; gap: 12px; text-decoration: none;
    background: #fff; border: 1px solid var(--line); border-radius: 14px;
    padding: 10px 16px 10px 12px; box-shadow: var(--shadow-sm);
}
.auth-aside .brand-text strong { color: var(--ink-deep); }
.auth-aside .brand-text small { color: var(--muted); }
.auth-aside .auth-aside__legal { color: var(--muted); margin: 0; }
@media (max-width: 980px) {
    .auth-aside::before { height: 4px; }
}
.auth-main { padding: clamp(28px, 5vw, 56px); display: flex; align-items: center; justify-content: center; }
.auth-card { width: min(430px, 100%); }
.auth-card h2 { margin-bottom: 6px; }
.demo-box { margin-top: 22px; border: 1px dashed var(--line-strong); border-radius: 12px; padding: 14px 16px; background: #fcfbf7; font-size: .82rem; }
.demo-box table { width: 100%; border-collapse: collapse; }
.demo-box td { padding: 3px 0; font-size: .8rem; color: var(--muted); }
.demo-box td:first-child { font-weight: 600; color: var(--navy); }
.demo-box button { font-size: .76rem; }

/* ---------------------------------------------------------------- Print-ish */
.confidential-strip {
    display: flex; align-items: center; gap: 8px; font-size: .74rem; letter-spacing: .1em;
    text-transform: uppercase; color: var(--muted); font-weight: 700;
}

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1100px) {
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero__inner { grid-template-columns: 1fr; }
    .contact-grid { grid-template-columns: 1fr; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

@media (max-width: 980px) {
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%);
        transition: transform .2s ease; box-shadow: var(--shadow-lg); width: 280px;
    }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar__close { display: inline-flex; }
    .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(28,28,28,.42); z-index: 25; }
    .sidebar-scrim[hidden] { display: none; }
    .topbar__menu { display: inline-flex; }
    .search { flex: 1 1 auto; }
    .topbar__privacy span { display: none; }
    .content { padding: 20px 16px; }
    .grid--2, .grid--3 { grid-template-columns: 1fr; }
    .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
    .pubnav {
        position: absolute; top: 100%; left: 0; right: 0; background: var(--warm);
        border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch;
        gap: 4px; padding: 12px 16px 18px; display: none;
    }
    .pubnav.is-open { display: flex; }
    .pubnav a { padding: 10px 6px; }
    .pubhead__toggle { display: inline-flex; }
    .pubhead__inner { position: relative; }
    .table th { position: static; }
}

@media (max-width: 640px) {
    body { font-size: 15px; }
    .grid--4 { grid-template-columns: 1fr; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1 1 auto; }
    .card--pad, .card__body { padding: 16px; }
    .card__head { padding: 14px 16px; }
    .table th, .table td { padding: 10px 12px; }
    .kv { grid-template-columns: 1fr; gap: 12px; }
    .wizard-steps li { flex: 1 1 100%; }
    .auth-main { padding: 24px 16px; }
    .hero__actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

@media print {
    .sidebar, .topbar, .appfoot, .page-actions, .tabs, .btn { display: none !important; }
    body, .main { background: #fff; }
    .card { box-shadow: none; border-color: #ccc; }
}

/* ---------------------------------------------------------------- Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal__dow {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
    color: var(--muted); padding: 4px 6px;
}
.cal__cell {
    min-height: 96px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 7px;
    background: #fff; display: flex; flex-direction: column; gap: 4px;
}
.cal__cell--empty { background: transparent; border-color: transparent; }
.cal__cell.has-items { background: #fcfbf7; border-color: var(--line-strong); }
.cal__cell.is-today { border-color: var(--teal); box-shadow: inset 0 0 0 1px rgba(45, 45, 45, .28); background: var(--teal-soft); }
.cal__num { font-size: .78rem; font-weight: 700; color: var(--navy); }
.cal__item {
    font-size: .72rem; line-height: 1.3; background: var(--sage-soft); color: #4A4A42;
    border-radius: 6px; padding: 2px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    border-left: 3px solid var(--teal);
}
.cal__more { font-size: .7rem; color: var(--muted); font-weight: 600; }
.contact-card { background: #fcfbf7; }
.contact-card legend { font-size: .82rem; }
@media (max-width: 760px) {
    .cal { gap: 4px; }
    .cal__cell { min-height: 66px; padding: 4px; }
    .cal__item { font-size: .64rem; }
    .cal__dow { font-size: .62rem; padding: 2px; }
}

/* ==========================================================================
   Brand logo sizing
   --------------------------------------------------------------------------
   Uploaded logo files can be any size (a 2400 px PNG is normal). These rules
   cap every placement so a large file can never overflow or cover the page.
   `max-width` + `max-height` with `width/height: auto` keeps the aspect ratio
   intact — no stretching — and `flex: none` stops flex containers growing it.
   ========================================================================== */

.brand-logo,
.pubbrand__logo,
.brand-mark-img,
.brand-preview img {
    display: block;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: left center;
}

/* Sidebar (after sign-in) */
.sidebar__brand .brand-logo {
    flex: none;
    width: auto;
    height: auto;
    max-width: 156px;
    max-height: 72px;
}
/* SVGs may declare only a viewBox, which leaves an <img> with no intrinsic size.
   For those (and only those) pin an explicit height so it can never collapse. */
.sidebar__brand .brand-logo[src*=".svg"] { height: 64px; }
.pubhead .pubbrand__logo[src*=".svg"] { height: 52px; }

/* Public website header */
.pubhead .pubbrand__logo {
    flex: none;
    width: auto;
    height: auto;
    max-width: 200px;
    max-height: 60px;
}

/* Sign-in page: the small square mark on its white plate */
.auth-aside .brand-mark-img {
    flex: none;
    width: 40px;
    height: 40px;
    max-width: 40px;
    max-height: 40px;
    object-fit: contain;
}

/* Preview boxes (Settings card and Branding page) */
.brand-preview {
    display: grid;
    place-items: center;
    min-height: 120px;
    padding: 18px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: #FBFAF4;
    overflow: hidden;
}
.brand-preview img {
    max-width: 100%;
    max-height: 96px;
}

/* A JPG/PNG logo usually carries a white background. Multiplying it into the
   light panels removes that box without needing a transparent PNG. */
.brand-logo.is-raster,
.pubbrand__logo.is-raster,
.auth-aside .brand-mark-img.is-raster,
.brand-preview.is-raster { mix-blend-mode: multiply; }

/* Never let the logo push the header out of shape on small screens. */
@media (max-width: 640px) {
    .sidebar__brand .brand-logo { max-width: 128px; max-height: 56px; }
    .sidebar__brand .brand-logo[src*=".svg"] { height: 52px; }
    .pubhead .pubbrand__logo { max-width: 150px; max-height: 46px; }
    .pubhead .pubbrand__logo[src*=".svg"] { height: 42px; }
}
