/*
 * Page components. Pages are sheets of white on the paper background, divided by thin lines and space rather than
 * boxed into cards; the accent is for actions and the current place only.
 */

/* ============================================
   PAGE HEAD
   ============================================ */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1rem;
    margin-bottom: 1.25rem;
}

.page-head h1 {
    margin: 0;
}

.page-head .page-sub {
    flex-basis: 100%;
    margin: -.4rem 0 0;
    color: var(--muted);
}

.page-head .page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-left: auto;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    margin-bottom: .6rem;
    color: var(--muted);
    font-size: var(--fs-meta);
    font-weight: 600;
}

.back-link:hover {
    color: var(--ink);
    text-decoration: none;
}

/* ============================================
   SHEET AND SECTIONS
   ============================================ */
.sheet {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background-color: var(--surface);
}

.sheet + .sheet {
    margin-top: 1rem;
}

.sheet-section {
    padding: 1.25rem 1.5rem;
}

.sheet-section + .sheet-section {
    border-top: 1px solid var(--line);
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
    margin-bottom: .9rem;
}

.section-head h2 {
    margin: 0;
}

.section-head .section-actions {
    display: flex;
    gap: .5rem;
    margin-left: auto;
}

.section-note {
    color: var(--muted);
    font-size: var(--fs-meta);
}

@media (max-width: 767.98px) {
    .sheet-section {
        padding: 1rem;
    }
}

/* ============================================
   FACTS: label over value, in columns that wrap
   ============================================ */
.facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: .9rem 1.5rem;
    margin: 0;
}

.facts > div {
    min-width: 0;
}

.facts dt {
    margin-bottom: .1rem;
    color: var(--muted);
    font-size: var(--fs-meta);
    font-weight: 500;
}

.facts dd {
    margin: 0;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.facts dd.empty {
    color: #9AA5AA;
}

.facts .wide {
    grid-column: 1 / -1;
}

/* ============================================
   FORM GRID
   ============================================ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem 1rem;
}

.form-grid > .col-2x { grid-column: span 2; }
.form-grid > .col-3x { grid-column: span 3; }
.form-grid > .col-4x { grid-column: span 4; }
.form-grid > .col-6x { grid-column: span 6; }
.form-grid > .col-8x { grid-column: span 8; }
.form-grid > .col-12x { grid-column: 1 / -1; }

@media (max-width: 991.98px) {
    .form-grid > .col-2x,
    .form-grid > .col-3x { grid-column: span 6; }
    .form-grid > .col-4x { grid-column: span 6; }
    .form-grid > .col-8x { grid-column: 1 / -1; }
}

@media (max-width: 575.98px) {
    .form-grid > .col-4x,
    .form-grid > .col-6x { grid-column: 1 / -1; }
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.form-actions .spacer {
    flex: 1 1 auto;
}

/* The save bar of a long form stays in reach while the page scrolls. */
.save-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 0 -1.5rem -1.25rem;
    padding: .75rem 1.5rem;
    border-top: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius);
    background-color: rgba(255, 255, 255, .94);
    backdrop-filter: blur(6px);
}

.save-bar .save-state {
    color: var(--muted);
    font-size: var(--fs-meta);
}

.save-bar .save-state.is-dirty {
    color: var(--warn);
    font-weight: 600;
}

@media (max-width: 991.98px) {
    .save-bar {
        bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    }
}

@media (max-width: 767.98px) {
    .save-bar {
        margin: 0 -1rem -1rem;
        padding: .6rem 1rem;
    }
}

/* ============================================
   CHOICE PILLS (the yes/no marks of the history: tap to toggle)
   ============================================ */
.pills {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}

.pill {
    position: relative;
    margin: 0;
}

