@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap');

:root {
    --primary: #0f766e;
    --secondary: #64748b;
    --sidebar: #0f172a;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #697386;
    --border: #e4e9f0;
    --shadow: 0 10px 28px rgba(16, 24, 40, .07);
    --shadow-soft: 0 6px 18px rgba(16, 24, 40, .05);
    --radius: 13px;
}

[data-theme="dark"] {
    --bg: #0c1220;
    --surface: #151e2e;
    --surface-soft: #1b2639;
    --text: #e5eaf2;
    --muted: #94a3b8;
    --border: #263247;
    --shadow: 0 10px 28px rgba(0, 0, 0, .24);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --bg: #0c1220;
        --surface: #151e2e;
        --surface-soft: #1b2639;
        --text: #e5eaf2;
        --muted: #94a3b8;
        --border: #263247;
        --shadow: 0 10px 28px rgba(0, 0, 0, .24);
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', Arial, sans-serif;
    letter-spacing: 0;
    margin: 0;
    overflow-x: hidden;
}

.app-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 22px;
}

.page-title-row {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-title-row h1,
.card-heading h2 {
    color: var(--text);
    margin: 0;
}

.page-title-row p,
.card-heading p {
    color: var(--muted);
    margin: 6px 0 0;
}

.card-heading {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
}

h1,
h2,
h3,
h4,
.topbar-title,
.sidebar-brand {
    font-family: 'Manrope', Arial, sans-serif;
    letter-spacing: 0;
}

a {
    text-decoration: none;
}

img {
    max-width: 100%;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar);
    box-shadow: 10px 0 30px rgba(2, 6, 23, .16);
    color: #fff;
    display: flex;
    flex-direction: column;
    inset: 0 auto 0 0;
    position: fixed;
    width: 270px;
    z-index: 1040;
}

.sidebar-brand {
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    gap: 12px;
    min-height: 78px;
    padding: 17px 20px;
}

.brand-mark {
    align-items: center;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(15, 118, 110, .2);
    display: flex;
    flex: 0 0 42px;
    height: 42px;
    justify-content: center;
    overflow: hidden;
    width: 42px;
}

.brand-mark img {
    display: block;
    max-height: 32px;
    object-fit: contain;
    padding: 3px;
}

.brand-copy {
    min-width: 0;
}

.brand-copy strong,
.brand-copy span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-copy strong {
    color: #fff;
    font-size: 15px;
    font-weight: 800;
}

.brand-copy span {
    color: #94a3b8;
    font-size: 11px;
    margin-top: 2px;
}

.sidebar-close {
    background: transparent;
    border: 0;
    color: #fff;
    margin-left: auto;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 22px 14px;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
    scrollbar-width: thin;
}

.nav-section {
    color: #64748b;
    display: block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.4px;
    padding: 0 12px 10px;
    text-transform: uppercase;
}

.sidebar-link,
.sidebar-nav a,
.sidebar-group-toggle {
    align-items: center;
    border: 0;
    border-radius: 9px;
    color: #b5c0d1;
    display: flex;
    font-size: 14px;
    font-weight: 600;
    gap: 13px;
    margin: 4px 0;
    min-width: 0;
    padding: 11px 13px;
    text-align: left;
    transition: background .2s, color .2s, box-shadow .2s;
    width: 100%;
}

.sidebar-group-toggle {
    background: transparent;
}

.sidebar-link i,
.sidebar-nav a i,
.sidebar-group-toggle > i:first-child {
    flex: 0 0 18px;
    font-size: 18px;
}

.sidebar-link span,
.sidebar-nav a span,
.sidebar-group-toggle span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-link:hover,
.sidebar-link.active,
.sidebar-nav a:hover,
.sidebar-nav a.active,
.sidebar-group-toggle:hover,
.sidebar-group-toggle.active {
    background: rgba(255, 255, 255, .09);
    color: #fff;
}

.sidebar-link.active,
.sidebar-nav a.active {
    box-shadow: inset 3px 0 var(--primary);
}

