/* ==========================================================================
   Dental clinic management - visual system
   White and warm neutral surfaces, dental teal and blue accents, generous
   spacing and WCAG-AA contrast. Layered on top of Bootstrap 5.
   ========================================================================== */

:root {
    /* Surfaces: warm neutrals rather than a cold grey */
    --surface: #ffffff;
    --surface-sunken: #f7f6f3;
    --surface-raised: #ffffff;
    --surface-accent: #f2f8f8;
    --line: #e6e2db;
    --line-strong: #d5cfc5;

    /* Ink */
    --ink: #1c2529;
    --ink-muted: #5c6a72;
    --ink-subtle: #7d8a91;
    --ink-inverse: #ffffff;

    /* Brand */
    --teal-900: #0a4f56;
    --teal-700: #0e7c86;
    --teal-600: #12909b;
    --teal-100: #d7eef0;
    --teal-050: #eef8f9;
    --blue-700: #1d6fa5;
    --blue-100: #dbeaf5;

    /* Status */
    --ok-700: #1f7a4d;
    --ok-100: #dcf1e6;
    --warn-700: #9a6206;
    --warn-100: #fdf0d5;
    --danger-700: #a62c2c;
    --danger-100: #fbe3e3;
    --info-700: #2b5f8f;
    --info-100: #dfebf6;
    --neutral-700: #5c6a72;
    --neutral-100: #ecebe7;
    --violet-700: #5b3fa8;
    --violet-100: #e8e2f7;

    --radius: 10px;
    --radius-sm: 7px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(28, 37, 41, .06), 0 1px 3px rgba(28, 37, 41, .04);
    --shadow-md: 0 2px 6px rgba(28, 37, 41, .07), 0 8px 24px rgba(28, 37, 41, .06);
    --shadow-lg: 0 12px 40px rgba(28, 37, 41, .14);

    --sidebar-width: 254px;
    --topbar-height: 60px;

    --font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-numeric: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}

/* ---------- base ---------- */

html { font-size: 15px; }

body {
    font-family: var(--font-sans);
    background: var(--surface-sunken);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
    margin: 0;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -.011em; color: var(--ink); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.28rem; }
h3 { font-size: 1.08rem; }
h4 { font-size: .98rem; }

a { color: var(--teal-700); text-decoration: none; }
a:hover { color: var(--teal-900); text-decoration: underline; }

:focus-visible {
    outline: 3px solid var(--teal-600);
    outline-offset: 2px;
    border-radius: 4px;
}