.pill input {
    position: absolute;
    opacity: 0;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.pill span {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 38px;
    padding: .3rem .85rem;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background-color: var(--surface);
    color: var(--text);
    font-weight: 500;
    user-select: none;
}

.pill input:checked + span {
    border-color: var(--app-primary);
    background-color: var(--app-primary-subtle);
    color: var(--app-primary-dark);
    font-weight: 650;
}

.pill input:checked + span::before {
    content: "\2713";
    font-size: .85em;
}

.pill input:focus-visible + span {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
}

.pill input:disabled + span {
    opacity: .7;
}

/* Read-only: only what is marked is shown. */
.marks {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.mark {
    padding: .2rem .7rem;
    border-radius: 999px;
    background-color: var(--app-primary-subtle);
    color: var(--app-primary-dark);
    font-size: var(--fs-meta);
    font-weight: 650;
}

/* ============================================
   RICH TEXT (notes): three tools, the ones the clinic's notes really use
   ============================================ */
.rt {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background-color: var(--input-bg);
}

.rt:focus-within {
    border-color: var(--app-primary);
    background-color: #fff;
    box-shadow: 0 0 0 .2rem rgba(var(--app-primary-rgb), .16);
}

.rt-tools {
    display: flex;
    flex-wrap: wrap;
    gap: .2rem;
    padding: .3rem;
    border-bottom: 1px solid var(--line);
}

.rt-tools button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 34px;
    padding: 0 .55rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: var(--fs-meta);
    font-weight: 600;
}

.rt-tools button:hover {
    background-color: var(--hover);
}

.rt-tools button.is-on {
    background-color: var(--app-primary-subtle);
    color: var(--app-primary-dark);
}

.rt-tools .rt-red {
    color: var(--mark-red);
}

.rt-tools .rt-yellow span {
    padding: 0 .3rem;
    border-radius: 3px;
    background-color: var(--mark-yellow);
    color: var(--ink);
}

.rt-body {
    min-height: 7rem;
    padding: .6rem .75rem;
    outline: 0;
    color: var(--ink);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.rt-body.rt-tall {
    min-height: 12rem;
}

.rt-body:empty::before {
    content: attr(data-placeholder);
    color: #8B979D;
}

/* Stored rich text, shown. */
.rich p,
.rt-body p {
    margin: 0 0 .15rem;
}

.rich {
    color: var(--ink);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.rich p:empty::before,
.rich p > br:only-child {
    content: "";
}

.plain {
    margin: 0;
    color: var(--ink);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ============================================
   PATIENT LIST
   ============================================ */
.list-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    margin-bottom: .75rem;
}

.list-tools .big-search {
    position: relative;
    flex: 1 1 320px;
}

.list-tools .big-search i.bx {
    position: absolute;
    top: 50%;
    left: .9rem;
    transform: translateY(-50%);
    font-size: 1.35rem;
    color: var(--muted);
}

.list-tools .big-search input {
    height: 48px;
    padding-left: 2.8rem;
    font-size: 1.0625rem;
    background-color: var(--surface);
}

.list-count {
    color: var(--muted);
    font-size: var(--fs-meta);
}

.patient-rows {
    display: flex;
    flex-direction: column;
}

.patient-row {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 2.2fr) minmax(0, 1.3fr) minmax(0, 1.6fr) 7.5rem;
    align-items: center;
    gap: 1rem;
    padding: .7rem 1.25rem;
    border-top: 1px solid var(--line);
    color: var(--text);
    text-decoration: none !important;
}

.patient-row:first-child {
    border-top: 0;
}

.patient-row:hover,
.patient-row:focus-visible {
    background-color: var(--hover);
}

.patient-row .file-no {
    color: var(--muted);
    font-weight: 600;
}

.patient-row .who {
    min-width: 0;
}

.patient-row .who strong {
    display: block;
    overflow: hidden;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.patient-row .who span,
.patient-row .cell-meta {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: var(--fs-meta);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.patient-row .when {
    color: var(--muted);
    font-size: var(--fs-meta);
    text-align: right;
    white-space: nowrap;
}

.patient-rows-head {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 2.2fr) minmax(0, 1.3fr) minmax(0, 1.6fr) 7.5rem;
    gap: 1rem;
    padding: .55rem 1.25rem;
    border-bottom: 1px solid var(--line-strong);
    color: var(--muted);
    font-size: var(--fs-meta);
    font-weight: 600;
}

.patient-rows-head span:last-child {
    text-align: right;
}

.inactive-tag {
    margin-left: .4rem;
    padding: .05rem .45rem;
    border-radius: 999px;
    background-color: var(--line);
    color: var(--muted);
    font-size: .75rem;
    font-weight: 600;
    vertical-align: middle;
}

@media (max-width: 767.98px) {
    .patient-rows-head {
        display: none;
    }

    /* Two lines per patient: who, then how to reach them. */
    .patient-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: .1rem .75rem;
        padding: .75rem 1rem;
    }

    .patient-row .file-no {
        grid-column: 2;
        grid-row: 1;
        font-size: var(--fs-meta);
    }

    .patient-row .who {
        grid-column: 1;
        grid-row: 1;
    }

    .patient-row .cell-phone {
        grid-column: 1;
        grid-row: 2;
    }

    .patient-row .cell-diagnosis {
        display: none;
    }

    .patient-row .when {
        grid-column: 2;
        grid-row: 2;
    }
}

.empty-state {
    padding: 2.5rem 1.25rem;
    color: var(--muted);
    text-align: center;
}

.empty-state strong {
    display: block;
    margin-bottom: .25rem;
    color: var(--ink);
    font-size: var(--fs-section);
}

.load-more {
    padding: .9rem;
    border-top: 1px solid var(--line);
    text-align: center;
}

/* ============================================
   PATIENT CARD
   ============================================ */
/* Who this is, always in view: like the tab of a paper file. */
.patient-strip {
    position: sticky;
    top: var(--topbar-height);
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem 1.25rem;
    margin: -1.5rem -1.75rem 1.25rem;
    padding: .8rem 1.75rem;
    border-bottom: 1px solid var(--line);
    background-color: rgba(255, 255, 255, .96);
    backdrop-filter: blur(6px);
}

.patient-strip h1 {
    margin: 0;
    font-size: 1.375rem;
}

.patient-strip .strip-facts {
    display: flex;
    flex-wrap: wrap;
    gap: .15rem 1.1rem;
    color: var(--text);
    font-size: var(--fs-meta);
}

.patient-strip .strip-facts b {
    color: var(--ink);
    font-weight: 650;
}

.patient-strip .strip-facts a {
    color: inherit;
    font-weight: 650;
}

.patient-strip .strip-actions {
    display: flex;
    gap: .4rem;
    margin-left: auto;
}

@media (max-width: 991.98px) {
    .patient-strip {
        margin: -1rem -.9rem 1rem;
        padding: .65rem .9rem;
    }

    .patient-strip h1 {
        flex-basis: 100%;
        font-size: 1.2rem;
    }

    .patient-strip .strip-actions {
        margin-left: 0;
    }
}

/* The sections of the card. Wide: a row of tabs; phones: the same row scrolls sideways. */
.card-tabs {
    display: flex;
    gap: .25rem;
    margin: 0 0 1rem;
    padding: 0;
    overflow-x: auto;
    border-bottom: 1px solid var(--line-strong);
    list-style: none;
    scrollbar-width: none;
}

.card-tabs::-webkit-scrollbar {
    display: none;
}

.card-tabs a {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .6rem .9rem;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none !important;
}

.card-tabs a:hover {
    color: var(--ink);
}

.card-tabs a.active {
    border-bottom-color: var(--app-primary);
    color: var(--app-primary-dark);
}

.card-tabs .count {
    padding: 0 .4rem;
    border-radius: 999px;
    background-color: var(--line);
    color: var(--text);
    font-size: .75rem;
}

/* Wide screens: the standing record on the left, what happened on the right. */
.card-desk {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 1199.98px) {
    .card-desk {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ============================================
   TIMELINE (visits, newest first): it is a sequence, so it gets a spine and dated points
   ============================================ */
.timeline {
    position: relative;
    margin: 0;
    padding: 0 0 0 1.4rem;
    list-style: none;
}

.timeline::before {
    content: "";
    position: absolute;
    top: .5rem;
    bottom: .5rem;
    left: .3rem;
    width: 2px;
    background-color: var(--line);
}

.timeline > li {
    position: relative;
    padding-bottom: 1.4rem;
}

.timeline > li:last-child {
    padding-bottom: 0;
}

.timeline > li::before {
    content: "";
    position: absolute;
    top: .45rem;
    left: -1.4rem;
    width: .75rem;
    height: .75rem;
    border: 2px solid var(--app-primary);
    border-radius: 50%;
    background-color: var(--surface);
}

.timeline > li.is-legacy::before {
    border-color: var(--line-strong);
}

.visit-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .25rem .75rem;
    margin-bottom: .35rem;
}

.visit-date {
    color: var(--ink);
    font-weight: 700;
}

.visit-ago {
    color: var(--muted);
    font-size: var(--fs-meta);
}

.visit-head .visit-actions {
    display: flex;
    gap: .25rem;
    margin-left: auto;
}

.visit-complaint {
    margin: 0 0 .35rem;
    color: var(--ink);
    font-weight: 600;
}

.vitals {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .5rem;
    margin: .5rem 0 0;
}

.vital {
    display: inline-flex;
    align-items: baseline;
    gap: .35rem;
    padding: .2rem .6rem;
    border: 1px solid var(--line);
    border-radius: 7px;
    background-color: var(--paper);
    font-size: var(--fs-meta);
}

.vital span {
    color: var(--muted);
}

.vital b {
    color: var(--ink);
    font-weight: 650;
}

.vital.is-out {
    border-color: #F1D79A;
    background-color: var(--warn-subtle);
}

.vital.is-out b {
    color: var(--warn);
}

.next-visit {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-top: .55rem;
    color: var(--text);
    font-size: var(--fs-meta);
}

.next-visit i.bx {
    color: var(--app-primary);
    font-size: 1.1rem;
}

/* The form of a visit, opened in place at the top of the timeline. */
.visit-form {
    margin-bottom: 1.25rem;
    padding: 1rem;
    border: 1px solid var(--app-primary-light);
    border-radius: var(--radius);
    background-color: #FCFEFD;
}

.lab-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .6rem .75rem;
}

.lab-inputs .form-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .4rem;
}

.lab-inputs .form-label small {
    color: var(--muted);
    font-weight: 500;
}

.quick-dates {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .4rem;
}

/* ============================================
   LAB TABLE
   ============================================ */
.lab-table-wrap {
    overflow-x: auto;
}

.lab-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-body);
}

