:root {
    --ink-950: #050e1a;
    --ink-900: #091e38;
    --ink-800: #0f2744;
    --ink-700: #1a3a5c;
    --brand-700: #1a7268;
    --brand-600: #218f82;
    --brand-500: #34b0a2;
    --brand-100: #d8f2ef;
    --paper-50: #faf8f4;
    --paper-100: #f4f1eb;
    --paper-200: #e8e2d7;
    --paper-300: #d4cab8;
    --gold-500: #b6873d;
    --text: #1e2d3d;
    --muted: #546070;
    --danger: #b42318;
    --success: #16a34a;
    --border-subtle: rgba(16, 34, 53, 0.08);
    --status-warning-bg: #fef3c7;  --status-warning-text: #92400e;
    --status-orange-bg: #ffedd5;   --status-orange-text: #c2410c;
    --status-info-bg: #dbeafe;     --status-info-text: #1e40af;
    --status-success-bg: #dcfce7;  --status-success-text: #166534;
    --status-danger-bg: #fee2e2;   --status-danger-text: #991b1b;
    --status-muted-bg: #f3f4f6;    --status-muted-text: #4b5563;
    --status-purple-bg: #ede9fe;   --status-purple-text: #5b21b6;
    --shadow-lg: 0 22px 55px rgba(9, 30, 56, 0.12);
    --shadow-sm: 0 4px 16px rgba(9, 30, 56, 0.07);
}

* { box-sizing: border-box; }

html {
    background: var(--paper-100);
}

body {
    margin: 0;
    color: var(--text);
    font-family: 'Figtree', system-ui, sans-serif;
    background: var(--paper-100);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, .metric-title {
    font-family: 'Figtree', system-ui, sans-serif;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    overflow-x: hidden;
    background: linear-gradient(to right, var(--ink-900) 270px, var(--paper-100) 270px);
}

.sidebar-backdrop {
    display: none;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 16px;
    color: #fff;
    background: var(--ink-900);
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-head {
    display: none;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px 18px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-logo,
.login-logo {
    width: 78px;
    height: 78px;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    background: #fff;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 10px;
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.nav a svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: rgba(255,255,255,0.40);
    transition: color .15s ease;
}

.nav a:hover svg {
    color: rgba(255,255,255,0.75);
}

.nav a:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.nav a.active {
    color: #fff;
    background: rgba(52,176,162,0.18);
}

.nav a.active svg {
    color: var(--brand-500);
}

.nav a:focus-visible,
.nav-portal-link:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: -2px;
    border-radius: 10px;
}

.sidebar-foot {
    margin-top: auto;
    padding: 12px 0 4px;
    border-top: 1px solid rgba(255,255,255,0.07);
}

.nav-portal-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: rgba(255,255,255,0.50);
    font-size: 13px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.nav-portal-link:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.80);
}

.nav-portal-link svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.sidebar-toggle svg,
.sidebar-close svg {
    width: 20px;
    height: 20px;
}

.main {
    min-width: 0;
}

.topbar {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 28px;
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
    border-bottom: 1px solid var(--paper-200);
}

.sidebar-toggle,
.topbar-brand {
    display: none;
}

.page-title-wrap h1 {
    margin: 2px 0 0;
    font-size: 22px;
}

.eyebrow, .mini-label, .section-label, .kpi-label {
    text-transform: uppercase;
    letter-spacing: .12em;
}

.eyebrow {
    margin: 0;
    font-size: 11px;
    font-weight: 800;
    color: var(--brand-600);
}

.content {
    padding: 24px 28px 34px;
}

.userbar {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--ink-800);
    color: #fff;
    font-weight: 800;
}

.logout {
    border: 0;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-weight: 700;
    padding: 8px 10px;
    border-radius: 10px;
}

.logout:hover { background: rgba(180,35,24,0.06); }
.logout:focus-visible { outline: 2px solid var(--danger); outline-offset: 2px; border-radius: 10px; }

.grid {
    display: grid;
    gap: 14px;
}

.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-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.grid-8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.grid-9 { grid-template-columns: repeat(9, minmax(0, 1fr)); }

.section-label {
    margin: 20px 0 8px;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
}