.numeric { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 2000;
    background: var(--teal-900);
    color: #fff;
    padding: .6rem 1rem;
    border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* ---------- app shell ---------- */

.app { min-height: 100vh; }

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: #0c3f46;
    background-image: linear-gradient(178deg, #0d4a52 0%, #0a353b 100%);
    color: #d9e9ea;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1rem 1.15rem;
    color: #fff;
    font-weight: 650;
    font-size: 1.02rem;
    letter-spacing: -.01em;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.app-brand:hover { color: #fff; text-decoration: none; }
.app-brand .brand-mark {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, .12);
    border-radius: 9px;
    flex: none;
}
.app-brand small { display: block; font-size: .72rem; font-weight: 400; color: #9dc3c6; letter-spacing: .02em; }

.nav-section {
    padding: 1rem 1.15rem .35rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #74a4a9;
    font-weight: 600;
}

.app-nav { padding: .35rem .6rem 1.5rem; }

.app-nav a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem .62rem;
    border-radius: var(--radius-sm);
    color: #cfe4e6;
    font-size: .9rem;
    font-weight: 500;
    margin-bottom: 1px;
}
.app-nav a:hover { background: rgba(255, 255, 255, .09); color: #fff; text-decoration: none; }
.app-nav a.active { background: var(--teal-600); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.app-nav a .icon { flex: none; opacity: .92; }
.app-nav .badge-count {
    margin-left: auto;
    background: rgba(255, 255, 255, .16);
    border-radius: 999px;
    padding: .05rem .45rem;
    font-size: .72rem;
    font-weight: 600;
}

.app-main { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }

.app-topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.35rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-content { padding: 1.35rem 1.35rem 3rem; flex: 1; }
.app-content > .container-fluid { padding: 0; }

/* ---------- global search ---------- */

.global-search { position: relative; flex: 1; max-width: 460px; }
.global-search .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--ink-subtle); }
.global-search input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface-sunken);
    border-radius: 999px;
    padding: .42rem .9rem .42rem 2.2rem;
    font-size: .9rem;
}
.global-search input:focus { background: #fff; border-color: var(--teal-600); outline: none; box-shadow: 0 0 0 3px var(--teal-100); }

.search-results {
    position: absolute;
    top: calc(100% + .4rem);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 380px;
    overflow-y: auto;
    z-index: 1050;
}
.search-results a { display: block; padding: .55rem .8rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a:focus { background: var(--teal-050); text-decoration: none; }
.search-results .muted { color: var(--ink-muted); font-size: .8rem; }
.search-results .empty { padding: .8rem; color: var(--ink-muted); font-size: .88rem; }

/* ---------- icons ---------- */

.icon { width: 1.15em; height: 1.15em; vertical-align: -.18em; flex: none; }
.icon-lg { width: 1.5em; height: 1.5em; }
.icon-xl { width: 2.1em; height: 2.1em; }

/* ---------- page header ---------- */

.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; margin-bottom: 1.2rem; }
.page-head .titles { flex: 1; min-width: 220px; }
.page-head h1 { margin: 0 0 .15rem; }
.page-head .lede { color: var(--ink-muted); font-size: .93rem; margin: 0; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.breadcrumb-trail { font-size: .82rem; color: var(--ink-subtle); margin-bottom: .35rem; }
.breadcrumb-trail a { color: var(--ink-muted); }
.breadcrumb-trail span { margin: 0 .35rem; }

/* ---------- cards ---------- */

.card {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: .8rem 1.05rem;
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.card-header .header-actions { margin-left: auto; display: flex; gap: .4rem; align-items: center; font-weight: 400; }
.card-body { padding: 1.05rem; }
.card-footer { background: var(--surface-sunken); border-top: 1px solid var(--line); padding: .7rem 1.05rem; }

.section-title {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--ink-subtle);
    font-weight: 650;
    margin: 0 0 .5rem;
}

/* ---------- stat tiles ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: .85rem; }

.stat {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: .1rem;
    position: relative;
    overflow: hidden;
}
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--teal-600); }
.stat.stat-warn::before { background: var(--warn-700); }
.stat.stat-danger::before { background: var(--danger-700); }
.stat.stat-ok::before { background: var(--ok-700); }
.stat.stat-info::before { background: var(--blue-700); }
.stat .stat-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-subtle); font-weight: 600; }
.stat .stat-value { font-size: 1.65rem; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .stat-hint { font-size: .8rem; color: var(--ink-muted); }
a.stat:hover { text-decoration: none; border-color: var(--teal-600); box-shadow: var(--shadow-md); }
a.stat:hover .stat-value { color: var(--teal-900); }

/* ---------- tables ---------- */

.table-card { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-scroll { overflow-x: auto; }

table.data { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
table.data thead th {
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--line);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-muted);
    font-weight: 650;
    padding: .6rem .8rem;
    white-space: nowrap;
    text-align: left;
}
table.data tbody td { padding: .62rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--teal-050); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data .primary-cell { font-weight: 600; }
table.data .sub { display: block; color: var(--ink-muted); font-size: .8rem; }

/* ---------- badges ---------- */

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .17rem .55rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    line-height: 1.35;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-neutral { background: var(--neutral-100); color: var(--neutral-700); border-color: #ddd9d1; }
.badge-info { background: var(--info-100); color: var(--info-700); border-color: #c6dcee; }
.badge-teal { background: var(--teal-100); color: var(--teal-900); border-color: #b8dee1; }
.badge-ok { background: var(--ok-100); color: var(--ok-700); border-color: #bce3ce; }
.badge-warn { background: var(--warn-100); color: var(--warn-700); border-color: #f0dcae; }
.badge-danger { background: var(--danger-100); color: var(--danger-700); border-color: #f0c5c5; }
.badge-violet { background: var(--violet-100); color: var(--violet-700); border-color: #d4c9f0; }

.chip {
    display: inline-flex; align-items: center; gap: .3rem;
    background: var(--surface-sunken); border: 1px solid var(--line);
    border-radius: 999px; padding: .12rem .55rem; font-size: .78rem; color: var(--ink-muted);
}

/* ---------- alerts / banners ---------- */

.patient-alerts { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.patient-alert {
    display: flex; align-items: flex-start; gap: .55rem;
    border-radius: var(--radius-sm); padding: .55rem .8rem; font-size: .88rem;
    border: 1px solid;
}
.patient-alert.sev-critical { background: var(--danger-100); border-color: #f0c5c5; color: #7d2020; }
.patient-alert.sev-warning { background: var(--warn-100); border-color: #f0dcae; color: #74490a; }
.patient-alert.sev-information { background: var(--info-100); border-color: #c6dcee; color: #204b71; }
.patient-alert form { margin-left: auto; }

/* ---------- buttons ---------- */

.btn { border-radius: var(--radius-sm); font-weight: 550; font-size: .9rem; padding: .42rem .85rem; display: inline-flex; align-items: center; gap: .4rem; }
.btn-primary { background: var(--teal-700); border-color: var(--teal-700); }
.btn-primary:hover, .btn-primary:focus { background: var(--teal-900); border-color: var(--teal-900); }
.btn-outline-primary { color: var(--teal-700); border-color: #b9d9dc; background: #fff; }
.btn-outline-primary:hover { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.btn-outline-secondary { color: var(--ink-muted); border-color: var(--line-strong); background: #fff; }
.btn-outline-secondary:hover { background: var(--surface-sunken); color: var(--ink); border-color: var(--line-strong); }
.btn-danger { background: var(--danger-700); border-color: var(--danger-700); }
.btn-outline-danger { color: var(--danger-700); border-color: #eec3c3; background: #fff; }
.btn-outline-danger:hover { background: var(--danger-700); border-color: var(--danger-700); color: #fff; }
.btn-sm { font-size: .82rem; padding: .26rem .6rem; }
.btn-link { color: var(--teal-700); padding: 0; }

/* ---------- forms ---------- */

.form-label { font-size: .82rem; font-weight: 600; color: var(--ink-muted); margin-bottom: .22rem; }
.form-control, .form-select {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: .92rem;
    padding: .42rem .65rem;
    color: var(--ink);
    background-color: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--teal-600);
    box-shadow: 0 0 0 3px var(--teal-100);
}
.form-control.input-validation-error, .form-select.input-validation-error {
    border-color: var(--danger-700);
    background-color: #fffafa;
}
.field-validation-error { color: var(--danger-700); font-size: .82rem; display: block; margin-top: .2rem; }
.validation-summary-errors { background: var(--danger-100); border: 1px solid #f0c5c5; color: #7d2020; border-radius: var(--radius-sm); padding: .7rem .9rem; margin-bottom: 1rem; }
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }
.form-hint { font-size: .8rem; color: var(--ink-subtle); margin-top: .2rem; }
.form-section { border-top: 1px solid var(--line); padding-top: 1.1rem; margin-top: 1.1rem; }
.form-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }

.filter-bar {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.filter-bar .row { align-items: end; }

/* ---------- empty and loading states ---------- */

.empty-state { text-align: center; padding: 2.6rem 1.5rem; color: var(--ink-muted); }
.empty-state .icon { color: var(--line-strong); width: 42px; height: 42px; margin-bottom: .6rem; }
.empty-state h3 { font-size: 1rem; color: var(--ink); margin-bottom: .3rem; }
.empty-state p { font-size: .9rem; max-width: 44ch; margin: 0 auto .9rem; }

.is-busy { position: relative; pointer-events: none; opacity: .6; }
.is-busy::after {
    content: "";
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 24 24' fill='none' stroke='%230e7c86' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M12 3a9 9 0 1 0 9 9'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='.8s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E") center no-repeat;
}

.spinner-inline {
    display: inline-block; width: 1em; height: 1em;
    border: 2px solid var(--teal-100); border-top-color: var(--teal-700);
    border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -.15em;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toasts ---------- */

.toast-stack { position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 1080; display: flex; flex-direction: column; gap: .5rem; max-width: 380px; }
.toast-note {
    background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--teal-700);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: .7rem .85rem;
    display: flex; gap: .55rem; align-items: flex-start; font-size: .9rem;
}
.toast-note.is-success { border-left-color: var(--ok-700); }
.toast-note.is-error { border-left-color: var(--danger-700); }
.toast-note.is-warning { border-left-color: var(--warn-700); }
.toast-note .close { margin-left: auto; background: none; border: 0; color: var(--ink-subtle); line-height: 1; padding: 0 .1rem; }

/* ---------- pagination ---------- */

.pager { display: flex; align-items: center; gap: .8rem; justify-content: space-between; flex-wrap: wrap; padding: .7rem 1.05rem; border-top: 1px solid var(--line); background: var(--surface-sunken); }
.pager .count { font-size: .85rem; color: var(--ink-muted); }
.pager .pages { display: flex; gap: .25rem; }
.pager .pages a, .pager .pages span {
    min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
    font-size: .85rem; color: var(--ink-muted); padding: 0 .45rem;
}
.pager .pages a:hover { border-color: var(--teal-600); color: var(--teal-900); text-decoration: none; }
.pager .pages .current { background: var(--teal-700); border-color: var(--teal-700); color: #fff; font-weight: 600; }
.pager .pages .disabled { opacity: .45; }

/* ---------- tabs ---------- */

.profile-tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--line); overflow-x: auto; margin-bottom: 1.1rem; }
.profile-tabs a {
    padding: .55rem .85rem; font-size: .88rem; font-weight: 550; color: var(--ink-muted);
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.profile-tabs a:hover { color: var(--teal-900); text-decoration: none; background: var(--teal-050); }
.profile-tabs a.active { color: var(--teal-900); border-bottom-color: var(--teal-700); }

/* ---------- patient header ---------- */

.patient-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.patient-avatar {
    width: 54px; height: 54px; border-radius: 12px; flex: none;
    background: var(--teal-100); color: var(--teal-900);
    display: grid; place-items: center; font-weight: 650; font-size: 1.15rem;
}
.patient-facts { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .86rem; color: var(--ink-muted); margin-top: .3rem; }
.patient-facts .fact { display: inline-flex; align-items: center; gap: .3rem; }

.definition-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .85rem 1.4rem; }
.definition-grid dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-subtle); font-weight: 650; margin-bottom: .1rem; }
.definition-grid dd { margin: 0; font-size: .92rem; }
.definition-grid dd.empty { color: var(--ink-subtle); font-style: italic; }

/* ---------- calendar ---------- */

.calendar-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.calendar-toolbar .spacer { flex: 1; }

.day-columns { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.day-column { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; min-height: 160px; }
.day-column .day-head { padding: .55rem .75rem; border-bottom: 1px solid var(--line); background: var(--surface-sunken); border-radius: var(--radius) var(--radius) 0 0; }
.day-column .day-head .dow { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-subtle); font-weight: 650; }
.day-column .day-head .dom { font-size: 1.05rem; font-weight: 650; }
.day-column.is-today .day-head { background: var(--teal-050); }
.day-column.is-today .day-head .dom { color: var(--teal-900); }
.day-column .day-body { padding: .5rem; display: flex; flex-direction: column; gap: .4rem; }

.appt {
    display: block;
    border: 1px solid var(--line);
    border-left: 4px solid var(--teal-700);
    border-radius: var(--radius-sm);
    padding: .45rem .6rem;
    background: #fff;
    color: var(--ink);
    font-size: .85rem;
    box-shadow: var(--shadow-sm);
}
.appt:hover { text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.appt .appt-time { font-weight: 650; font-variant-numeric: tabular-nums; }
.appt .appt-patient { font-weight: 600; display: block; }
.appt .appt-meta { color: var(--ink-muted); font-size: .78rem; display: block; }
.appt.status-cancelled, .appt.status-noshow { opacity: .58; }
.appt.status-cancelled .appt-patient { text-decoration: line-through; }
.appt.status-completed { background: var(--ok-100); }
.appt.status-intreatment { background: var(--teal-050); box-shadow: 0 0 0 2px var(--teal-100); }
.appt.status-checkedin { background: var(--warn-100); }

.agenda-row { display: grid; grid-template-columns: 92px 1fr; gap: .8rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.agenda-row:last-child { border-bottom: 0; }
.agenda-row .agenda-time { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--ink-muted); }

/* ---------- odontogram ---------- */

.odontogram { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow-sm); }
.arch { display: flex; justify-content: center; gap: 1.6rem; flex-wrap: wrap; }
.quadrant { display: flex; gap: .3rem; }
.arch + .arch { margin-top: 1.6rem; padding-top: 1.4rem; border-top: 1px dashed var(--line-strong); }

.tooth { width: 46px; text-align: center; }
.tooth .tooth-number { font-size: .72rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; margin-bottom: .15rem; font-weight: 600; }
.tooth svg { display: block; margin: 0 auto; cursor: pointer; }
.tooth .surface { fill: #fff; stroke: var(--line-strong); stroke-width: 1; transition: fill .12s ease; }
.tooth .surface:hover { stroke: var(--teal-700); stroke-width: 2; }
.tooth.is-missing svg { opacity: .45; }
.tooth .tooth-flag { font-size: .66rem; font-weight: 700; letter-spacing: .02em; margin-top: .15rem; display: block; min-height: 1em; }
.tooth.is-selected { outline: 2px solid var(--teal-600); outline-offset: 2px; border-radius: 6px; }

.legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--ink-muted); }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line-strong); display: inline-block; }
.legend-abbr { font-weight: 700; font-size: .68rem; }

/* ---------- print ---------- */

.print-sheet { background: #fff; max-width: 820px; margin: 0 auto; padding: 2.2rem 2.4rem; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.print-sheet h1 { font-size: 1.35rem; }
.print-head { display: flex; justify-content: space-between; gap: 2rem; border-bottom: 2px solid var(--teal-700); padding-bottom: 1rem; margin-bottom: 1.4rem; }
.print-totals { margin-left: auto; width: min(320px, 100%); }
.print-totals dl { display: grid; grid-template-columns: 1fr auto; gap: .3rem .9rem; margin: 0; }
.print-totals dt { color: var(--ink-muted); font-size: .88rem; }
.print-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.print-totals .grand { font-size: 1.12rem; font-weight: 700; border-top: 1px solid var(--line-strong); padding-top: .35rem; }
.print-totals .grand + dd { border-top: 1px solid var(--line-strong); padding-top: .35rem; }

@media print {
    .app-sidebar, .app-topbar, .no-print, .toast-stack { display: none !important; }
    .app-main { margin-left: 0; }
    .app-content { padding: 0; }
    body { background: #fff; }
    .print-sheet { border: 0; box-shadow: none; max-width: none; padding: 0; }
    table.data thead th { background: #f2f2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a { color: #000; text-decoration: none; }
}

/* ---------- responsive ---------- */

.sidebar-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .3rem .45rem; color: var(--ink-muted); }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow-lg); }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(12, 34, 38, .45); z-index: 1035; }
}

@media (max-width: 575.98px) {
    .app-content { padding: 1rem .8rem 2.5rem; }
    .page-head { flex-direction: column; }
    .stat .stat-value { font-size: 1.4rem; }
    .global-search { max-width: none; }
}