.lab-table th,
.lab-table td {
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
}

.lab-table th:first-child,
.lab-table td:first-child {
    position: sticky;
    left: 0;
    background-color: var(--surface);
    text-align: left;
}

.lab-table thead th {
    color: var(--muted);
    font-size: var(--fs-meta);
    font-weight: 600;
    border-bottom-color: var(--line-strong);
}

.lab-table td.is-out {
    color: var(--warn);
    font-weight: 700;
}

.lab-table .test-name small {
    display: block;
    color: var(--muted);
    font-weight: 400;
}

/* ============================================
   SMALL THINGS
   ============================================ */
.masked {
    letter-spacing: .04em;
}

.text-muted-2 {
    color: var(--muted);
}

.status-dot {
    display: inline-block;
    width: .55rem;
    height: .55rem;
    margin-right: .35rem;
    border-radius: 50%;
    background-color: var(--line-strong);
}

.status-dot.is-on {
    background-color: var(--ok);
}

.toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: min(420px, calc(100vw - 2rem));
}

@media (max-width: 991.98px) {
    .toast-stack {
        right: .75rem;
        bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + .75rem);
        left: .75rem;
        max-width: none;
    }
}

.app-toast {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .7rem .9rem;
    border-radius: var(--radius-sm);
    background-color: var(--ink);
    color: #fff;
    box-shadow: var(--shadow-raised);
    font-weight: 500;
}