.sidebar-group-arrow {
    flex: 0 0 auto;
    font-size: 12px !important;
    transition: transform .2s;
}

.sidebar-group-toggle[aria-expanded="true"] .sidebar-group-arrow {
    transform: rotate(180deg);
}

.sidebar-submenu {
    border-left: 1px solid rgba(255, 255, 255, .1);
    margin: 2px 0 8px;
    padding-left: 14px;
}

.sidebar-submenu a {
    font-size: 12.5px;
    padding: 9px 12px;
}

.sidebar-submenu a i {
    font-size: 15px;
}

.sidebar-profile {
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    gap: 10px;
    min-width: 0;
    padding: 15px;
}

.avatar-sm {
    align-items: center;
    background: color-mix(in srgb, var(--primary) 13%, #fff);
    border-radius: 9px;
    color: var(--primary);
    display: flex;
    flex: 0 0 34px;
    font-size: 12px;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.profile-copy {
    min-width: 0;
}

.profile-copy strong,
.profile-copy span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-copy strong {
    color: #fff;
    font-size: 12px;
}

.profile-copy span {
    color: #8492a6;
    font-size: 10px;
}

.main-area {
    display: flex;
    flex-direction: column;
    margin-left: 270px;
    min-height: 100vh;
    min-width: 0;
    width: calc(100% - 270px);
}

.topbar {
    align-items: center;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 16px;
    min-height: 76px;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-title {
    min-width: 0;
}

.topbar-title span,
.topbar-title small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-title span {
    color: var(--text);
    font-size: 17px;
    font-weight: 800;
}

.topbar-title small {
    color: var(--muted);
    font-family: 'DM Sans', Arial, sans-serif;
    font-size: 11px;
    margin-top: 2px;
}

.topbar-actions {
    align-items: center;
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.icon-btn,
.user-menu {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 9px;
    color: var(--muted);
    display: flex;
    height: 40px;
    justify-content: center;
}

.icon-btn {
    font-size: 18px;
    width: 40px;
}

.icon-btn:hover,
.user-menu:hover {
    background: var(--surface-soft);
}

.user-menu {
    gap: 9px;
    padding: 0 8px;
}

.content-area {
    flex: 1;
    margin: 0 auto;
    max-width: 1600px;
    padding: 30px 32px;
    width: 100%;
}

.app-footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    display: flex;
    font-size: 12px;
    justify-content: space-between;
    padding: 18px 32px;
}

.app-footer a {
    color: var(--primary);
}

.sidebar-backdrop {
    display: none;
}

.auth-shell {
    align-items: center;
    background:
        radial-gradient(circle at 82% 18%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 30%),
        linear-gradient(145deg, #08111f, #123047);
    display: grid;
    min-height: 100vh;
    padding: 24px;
}

.site-login {
    width: 100%;
}

.auth-layout {
    background: var(--surface);
    border-radius: 22px;
    box-shadow: 0 24px 70px rgba(2, 6, 23, .26);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    margin: 0 auto;
    max-width: 1120px;
    min-height: 680px;
    overflow: hidden;
    width: 100%;
}

.auth-visual {
    background:
        radial-gradient(circle at 82% 15%, rgba(45, 212, 191, .24), transparent 28%),
        linear-gradient(145deg, #07111f, #123047);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 38px;
}

.auth-brand,
.mobile-brand {
    align-items: center;
    display: flex;
    gap: 11px;
}

.auth-brand strong,
.mobile-brand strong {
    font-family: 'Manrope', Arial, sans-serif;
    font-weight: 800;
}

.auth-message {
    margin: auto 0;
    max-width: 520px;
}

.auth-message h1 {
    font-size: clamp(2rem, 4vw, 3.1rem);
    font-weight: 800;
    line-height: 1.08;
    margin: 14px 0;
}

.auth-message > p {
    color: #b9c7de;
    line-height: 1.7;
}

.auth-feature {
    display: flex;
    gap: 13px;
    margin-top: 24px;
}

.auth-feature > i {
    align-items: center;
    background: rgba(255, 255, 255, .1);
    border-radius: 9px;
    color: #7dd3fc;
    display: flex;
    flex: 0 0 39px;
    height: 39px;
    justify-content: center;
    width: 39px;
}

.auth-feature span,
.auth-feature strong {
    display: block;
    font-size: 12px;
}

.auth-feature span {
    color: #9fb0c9;
}

.auth-feature strong {
    color: #fff;
    margin-bottom: 2px;
}

.auth-visual > small {
    color: #7184a1;
}

.auth-form-side {
    align-items: center;
    background: var(--surface);
    display: flex;
    justify-content: center;
    padding: 36px;
}

.login-card {
    max-width: 390px;
    width: 100%;
}

.onboarding-card-enhanced {
    max-width: 500px;
}

.onboarding-card-enhanced h1 {
    color: var(--ink);
    font-size: clamp(1.7rem, 3vw, 2.25rem);
    font-weight: 800;
    letter-spacing: -.03em;
    margin-bottom: 10px;
}

.onboarding-card-enhanced .alert-success {
    background: color-mix(in srgb, #10b981 10%, var(--surface));
    border: 1px solid color-mix(in srgb, #10b981 28%, var(--border));
    border-radius: 14px;
    color: var(--ink);
    line-height: 1.55;
}

.onboarding-card-enhanced .border.rounded {
    background: color-mix(in srgb, var(--primary) 4%, var(--surface));
    border-color: var(--border) !important;
    border-radius: 14px !important;
}

.onboarding-card-enhanced .form-check {
    align-items: flex-start;
    display: flex;
    gap: 8px;
}

.onboarding-card-enhanced .form-check input {
    flex: 0 0 auto;
    margin-top: 4px;
}

.onboarding-card-enhanced .form-check label {
    color: var(--ink);
    font-size: 13px;
    line-height: 1.45;
}

.onboarding-card-enhanced .form-control,
.onboarding-card-enhanced .form-select {
    border-radius: 10px;
    min-height: 44px;
}

.onboarding-visual {
    min-height: 720px;
}

.login-card h2 {
    font-size: 30px;
    font-weight: 800;
    margin: 7px 0;
}

.login-card > p {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 24px;
}

.login-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(2, 6, 23, .22);
    margin: 0 auto;
    max-width: 440px;
    padding: 30px;
    text-align: center;
}

.login-logo {
    margin-bottom: 18px;
    max-height: 116px;
    object-fit: contain;
}

.btn-login {
    display: flex;
    gap: 9px;
    justify-content: center;
    margin-top: 10px;
    padding: 12px;
    width: 100%;
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 46px;
}

.password-toggle {
    align-items: center;
    background: transparent;
    border: 0;
    color: var(--muted);
    display: inline-flex;
    height: 38px;
    justify-content: center;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
}

.password-toggle:hover,
.password-toggle:focus {
    color: var(--primary);
}

.login-help {
    background: var(--surface-soft);
    border-radius: 9px;
    color: var(--muted);
    display: flex;
    font-size: 11px;
    gap: 9px;
    margin-top: 24px;
    padding: 12px;
}

.mobile-brand {
    display: none;
    margin-bottom: 32px;
}

.eyebrow.light {
    color: #93c5fd !important;
}

.panel,
.stat-card,
.clinic-hero,
.setting-box,
.system-error-card,
.grid-view,
.detail-view,
.card-like {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.clinic-hero {
    align-items: center;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 28px;
}

.clinic-hero h1,
.page-header h1 {
    font-size: clamp(1.55rem, 2vw, 2.05rem);
    font-weight: 800;
    line-height: 1.2;
    margin: 0 0 8px;
}

.clinic-hero p,
.page-header p {
    color: var(--muted);
    margin: 0;
}

.eyebrow {
    color: var(--primary) !important;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .1em;
    margin-bottom: 8px !important;
    text-transform: uppercase;
}

.hero-actions,
.button-group,
.form-actions,
.section-title,
.page-header,
.list-row {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.hero-actions,
.button-group,
.form-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
}

.page-header {
    margin: 0 0 18px;
}

.stats-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    margin-bottom: 18px;
}

.stat-card {
    min-width: 0;
    padding: 19px;
}

.stat-card span {
    color: var(--muted);
    display: block;
    font-size: .82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-card strong {
    display: block;
    font-family: 'Manrope', Arial, sans-serif;
    font-size: clamp(1.35rem, 2vw, 2rem);
    margin-top: 6px;
    overflow-wrap: anywhere;
}

.panel {
    margin-bottom: 16px;
    padding: 20px;
}

.section-title {
    margin-bottom: 14px;
}

.section-title h2,
.panel h2 {
    font-size: 1.12rem;
    font-weight: 800;
    margin: 0;
}

.quick-panel {
    margin: 18px 0;
}

.quick-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.search-bar,
.expense-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.expense-filter {
    align-items: end;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    padding: 14px;
}

.expense-filter .filter-field {
    min-width: 0;
}

.expense-filter .filter-field-wide {
    grid-column: span 2;
}

.filter-field label {
    color: var(--muted);
    display: block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.filter-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.filter-actions .btn {
    align-items: center;
    display: inline-flex;
    gap: 6px;
    justify-content: center;
    white-space: nowrap;
}

.btn {
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    padding: 9px 15px;
}

.btn-lg {
    font-size: 15px;
    padding: 12px 18px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 6px 14px color-mix(in srgb, var(--primary) 20%, transparent);
}

.btn-outline-primary {
    border-color: color-mix(in srgb, var(--primary) 62%, #fff);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.form-control,
.form-select {
    background-color: var(--surface);
    border-color: #dce1e9;
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    padding: 10px 12px;
}

.form-control:focus,
.form-select:focus {
    border-color: color-mix(in srgb, var(--primary) 70%, #fff);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--primary) 15%, transparent);
}

.form-card {
    max-width: 900px;
}

.form-label,
label {
    font-size: 12px;
    font-weight: 700;
}

.help-block,
.hint-block {
    color: var(--muted);
    display: block;
    font-size: 12px;
    margin-top: 5px;
}

.alert {
    align-items: center;
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
    display: flex;
    gap: 10px;
}

.app-reminder {
    justify-content: space-between;
}

.table,
.grid-view table,
.detail-view table {
    color: var(--text);
    font-size: 13px;
    margin-bottom: 0;
}

.grid-view {
    overflow: hidden;
}

.grid-view .table-responsive,
.grid-view table {
    overflow-x: auto;
}

.grid-view th,
.grid-view td,
.detail-view th,
.detail-view td {
    border-color: var(--border) !important;
    max-width: 420px;
    overflow-wrap: anywhere;
    vertical-align: middle;
}

.grid-view thead th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.grid-view tbody tr:hover {
    background: color-mix(in srgb, var(--primary) 4%, transparent);
}

.pagination {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    justify-content: flex-end;
    margin: 18px 0 0;
}

.pagination > li {
    display: block;
}

.pagination > li > a,
.pagination > li > span {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--muted);
    display: flex;
    font-size: 13px;
    font-weight: 800;
    justify-content: center;
    min-height: 36px;
    min-width: 36px;
    padding: 7px 11px;
    transition: background .18s, border-color .18s, color .18s, box-shadow .18s;
}

.pagination > li > a:hover {
    background: color-mix(in srgb, var(--primary) 9%, var(--surface));
    border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
    color: var(--primary);
}

.pagination > li.active > a,
.pagination > li.active > span {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 6px 14px color-mix(in srgb, var(--primary) 20%, transparent);
    color: #fff;
}

.pagination > li.disabled > span,
.pagination > li.disabled > a {
    background: var(--surface-soft);
    color: color-mix(in srgb, var(--muted) 52%, transparent);
    cursor: not-allowed;
}

.detail-view th {
    background: var(--surface-soft);
    color: var(--muted);
    width: 210px;
}

a.asc:after,
a.desc:after {
    background: transparent;
    border: solid 5px transparent;
    content: '';
    display: inline-block;
    height: 0;
    margin: 4px 4px 2px;
    width: 0;
}

a.asc:after {
    border-bottom: solid 7px var(--text);
    border-top-width: 0;
}

a.desc:after {
    border-bottom-width: 0;
    border-top: solid 7px var(--text);
}

.not-set {
    color: #c24141;
    font-style: italic;
}

.error-summary {
    background: #fff1f2;
    border-left: 3px solid #fb7185;
    border-radius: 8px;
    color: #9f1239;
    margin: 0 0 15px;
    padding: 10px 14px;
}

.setting-index {
    max-width: 980px;
}

.setting-section {
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    padding-bottom: 24px;
}

.setting-section:last-of-type {
    border-bottom: 0;
    margin-bottom: 10px;
    padding-bottom: 8px;
}

.setting-section h2 {
    color: var(--text);
    font-family: 'Manrope', Arial, sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0 0 16px;
}

.setting-preview {
    align-items: center;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    height: 100%;
    justify-content: space-between;
    min-height: 66px;
    padding: 12px 14px;
}

.setting-preview span {
    color: var(--muted);
    font-size: 12px;
}

.setting-preview strong {
    color: var(--text);
    font-family: 'Manrope', Arial, sans-serif;
}

.schedule-summary {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: grid;
    gap: 2px;
    min-height: 66px;
    padding: 12px 14px;
}

.schedule-summary span,
.schedule-summary em {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.schedule-summary strong {
    color: var(--text);
    font-family: 'Manrope', Arial, sans-serif;
}

.working-days {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.working-days .form-check {
    align-items: center;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: inline-flex;
    gap: 7px;
    margin: 0;
    min-height: 38px;
    padding: 8px 12px 8px 34px;
}

.form-control-color {
    min-height: 42px;
    padding: 5px;
    width: 100%;
}

.theme-preview {
    --preview-primary: var(--primary);
    --preview-secondary: var(--secondary);
    --preview-sidebar: var(--sidebar);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: grid;
    grid-template-columns: 110px 1fr;
    margin: 18px 0 4px;
    min-height: 120px;
    overflow: hidden;
}

.theme-preview-sidebar {
    background: var(--preview-sidebar);
}

.theme-preview-main {
    background: var(--surface-soft);
    display: grid;
    gap: 10px;
    padding: 18px;
}

.theme-preview-main span,
.theme-preview-main strong,
.theme-preview-main em {
    border-radius: 999px;
    display: block;
}

.theme-preview-main span {
    background: var(--preview-primary);
    height: 13px;
    width: 48%;
}

.theme-preview-main strong {
    background: color-mix(in srgb, var(--preview-secondary) 25%, var(--surface));
    height: 28px;
    width: 82%;
}

.theme-preview-main em {
    background: var(--preview-primary);
    height: 34px;
    justify-self: end;
    width: 120px;
}

.calendar-panel {
    overflow: visible;
}

.calendar-legend {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: .9rem;
    gap: 16px;
    margin-bottom: 14px;
}

.legend-dot {
    border-radius: 50%;
    display: inline-block;
    height: 10px;
    margin-right: 6px;
    width: 10px;
}

.legend-dot.status-programado { background: #f59f00; }
.legend-dot.status-confirmado { background: #2f9e44; }
.legend-dot.status-atendido { background: #1c7ed6; }
.legend-dot.status-cancelado { background: #e03131; }
.legend-dot.status-no_asistio { background: #868e96; }
.legend-dot.available { background: #94d3a2; }

.calendar-scroll {
    border: 1px solid var(--border);
    border-radius: 10px;
    max-height: 72vh;
    overflow: auto;
    position: relative;
}

.calendar-table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1120px;
    table-layout: fixed;
    width: 100%;
}

.calendar-table th,
.calendar-table td {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    vertical-align: top;
}

.calendar-table thead th {
    background: var(--surface-soft);
    box-shadow: 0 1px 0 var(--border);
    padding: 10px;
    position: sticky;
    text-align: center;
    top: 0;
    z-index: 2;
}

.calendar-table thead th span {
    color: var(--muted);
    display: block;
    font-size: .82rem;
}

.calendar-table .calendar-time,
.calendar-time-head {
    background: var(--surface-soft);
    color: var(--muted);
    font-weight: 800;
    width: 76px;
}

.calendar-table .calendar-time {
    box-shadow: 1px 0 0 var(--border);
    left: 0;
    padding: 10px 8px;
    position: sticky;
    z-index: 1;
}

.calendar-time-head {
    box-shadow: 1px 1px 0 var(--border);
    left: 0;
    position: sticky;
    z-index: 3 !important;
}

.calendar-table td {
    background: var(--surface);
    height: 58px;
    padding: 5px;
}

.calendar-event {
    border-radius: 7px;
    display: block;
    font-size: .82rem;
    line-height: 1.22;
    min-height: 40px;
    overflow: hidden;
    padding: 6px 7px;
    text-decoration: none;
}

.calendar-event + .calendar-event {
    margin-top: 6px;
}

.calendar-event strong,
.calendar-event span,
.calendar-event em {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-event em {
    font-size: .7rem;
    font-style: normal;
    font-weight: 800;
    margin-top: 3px;
    text-transform: uppercase;
}

.calendar-event.available {
    background: color-mix(in srgb, #22c55e 11%, var(--surface));
    border: 1px dashed #86efac;
    color: #166534;
    font-weight: 800;
    padding-top: 12px;
    text-align: center;
}

.appointment-patient-search {
    align-items: end;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    padding: 12px;
}

.appointment-patient-search label {
    color: var(--muted);
    display: grid;
    flex: 1 1 260px;
    font-size: .86rem;
    gap: 4px;
}

.appointment-patient-search input[type="text"] {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    min-height: 38px;
    padding: 6px 10px;
}

.appointment-patient-search .btn {
    min-height: 38px;
}

.calendar-event.status-programado {
    background: #fff3bf;
    border: 1px solid #ffd43b;
    color: #7a4f01;
}

.calendar-event.status-confirmado {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
}

.calendar-event.status-atendido {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    color: #124e8a;
}

.calendar-event.status-cancelado {
    background: #ffe3e3;
    border: 1px solid #ffa8a8;
    color: #9b1c1c;
}

.calendar-event.status-no_asistio {
    background: #f1f3f5;
    border: 1px solid #ced4da;
    color: #495057;
}

.timeline-row,
.list-row {
    border-top: 1px solid var(--border);
    padding: 14px 0;
}

.timeline-row:first-of-type,
.list-row:first-of-type {
    border-top: 0;
}

.timeline-row span,
.list-row span {
    color: var(--muted);
    display: block;
    font-size: .84rem;
}

.timeline-row p {
    color: var(--muted);
    margin: 6px 0 0;
    overflow-wrap: anywhere;
}

.patient-profile-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 14px;
}

.patient-profile-item {
    align-items: flex-start;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 11px;
    display: flex;
    gap: 11px;
    min-width: 0;
    padding: 13px;
}

.patient-profile-item > i {
    align-items: center;
    background: color-mix(in srgb, var(--primary) 11%, var(--surface));
    border-radius: 9px;
    color: var(--primary);
    display: flex;
    flex: 0 0 34px;
    font-size: 16px;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.patient-profile-item div {
    min-width: 0;
}

.patient-profile-item span,
.patient-profile-item strong {
    display: block;
}

.patient-profile-item span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.patient-profile-item strong {
    color: var(--text);
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.patient-clinical-summary {
    margin-top: 10px;
}

.patient-clinical-summary .timeline-row strong {
    align-items: center;
    display: flex;
    gap: 8px;
}

.patient-clinical-summary .timeline-row strong i {
    color: var(--primary);
}

.odontogram {
    display: grid;
    gap: 18px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.tooth-row {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(16, minmax(112px, 1fr));
}

.tooth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    border-top: 5px solid #9fb0c0;
    padding: 8px;
    position: relative;
}

.tooth-card strong {
    display: block;
    margin-bottom: 6px;
    text-align: center;
}

.tooth-card.has-note {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 12%, transparent);
}

.tooth-note-indicator {
    align-items: center;
    background: var(--primary);
    border-radius: 999px;
    color: #fff;
    display: flex;
    font-size: 11px;
    height: 22px;
    justify-content: center;
    position: absolute;
    right: 7px;
    top: 7px;
    width: 22px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0;
}

.legend-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: .85rem;
    padding: 5px 10px;
}

.status-sano { border-color: #22a06b; }
.status-caries { background: #d9480f; border-color: #d9480f; color: white; }
.status-obturado { background: #1c7ed6; border-color: #1c7ed6; color: white; }
.status-extraido { background: #c92a2a; border-color: #c92a2a; color: white; }
.status-endodoncia { background: #7048e8; border-color: #7048e8; color: white; }
.status-corona { background: #f08c00; border-color: #f08c00; color: white; }
.status-implante { background: #0b7285; border-color: #0b7285; color: white; }
.status-ausente { background: #868e96; border-color: #868e96; color: white; }

.system-error-page {
    display: grid;
    min-height: calc(100vh - 220px);
    place-items: center;
    padding: 24px;
}

.system-error-card {
    overflow: hidden;
    padding: 42px;
    position: relative;
    text-align: center;
    width: min(620px, 100%);
}

.system-error-card:before {
    background: linear-gradient(90deg, var(--primary), #60a5fa);
    content: "";
    height: 4px;
    inset: 0 0 auto;
    position: absolute;
}

.error-icon {
    align-items: center;
    background: color-mix(in srgb, var(--primary) 10%, var(--surface));
    border-radius: 18px;
    color: var(--primary);
    display: flex;
    font-size: 30px;
    height: 70px;
    justify-content: center;
    margin: 0 auto 20px;
    width: 70px;
}

.error-actions {
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    justify-content: center;
    margin-top: 24px;
    padding-top: 20px;
}

.error-technical {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--muted);
    font-size: 11px;
    margin-top: 20px;
    padding: 10px 12px;
    text-align: left;
}

.error-technical code {
    color: #b42318;
    display: block;
    margin-top: 8px;
    white-space: pre-wrap;
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s;
    }

    .sidebar-open .sidebar {
        transform: none;
    }

    .sidebar-open .sidebar-backdrop {
        background: rgba(0, 0, 0, .52);
        display: block;
        inset: 0;
        position: fixed;
        z-index: 1030;
    }

    .main-area {
        margin-left: 0;
        width: 100%;
    }

    .topbar {
        padding: 0 18px;
    }

    .content-area {
        padding: 24px 18px;
    }

    .auth-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .auth-visual {
        display: none;
    }

    .auth-form-side {
        min-height: calc(100vh - 48px);
    }

    .mobile-brand {
        display: flex;
    }

    .clinic-hero,
    .page-header,
    .section-title,
    .list-row {
        align-items: stretch;
        flex-direction: column;
    }

    .hero-actions .btn,
    .button-group .btn,
    .form-actions .btn {
        width: 100%;
    }

    .expense-filter {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .expense-filter .filter-field-wide,
    .filter-actions {
        grid-column: 1 / -1;
    }

    .filter-actions .btn {
        flex: 1;
    }
}

@media (max-width: 575px) {
    .auth-shell {
        padding: 12px;
    }

    .login-panel {
        padding: 22px;
    }

    .content-area {
        padding: 18px 12px;
    }

    .panel,
    .clinic-hero,
    .stat-card {
        padding: 15px;
    }

    .topbar-title small {
        display: none;
    }

    .app-footer {
        flex-direction: column;
        gap: 6px;
        padding: 16px 18px;
    }

    .calendar-legend {
        gap: 8px;
    }

    .calendar-scroll {
        max-height: 68vh;
    }

    .calendar-table {
        min-width: 980px;
    }

    .detail-view th {
        width: 145px;
    }

    .expense-filter {
        grid-template-columns: 1fr;
    }

    .patient-profile-grid {
        grid-template-columns: 1fr;
    }

    .system-error-card {
        padding: 34px 18px 24px;
    }

    .error-actions .btn {
        width: 100%;
    }
}