.card,
.table-wrapper,
.form-section,
.report-hero,
.report-summary,
.report-order,
.report-preview,
.login-card,
.login-visual {
    background: #fff;
    border: 1px solid var(--paper-200);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.card { padding: 18px; }

.metric-grid {
    margin-top: 4px;
    margin-bottom: 4px;
}

.metric-card { min-height: 0; text-align: center; }


.info-card { min-height: 126px; }

.backlog {
    display: flex;
    gap: 14px;
    margin-top: 10px;
}

.backlog div {
    display: grid;
    gap: 3px;
    text-align: center;
    min-width: 64px;
}

.backlog strong {
    font-size: 22px;
    color: var(--ink-800);
}

.backlog span,
.muted,
.kpi-sub {
    color: var(--muted);
    font-size: 13px;
}

.kpi-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.kpi-change-up { color: var(--success); }
.kpi-change-down { color: var(--danger); }

.kpi-label {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
}

.kpi-value {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    color: var(--ink-900);
}

/* KPI value colour modifiers — matched to old dashboard palette */
.kpi-amber  { color: #d97706; }
.kpi-sky    { color: #0284c7; }
.kpi-blue   { color: #2563eb; }
.kpi-emerald{ color: #059669; }
.kpi-violet { color: #7c3aed; }
.kpi-teal   { color: var(--brand-600); }
.kpi-orange { color: #ea580c; }

/* Section label above card groups */
.dash-section {
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: .14em;
    text-transform: uppercase;
    margin: 20px 0 8px;
}

/* Container de painel de KPIs */
.kpi-panel-body {
    padding: 20px 20px 24px;
}

.kpi-panel-body .grid {
    gap: 16px;
}

/* Separador visual entre grupos de KPIs */
.metric-grid + .dash-section,
.kpi-panel + .dash-section {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.kpi-panel + .kpi-panel {
    margin-top: 20px;
}

.kpi-sub {
    margin: 8px 0 0;
    font-size: 12px;
}

.toolbar {
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    padding: 14px 18px;
}

.toolbar form {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.order-row-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-inline-form {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-inline-form .input-sm {
    width: 155px;
}

.table-scroll { overflow-x: auto; }

table {
    border-collapse: collapse;
    width: 100%;
}

th {
    background: var(--paper-50);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .10em;
    padding: 10px 16px;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    border-top: 1px solid var(--border-subtle);
    color: var(--text);
    font-size: 14px;
    padding: 11px 16px;
    vertical-align: middle;
}

.description-preview {
    max-width: 360px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

tbody tr:nth-child(even) td { background: rgba(0, 0, 0, 0.025); }
tr:hover td { background: rgba(247, 243, 236, 0.9); }

tr.tr-link { cursor: pointer; }
a.tr-link-anchor { color: inherit; text-decoration: none; }

.right { text-align: right; }
.mono { font-family: ui-monospace, monospace; }

.input,
.input-sm,
textarea,
select {
    background: rgba(255,255,255,0.94);
    border: 1px solid var(--paper-200);
    border-radius: 12px;
    color: var(--text);
    padding: 11px 12px;
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.input-sm {
    min-height: 38px;
    padding: 8px 10px;
    width: auto;
}

.input:focus,
.input-sm:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(52,176,162,0.18);
}

.input:focus-visible,
.input-sm:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 1px;
}

textarea { min-height: 110px; }

.btn-access,
.btn-edit,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost,
.btn-ghost-danger,
.btn-success {
    align-items: center;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    font-size: 14px;
    font-weight: 700;
    gap: 8px;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    white-space: nowrap;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.btn-primary {
    background: linear-gradient(145deg, var(--ink-800), var(--ink-700));
    border: 1px solid var(--ink-800);
    color: #fff;
    box-shadow: 0 14px 30px rgba(16,34,53,0.18);
}

.btn-secondary {
    background: #fff;
    border: 1px solid rgba(16,34,53,0.14);
    color: var(--ink-800);
}

.btn-danger {
    background: var(--danger);
    border: 1px solid var(--danger);
    color: #fff;
}

.btn-success {
    background: linear-gradient(145deg, #14532d, #166534);
    border: 1px solid #14532d;
    color: #fff;
    box-shadow: 0 14px 30px rgba(20,83,45,0.22);
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
}

.btn-access:hover,
.btn-edit:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover,
.btn-ghost:hover,
.btn-success:hover {
    transform: translateY(-1px);
}

.btn-access:focus-visible,
.btn-edit:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible,
.btn-ghost:focus-visible,
.btn-success:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}

.btn-wide { width: 100%; }

.btn-sm {
    min-height: 36px;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 8px;
}

@media (pointer: coarse) {
    .btn-sm { min-height: 44px; padding: 6px 12px; }
}

.btn-ghost-danger {
    background: transparent;
    border: 1px solid rgba(180,35,24,0.3);
    color: var(--danger);
}

.btn-ghost-danger:hover { background: rgba(180,35,24,0.06); border-color: var(--danger); transform: translateY(-1px); }
.btn-ghost-danger:focus-visible { outline: 2px solid var(--danger); outline-offset: 2px; border-radius: 12px; }

.btn-success:hover {
    background: linear-gradient(145deg, #166534, #15803d);
    transform: translateY(-1px);
}

.btn-access {
    background: linear-gradient(145deg, #15803d, #16a34a);
    border: 1px solid #15803d;
    color: #fff;
    box-shadow: 0 4px 14px rgba(21,128,61,0.25);
}
.btn-access:hover {
    background: linear-gradient(145deg, #166534, #15803d);
    transform: translateY(-1px);
}

.btn-edit {
    background: linear-gradient(145deg, #1d4ed8, #2563eb);
    border: 1px solid #1d4ed8;
    color: #fff;
    box-shadow: 0 4px 14px rgba(29,78,216,0.22);
}
.btn-edit:hover {
    background: linear-gradient(145deg, #1e40af, #1d4ed8);
    transform: translateY(-1px);
}

label.btn-access,
label.btn-edit,
label.btn-primary,
label.btn-secondary,
label.btn-ghost,
label.btn-danger,
label.btn-ghost-danger,
label.btn-success { margin: 0; }

/* ── Confirm modal ─────────────────────────────────────────── */
.confirm-modal {
    border: none;
    border-radius: 16px;
    box-shadow: 0 22px 55px rgba(9,30,56,0.18);
    padding: 0;
    width: min(440px, calc(100vw - 32px));
}

.confirm-modal::backdrop {
    background: rgba(9,30,56,0.4);
    backdrop-filter: blur(3px);
}

.confirm-modal-inner {
    padding: 28px;
}

.confirm-modal-inner h3 {
    color: var(--text);
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 8px;
}

.confirm-modal-inner p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
    margin: 0 0 28px;
}

.confirm-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.login-card .btn-wide { margin-top: 8px; }

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 400;
    padding: 4px 10px;
}

.badge-warning { background: var(--status-warning-bg); color: var(--status-warning-text); }
.badge-orange  { background: var(--status-orange-bg);  color: var(--status-orange-text); }
.badge-info    { background: var(--status-info-bg);    color: var(--status-info-text); }
.badge-success { background: var(--status-success-bg); color: var(--status-success-text); }
.badge-danger  { background: var(--status-danger-bg);  color: var(--status-danger-text); }
.badge-muted   { background: var(--status-muted-bg);   color: var(--status-muted-text); }
.badge-purple     { background: var(--status-purple-bg);  color: var(--status-purple-text); }
.badge-dark-green { background: #166534; color: #fff; }

.flash {
    border-radius: 14px;
    font-weight: 700;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.flash.success { background: var(--status-success-bg); color: var(--status-success-text); }
.flash.error   { background: var(--status-danger-bg);  color: var(--status-danger-text); }

.form-section {
    margin-bottom: 16px;
    overflow: hidden;
}

.form-section h2 {
    border-bottom: 1px solid var(--border-subtle);
    font-size: 15px;
    margin: 0;
    padding: 14px 16px;
}

.form-body {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.field label {
    color: var(--ink-800);
    display: block;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
}

.login-card .field + .field {
    margin-top: 16px;
}

.actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.pagination-bar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding: 0 4px;
}

body.auth-page {
    background: var(--ink-900);
    min-height: 100vh;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    align-items: stretch;
}

.login-shell-centered {
    grid-template-columns: 1fr;
    align-items: center;
    justify-items: center;
    padding: 32px 24px;
}

.login-stack {
    width: min(100%, 440px);
    display: grid;
    gap: 24px;
    justify-items: center;
}

.login-visual {
    padding: 48px 44px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--ink-800);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.login-visual::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 50% at 20% 80%, rgba(52,176,162,0.12) 0%, transparent 70%);
    pointer-events: none;
}

.login-visual h1 {
    margin: 20px 0 12px;
    font-size: clamp(32px, 3.5vw, 52px);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.08;
    text-wrap: balance;
}

.login-visual p {
    margin: 0;
    max-width: 44ch;
    color: rgba(255,255,255,0.72);
    font-size: 16px;
    line-height: 1.65;
}

.login-visual-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: block;
}

.login-visual-foot {
    font-size: 12px;
    color: rgba(255,255,255,0.38);
    letter-spacing: 0.01em;
}

.login-form-col {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 48px;
    background: var(--ink-900);
}

.login-form-col .login-card {
    width: min(100%, 400px);
}

.login-card {
    padding: 32px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.28);
    width: 100%;
}

.login-card h2 {
    margin: 0 0 6px;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.login-card-portal {
    border-top: 3px solid var(--brand-500);
}

.login-card p {
    color: var(--muted);
    margin: 0 0 22px;
}

.mini-link {
    color: var(--brand-700);
    font-size: 13px;
    font-weight: 800;
}

.mini-link:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
    border-radius: 3px;
}

.login-logo-large {
    width: 112px;
    height: 112px;
    border-radius: 18px;
}

/* Home / portal selector */
.home-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    position: relative;
}

.home-stack {
    width: min(100%, 680px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.home-subtitle {
    margin: 0;
    font-size: 14px;
    color: rgba(255,255,255,0.42);
    letter-spacing: 0.02em;
}

.home-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    width: 100%;
}

.home-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 20px;
    background: var(--ink-800);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 14px;
    color: rgba(255,255,255,0.88);
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.home-card:hover {
    background: var(--ink-700);
    border-color: var(--brand-500);
    transform: translateY(-3px);
    color: #fff;
}

.home-card-icon {
    width: 44px;
    height: 44px;
    color: var(--brand-500);
    flex-shrink: 0;
}

.home-card-label {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.home-super-link {
    position: fixed;
    bottom: 18px;
    left: 20px;
    font-size: 11px;
    color: rgba(255,255,255,0.16);
    text-decoration: none;
    letter-spacing: 0.03em;
    transition: color 0.2s ease;
}

.home-super-link:hover {
    color: rgba(255,255,255,0.42);
}

@media (max-width: 480px) {
    .home-cards {
        grid-template-columns: 1fr;
        max-width: 280px;
        margin: 0 auto;
    }

    .home-card {
        flex-direction: row;
        padding: 20px 24px;
        gap: 14px;
        justify-content: flex-start;
    }
}

.mini-label {
    font-size: 10px;
    color: rgba(255,255,255,0.58);
}

.report-hero {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 18px;
    padding: 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-lg);
}

.report-hero-copy h2 {
    margin: 6px 0 10px;
    font-size: 34px;
    line-height: 1.02;
}

.report-hero-copy p:last-child {
    margin: 0;
    max-width: 60ch;
    color: var(--muted);
    line-height: 1.6;
}

.report-filters {
    display: grid;
    gap: 12px;
    align-content: start;
}

.report-filters .field { margin: 0; }

.report-summary {
    padding: 20px;
    margin-bottom: 18px;
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, .9fr);
    gap: 18px;
    align-items: center;
}

.report-summary h3,
.report-order h3 {
    margin: 4px 0;
    font-size: 22px;
}

.report-summary-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.metric-value {
    display: block;
    font-size: 22px;
    color: var(--ink-900);
}

.report-actions {
    grid-column: 1 / -1;
    margin-top: 6px;
}

.report-orders {
    display: grid;
    gap: 14px;
}

.report-order {
    padding: 18px;
}

.report-order-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.report-order-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.report-order-total strong {
    font-size: 20px;
    color: var(--ink-900);
}

.report-preview {
    margin-top: 18px;
    padding: 18px;
}

.teeth-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.teeth-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--paper-300) transparent;
    padding-bottom: 4px;
    mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
}

@supports (container-type: inline-size) {
    .teeth-scroll {
        container-type: inline-size;
    }
}

.teeth-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: max-content;
}

.teeth-row {
    display: flex;
    align-items: center;
    gap: 0;
}

.teeth-quadrant {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
}

.teeth-midline {
    width: 1px;
    height: 48px;
    background: var(--paper-200);
    margin: 0 8px;
    flex-shrink: 0;
}

.teeth-jaw-separator {
    height: 1px;
    background: var(--paper-200);
    margin: 4px 0;
}

.tooth-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1.5px solid var(--paper-200);
    background: var(--paper-50);
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    transition: border-color .12s ease, background .12s ease, color .12s ease, transform .1s ease;
    flex-shrink: 0;
    font-family: inherit;
    touch-action: manipulation;
}

@media (pointer: coarse) {
    .tooth-btn {
        width: 44px;
        height: 44px;
        font-size: 11px;
        border-radius: 10px;
    }

    .teeth-quadrant {
        gap: 3px;
    }

    .teeth-midline {
        height: 44px;
        margin: 0 6px;
    }
}

.tooth-btn:hover {
    border-color: var(--brand-500);
    color: var(--brand-600);
    transform: translateY(-1px);
}

@media (hover: none) {
    .tooth-btn:hover {
        transform: none;
    }
}

@media (max-width: 640px) {
    .teeth-row {
        flex-direction: column;
        gap: 3px;
    }
    .teeth-midline {
        display: none;
    }
    .teeth-scroll {
        overflow-x: visible;
        mask-image: none;
        -webkit-mask-image: none;
    }
    .teeth-grid {
        min-width: 0;
    }
    .tooth-btn {
        width: 30px;
        height: 30px;
        font-size: 9px;
        border-radius: 6px;
    }
    .teeth-quadrant {
        gap: 3px;
    }
}

.tooth-btn.selected,
.tooth-btn[aria-pressed="true"] {
    background: var(--brand-500);
    border-color: var(--brand-600);
    color: #fff;
    box-shadow: 0 2px 8px rgba(52,176,162,0.30);
}

.tooth-btn:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}

.teeth-picker--readonly {
    pointer-events: none;
    user-select: none;
    align-items: center;
}
.teeth-picker--readonly .teeth-scroll {
    container-type: normal;
    mask-image: none;
    -webkit-mask-image: none;
}
.teeth-picker--readonly .tooth-btn:hover {
    transform: none;
    border-color: var(--paper-200);
    color: inherit;
}
.teeth-picker--readonly .tooth-btn.selected:hover {
    background: var(--brand-500);
    border-color: var(--brand-600);
    color: #fff;
}

.teeth-summary {
    margin: 0;
    font-size: 13px;
}

.report-frame {
    display: block;
    width: 100%;
    height: 860px;
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    background: #fff;
}

.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    padding: 20px 24px;
    box-shadow: var(--shadow-lg);
}

.dashboard-hero h2 {
    margin: 0;
    font-size: 24px;
}

.hero-period {
    color: var(--brand-600);
}

.dashboard-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.dashboard-period-form {
    display: flex;
    align-items: center;
}

.period-picker {
    align-items: stretch;
    background: #fff;
    border: 1px solid rgba(16,34,53,0.14);
    border-radius: 10px;
    display: flex;
    overflow: hidden;
}

.period-select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    min-height: 36px;
    outline: none;
    padding: 0 10px;
}

.period-select:first-child {
    border-right: 1px solid rgba(16,34,53,0.1);
    min-width: 118px;
}

.period-select:last-child {
    min-width: 68px;
}

.period-select:focus-visible {
    background: rgba(52,176,162,0.06);
    outline: 2px solid var(--brand-500);
    outline-offset: -2px;
}

.period-select:hover {
    background: rgba(16,34,53,0.04);
}

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

.metric-financial-grid {
    margin-top: 0;
}

.metric-financial-grid .card,
.kpi-panel .metric-grid .card {
    border-color: var(--brand-500);
    border-width: 1.5px;
}

.kpi-value-financial {
    font-size: 32px;
    color: var(--ink-900);
}

.kpi-value-highlight {
    color: var(--brand-600);
}

.upcoming-table {
    margin-top: 14px;
}

.supplier-checks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.supplier-check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--paper-200);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    transition: border-color .15s ease, background .15s ease;
}

.supplier-check-item:hover {
    border-color: var(--brand-500);
    background: var(--brand-100);
}

.supplier-check-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--brand-500);
    cursor: pointer;
}