.app-toast.is-error {
    background-color: var(--danger);
}

.app-toast.is-success {
    background-color: var(--ok);
}

.app-toast i.bx {
    margin-top: .1rem;
    font-size: 1.25rem;
}

.secret-box {
    padding: .75rem 1rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background-color: var(--paper);
    color: var(--ink);
    font-size: 1.125rem;
    font-weight: 650;
    letter-spacing: .06em;
    overflow-wrap: anywhere;
    user-select: all;
}

.error-page {
    max-width: 34rem;
    margin: 12vh auto 0;
    text-align: center;
}

.error-page .code {
    color: var(--app-primary);
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
}

/* ============================================
   NOTES: coloured cards (the old program's six colours, softened)
   ============================================ */
.note-new {
    padding: .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background-color: var(--paper);
}

.note-new-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem 1rem;
    margin-top: .5rem;
}

.note-colors {
    display: flex;
    gap: .35rem;
}

.note-color {
    position: relative;
    width: 26px;
    height: 26px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
}

.note-color input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.note-color:has(input:checked) {
    border-color: var(--ink);
}

.note-color:has(input:focus-visible) {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
}

.note-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .75rem;
}

.note-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    min-height: 7rem;
    padding: .8rem .9rem .5rem;
    border-radius: var(--radius-sm);
    color: var(--ink);
}

.note-card footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    color: rgba(20, 35, 43, .65);
    font-size: .8125rem;
}

.note-pin {
    position: absolute;
    top: .5rem;
    right: .5rem;
    color: rgba(20, 35, 43, .55);
}

.note-c0 { background-color: #FFF4B8; }
.note-c1 { background-color: #D3F5DD; }
.note-c2 { background-color: #D2F1F8; }
.note-c3 { background-color: #EBDDF8; }
.note-c4 { background-color: #F9DDF0; }
.note-c5 { background-color: #FBD5D5; }

/* ============================================
   FILES
   ============================================ */
.file-drop {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    padding: 1rem;
    border: 2px dashed var(--line-strong);
    border-radius: var(--radius);
    background-color: var(--paper);
}

.file-drop.is-over {
    border-color: var(--app-primary);
    background-color: var(--app-primary-subtle);
}

.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .75rem;
    margin-top: 1rem;
}

.file-item {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
}

.file-thumb {
    display: grid;
    place-items: center;
    height: 120px;
    background-color: var(--paper);
    color: var(--muted);
    font-size: 2.5rem;
    text-decoration: none !important;
}

.file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-info {
    padding: .5rem .65rem .6rem;
    font-size: var(--fs-meta);
}

.file-info strong {
    display: block;
    overflow: hidden;
    color: var(--ink);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-info span {
    color: var(--muted);
}

.file-actions {
    display: flex;
    gap: .25rem;
    margin-top: .35rem;
}

.narrow-col {
    max-width: 60rem;
}

.narrow-sheet {
    max-width: 40rem;
}

/* ============================================
   REMINDERS AND APPOINTMENTS
   ============================================ */
.reminder-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.reminder-item {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .75rem 1.25rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--line);
}

.reminder-item:first-child {
    border-top: 0;
}

.reminder-main {
    flex: 1 1 22rem;
    min-width: 0;
}

.reminder-who {
    color: var(--ink);
    font-weight: 650;
}

.reminder-when {
    margin-left: .5rem;
    color: var(--muted);
    font-size: var(--fs-meta);
}

.reminder-text {
    margin: .35rem 0 0;
    color: var(--text);
}

.reminder-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
}

.ap-item {
    padding: 1px 2px;
    line-height: 1.25;
}

.ap-item strong {
    display: block;
    overflow: hidden;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ap-meta {
    overflow: hidden;
    font-size: .75rem;
    opacity: .9;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.today-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 991.98px) {
    .today-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.day-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.day-list li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .65rem 0;
    border-top: 1px solid var(--line);
}

.day-list li:first-child {
    border-top: 0;
}

.day-time {
    flex: 0 0 3.4rem;
    color: var(--ink);
    font-weight: 700;
}

.day-who {
    flex: 1 1 auto;
    min-width: 0;
}

.day-who a,
.day-who strong {
    color: var(--ink);
    font-weight: 600;
}

.day-who span {
    display: block;
    color: var(--muted);
    font-size: var(--fs-meta);
}

.status-chip {
    padding: .1rem .55rem;
    border-radius: 999px;
    background-color: var(--line);
    color: var(--text);
    font-size: .8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-chip.s1 { background-color: var(--ok-subtle); color: var(--ok); }
.status-chip.s2 { background-color: var(--warn-subtle); color: var(--warn); }
.status-chip.s3 { text-decoration: line-through; }

.stat-line {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 2rem;
    margin: 0;
}

.stat-line div {
    display: flex;
    align-items: baseline;
    gap: .4rem;
}

.stat-line b {
    color: var(--ink);
    font-size: 1.25rem;
}

.stat-line span {
    color: var(--muted);
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

/* ============================================
   SETTINGS
   ============================================ */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: .75rem;
}

.settings-link {
    display: flex;
    align-items: flex-start;
    gap: .9rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background-color: var(--surface);
    color: var(--text);
    text-decoration: none !important;
}

.settings-link:hover {
    border-color: var(--app-primary-light);
    background-color: var(--hover);
}

.settings-link > i {
    margin-top: .1rem;
    color: var(--app-primary);
    font-size: 1.6rem;
}

.settings-link strong {
    display: block;
    color: var(--ink);
    font-weight: 650;
}

.settings-link span span {
    color: var(--muted);
    font-size: var(--fs-meta);
}

.perm-group th {
    padding-top: 1rem !important;
    background-color: var(--paper) !important;
    color: var(--ink) !important;
    font-size: var(--fs-body) !important;
}

/* ============================================
   PRINT SHEET (A4)
   ============================================ */
.print-sheet {
    max-width: 210mm;
    margin: 0 auto;
    padding: 14mm 14mm 18mm;
    background-color: #fff;
    color: #111;
    font-size: 10.5pt;
    line-height: 1.45;
}

.print-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 4mm;
    border-bottom: 2px solid var(--app-primary);
    margin-bottom: 5mm;
}

.print-head img {
    max-width: 45mm;
    max-height: 18mm;
    object-fit: contain;
}

.print-head .clinic strong {
    display: block;
    font-size: 13pt;
}

.print-head .clinic span {
    display: block;
    color: #444;
    font-size: 9pt;
}

.print-title {
    margin: 0 0 3mm;
    font-size: 14pt;
}

.print-sheet h2 {
    margin: 6mm 0 2mm;
    padding-bottom: 1mm;
    border-bottom: 1px solid #ccc;
    font-size: 11pt;
}

.print-sheet .facts {
    grid-template-columns: repeat(3, 1fr);
    gap: 2mm 6mm;
}

.print-sheet .facts dt {
    font-size: 8.5pt;
}

.print-visit {
    padding: 2mm 0;
    border-bottom: 1px dotted #ccc;
    break-inside: avoid;
}

.print-foot {
    margin-top: 8mm;
    color: #666;
    font-size: 8pt;
}

.print-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    max-width: 210mm;
    margin: 0 auto 1rem;
}

@media print {
    .print-sheet {
        max-width: none;
        padding: 0;
    }

    @page {
        size: A4;
        margin: 14mm;
    }
}

.card-tabs .count:empty {
    display: none;
}