.supplier-check-item:has(input:checked) {
    border-color: var(--brand-500);
    background: var(--brand-100);
}

.supplier-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.supplier-tag {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    background: var(--paper-100);
    border: 1px solid var(--paper-200);
    border-radius: 10px;
    font-size: 14px;
}

.supplier-tag .muted {
    font-size: 12px;
}

.metric-title {
    display: block;
    font-size: 18px;
    color: var(--ink-900);
}

@media (max-width: 1060px) {
    .app-shell,
    .login-shell,
    .report-hero,
    .report-summary {
        grid-template-columns: 1fr;
    }

    .app-shell {
        position: relative;
        max-width: 100vw;
        background: var(--paper-100);
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(320px, 84vw);
        z-index: 60;
        transform: translateX(-102%);
        transition: transform .22s ease;
        box-shadow: 18px 0 50px rgba(9, 19, 31, 0.28);
        max-width: 84vw;
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 50;
        background: rgba(9, 19, 31, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s ease;
    }

    .app-shell.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-head {
        display: flex;
        justify-content: flex-end;
        padding-bottom: 8px;
    }

    .sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: 0;
        border-radius: 999px;
        background: rgba(255,255,255,0.08);
        color: #fff;
        cursor: pointer;
    }

    .sidebar-toggle,
    .topbar-brand {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
    }

    .sidebar-toggle {
        width: 42px;
        height: 42px;
        border: 0;
        border-radius: 12px;
        background: rgba(16,34,53,0.06);
        color: var(--ink-800);
        cursor: pointer;
    }

    .topbar {
        position: relative;
        justify-content: flex-start;
        gap: 10px;
        max-width: 100vw;
    }

    .topbar-brand {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    .topbar-brand .brand-logo {
        width: 48px;
        height: 48px;
    }

    .page-title-wrap {
        display: none;
    }

    .userbar {
        margin-left: auto;
        gap: 8px;
        min-width: 0;
    }

    .login-visual {
        min-height: 260px;
        padding: 32px 32px 28px;
    }

    .login-visual h1 {
        font-size: 36px;
    }

    .login-form-col {
        padding: 32px 24px;
    }
}

@media (max-width: 680px) {
    .login-visual {
        display: none;
    }

    .login-form-col {
        padding: 40px 20px;
        min-height: 100vh;
    }

    .login-form-col .login-card {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 900px) {
    .grid-3,
    .grid-4,
    .grid-5,
    .grid-6,
    .grid-7,
    .grid-8,
    .grid-9,
    .report-summary-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stacked-grid,
    .wide-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .content,
    .topbar {
        padding-left: 14px;
        padding-right: 14px;
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .grid-5,
    .grid-6,
    .grid-7,
    .grid-8,
    .grid-9,
    .report-summary-metrics,
    .dashboard-hero,
    .report-order-head {
        grid-template-columns: 1fr;
        display: grid;
    }

    .login-card,
    .login-visual,
    .report-hero,
    .report-summary,
    .report-order,
    .report-preview,
    .dashboard-hero {
        padding: 18px;
    }

    .login-stack {
        width: min(100%, 100%);
    }

    .userbar span {
        display: none;
    }

    .logout {
        padding: 8px;
    }

    .report-frame {
        height: 620px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Order meta grid (OS detail — OS# / patient / clinic / status / delivery) */
.order-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    gap: 6px 8px;
    margin-top: 4px;
}

/* Order header 2-col */
.order-header-cols {
    display: grid;
    grid-template-columns: 1fr 30%;
    gap: 20px;
    align-items: start;
}

.order-header-suppliers {
    padding-left: 20px;
    border-left: 1px solid var(--border-subtle);
}

@media (max-width: 640px) {
    .order-header-cols {
        grid-template-columns: 1fr;
    }
    .order-header-suppliers {
        padding-left: 0;
        border-left: none;
        border-top: 1px solid var(--border-subtle);
        padding-top: 16px;
    }
    #inline-stl-container,
    #html-model-container {
        aspect-ratio: 4/3;
        max-height: 75vw;
    }
    .order-meta-grid {
        grid-template-columns: 1fr;
    }
    .order-meta-grid > span,
    .order-meta-grid > strong {
        text-align: left !important;
    }
    .order-meta-grid > div {
        justify-content: flex-start !important;
    }
}

/* Attachment columns */
.attachment-cols {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.attachment-col {
    border-right: 1px solid var(--border-subtle);
}

.attachment-col:last-child {
    border-right: none;
}

@media (max-width: 720px) {
    .attachment-cols {
        grid-template-columns: 1fr;
    }
    .attachment-col {
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }
    .attachment-col:last-child {
        border-bottom: none;
    }
}

/* Attachment date groups (collapsible) */
.att-date-groups {
    padding: 4px 0;
}

.att-date-group {
    border-bottom: 1px solid var(--border-subtle);
}

.att-date-group:last-child {
    border-bottom: none;
}

.att-date-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.att-date-summary::-webkit-details-marker { display: none; }

.att-date-summary:hover {
    background: var(--paper-100, rgba(0,0,0,.03));
}

.badge-date {
    background: var(--brand-100, #e8edf5);
    color: var(--brand-700, var(--brand-600));
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.att-date-count {
    flex: 1;
    font-size: 11px;
    color: var(--muted);
}

.att-chevron {
    color: var(--muted);
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

details[open] .att-chevron {
    transform: rotate(180deg);
}

/* ── Dropzone upload modal ── */
@keyframes att-spin { to { transform: rotate(360deg); } }

/* neutraliza estilos padrão do dropzone no drop zone customizado */
#att-drop-zone.dropzone { border: none; background: none; min-height: unset; padding: 0; }
#att-drop-zone.dropzone .dz-message { display: none; }
#att-drop-zone.dz-drag-hover { background: var(--brand-50, #eef2ff); outline: 2px dashed var(--brand-400, #818cf8); outline-offset: -8px; border-radius: 8px; }
#att-previews .dz-preview { margin: 0; }
#att-previews .dz-preview .dz-image { display: none; }
#att-previews .dz-preview .dz-details { display: none; }
#att-previews .dz-preview .dz-error-mark,
#att-previews .dz-preview .dz-success-mark,
#att-previews .dz-preview .dz-progress { display: none; }

.att-file-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); }
.att-file-item:last-child { border-bottom: none; }
.att-file-icon { flex-shrink: 0; }
.att-file-info { flex: 1; min-width: 0; }
.att-file-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.att-file-size { font-size: 11px; color: var(--muted); }
.att-dz-bar { height: 3px; background: var(--border-subtle); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.att-dz-fill { height: 100%; width: 0; background: var(--brand-600, #4f6ef7); border-radius: 2px; transition: width 0.4s ease; }
.att-file-remove { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 18px; flex-shrink: 0; line-height: 1; padding: 2px 4px; }
.att-file-remove:hover { color: var(--danger); }

/* STL viewer modal */
.stl-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.stl-modal.open { display: flex; }
.stl-modal-box {
    background: #2e3035;
    border-radius: 12px;
    width: min(94vw, 960px);
    height: min(88vh, 660px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.stl-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    position: relative;
    z-index: 10;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
    background: #1e2125;
}
.stl-modal-title {
    font-weight: 600;
    font-size: 13px;
    color: rgba(255,255,255,.82);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stl-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,.45);
    padding: 4px 6px;
    line-height: 1;
    font-size: 20px;
    border-radius: 6px;
    flex-shrink: 0;
    transition: color .15s, background .15s;
}
.stl-modal-close:hover { color: rgba(255,255,255,.9); background: rgba(255,255,255,.1); }
.stl-modal-body { display: flex; flex: 1; min-height: 0; }
#stl-viewer-el { flex: 1; min-height: 0; position: relative; overflow: hidden; z-index: 1; }
.stl-panel {
    width: 158px;
    flex-shrink: 0;
    background: #1e2125;
    border-left: 1px solid rgba(255,255,255,.06);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}
.stl-panel-section { padding: 12px 10px; }
.stl-panel-divider { height: 1px; background: rgba(255,255,255,.06); }
.stl-panel-spacer  { flex: 1; }
.stl-panel-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.3);
    margin-bottom: 9px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.stl-view-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
.stl-view-btn {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 5px;
    color: rgba(255,255,255,.65);
    font-size: 11px;
    font-weight: 500;
    padding: 6px 2px;
    cursor: pointer;
    text-align: center;
    transition: background .14s, color .14s, border-color .14s;
}
.stl-view-btn:hover {
    background: rgba(255,255,255,.13);
    color: #fff;
    border-color: rgba(255,255,255,.2);
}
.stl-mat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}
.stl-mat-btn {
    height: 30px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color .15s, transform .12s, box-shadow .15s;
}
.stl-mat-btn:hover { transform: scale(1.06); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.stl-mat-btn.active { border-color: #34b0a2; box-shadow: 0 0 0 1px #34b0a2; }
.stl-range {
    width: 100%;
    accent-color: #34b0a2;
    cursor: pointer;
    height: 4px;
    margin-top: 2px;
}
.stl-check-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: rgba(255,255,255,.65);
    cursor: pointer;
    user-select: none;
}
.stl-check-row input[type="checkbox"] { accent-color: #34b0a2; cursor: pointer; width: 14px; height: 14px; }
@media (max-width: 600px) {
    .stl-modal-body { flex-direction: column; }
    .stl-panel {
        width: auto;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,.06);
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: visible;
        height: auto;
        max-height: 200px;
        overflow-y: auto;
    }
    .stl-panel-spacer, .stl-panel-section:last-child { display: none; }
    .stl-panel-section { padding: 8px; }
    .stl-panel-divider { width: 1px; height: auto; }
}

/* ── Portal header ── */
.portal-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 28px;
    height: 56px;
    background: var(--ink-900);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    position: sticky;
    top: 0;
    z-index: 50;
}
.portal-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.portal-header-logo {
    width: 40px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.portal-header-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}
.portal-header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.portal-header-user {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    text-align: center;
}
.portal-page .content {
    padding-top: 28px;
}
@media (max-width: 640px) {
    .portal-header { padding: 0 14px; }
    .portal-header-name { display: none; }
    .portal-header-user { display: none; }
}

/* ── Tiptap rich text editor ── */
.tiptap-wrap {
    border: 1px solid var(--paper-200);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255,255,255,0.94);
    transition: border-color .15s, box-shadow .15s;
}
.tiptap-wrap:focus-within {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(52,176,162,0.18);
}
.tiptap-toolbar {
    display: flex;
    gap: 2px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--paper-200);
    background: var(--paper-50, #f9fafb);
    flex-wrap: wrap;
}
.tiptap-tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    color: var(--ink-600, #374151);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    transition: background .12s, color .12s;
}
.tiptap-tb-btn:hover { background: rgba(0,0,0,0.06); }
.tiptap-tb-btn.is-active { background: var(--brand-100, #ccf0ec); color: var(--brand-700, #0d7e72); border-color: var(--brand-300, #5dd5ca); }
.tiptap-tb-sep { width: 1px; background: var(--border-subtle); margin: 4px 4px; align-self: stretch; }
.tiptap-body .ProseMirror {
    padding: 12px 14px;
    min-height: 100px;
    outline: none;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
}
.tiptap-body .ProseMirror p { margin: 0 0 6px; }
.tiptap-body .ProseMirror p:last-child { margin-bottom: 0; }
.tiptap-body .ProseMirror ul,
.tiptap-body .ProseMirror ol { padding-left: 20px; margin: 0 0 6px; }
.tiptap-body .ProseMirror strong { font-weight: 700; }
.tiptap-body .ProseMirror em { font-style: italic; }
.tiptap-body .ProseMirror s { text-decoration: line-through; }
.tiptap-body .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    color: var(--muted);
    pointer-events: none;
    float: left;
    height: 0;
}
/* show.ejs render */
.obs-render p { margin: 0 0 6px; }
.obs-render p:last-child { margin: 0; }
.obs-render ul, .obs-render ol { padding-left: 20px; margin: 0 0 6px; }
.obs-render strong { font-weight: 700; }
.obs-render em { font-style: italic; }
