:root {
    --kova-teal: #66c7cc;
    --kova-teal-dark: #178a94;
    --kova-lime: #c9dc4e;
    --kova-lime-dark: #9fb72d;
    --kova-ink: #152635;
    --kova-muted: #7e8a99;
    --kova-bg: #f5f8fa;
    --kova-sidebar: #17202d;
    --kova-sidebar-2: #1f2a3a;
    --kova-border: #e6edf2;
    --sidebar-width: 286px;
    --sidebar-width-collapsed: 82px;
    --topbar-height: 78px;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    color: var(--kova-ink);
    background: var(--kova-bg);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-body {
    min-height: 100vh;
}

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

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    width: var(--sidebar-width);
    color: #fff;
    background:
        linear-gradient(180deg, rgba(102, 199, 204, 0.12), transparent 28%),
        var(--kova-sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    transition: width 0.22s ease, transform 0.22s ease;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-link img {
    width: 188px;
    max-width: 100%;
    height: auto;
    display: block;
}

.sidebar-icon-btn,
.topbar-icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    background: rgba(255, 255, 255, 0.08);
}

.topbar-icon-btn {
    color: var(--kova-ink);
    background: #eef5f7;
}

.topbar-icon-btn:hover,
.sidebar-icon-btn:hover {
    background: rgba(102, 199, 204, 0.18);
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px 14px;
}

.profile-avatar,
.user-chip-avatar,
.login-mark,
.metric-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.profile-avatar,
.user-chip-avatar {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    color: var(--kova-sidebar);
    background: var(--kova-lime);
    font-weight: 800;
}

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

.profile-name,
.profile-role {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-name {
    font-size: 0.94rem;
    font-weight: 700;
}

.profile-role {
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.78rem;
}

.sidebar-menu {
    padding: 8px 14px 24px;
    overflow-y: auto;
}

.menu-item,
.menu-section-toggle {
    width: 100%;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: rgba(255, 255, 255, 0.72);
    background: transparent;
    font-size: 0.92rem;
    font-weight: 650;
    text-align: left;
    transition: background 0.18s ease, color 0.18s ease;
}

.menu-item i,
.menu-section-toggle i:first-child {
    width: 22px;
    color: rgba(102, 199, 204, 0.9);
    font-size: 1.08rem;
}

.menu-item:hover,
.menu-section-toggle:hover,
.menu-item.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.menu-item.active {
    box-shadow: inset 3px 0 0 var(--kova-lime);
}

.menu-section {
    margin-top: 8px;
}

.menu-section-toggle {
    justify-content: space-between;
}

.menu-section-toggle span {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.menu-sub {
    display: none;
    padding: 4px 0 0 12px;
}

.menu-section.open .menu-sub {
    display: block;
}

.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.22s ease;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--kova-border);
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.topbar-eyebrow {
    color: var(--kova-muted);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
}

.topbar-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0;
}

.app-content {
    padding: 28px;
}

.content-panel {
    min-height: calc(100vh - var(--topbar-height) - 56px);
}

.user-chip {
    border: 1px solid var(--kova-border);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 6px 12px 6px 6px;
    color: var(--kova-ink);
    background: #fff;
}

.user-chip::after {
    margin-left: 2px;
}

.user-chip-text {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}

.btn-kova,
.btn-kova-soft {
    border-radius: 8px;
    font-weight: 750;
}

.btn-kova {
    border-color: var(--kova-teal-dark);
    color: #fff;
    background: var(--kova-teal-dark);
}

.btn-kova:hover {
    border-color: #11747c;
    color: #fff;
    background: #11747c;
}

.btn-kova-soft {
    border-color: rgba(102, 199, 204, 0.28);
    color: var(--kova-teal-dark);
    background: rgba(102, 199, 204, 0.12);
}

.btn-kova-soft:hover {
    border-color: rgba(102, 199, 204, 0.4);
    color: var(--kova-teal-dark);
    background: rgba(102, 199, 204, 0.2);
}

.card-kova,
.module-card,
.table-card {
    border: 1px solid var(--kova-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(21, 38, 53, 0.05);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.metric-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
}

.metric-label {
    color: var(--kova-muted);
    font-size: 0.82rem;
    font-weight: 750;
}

.metric-value {
    margin-top: 4px;
    font-size: 1.72rem;
    line-height: 1;
    font-weight: 850;
}

.metric-icon {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    color: var(--kova-teal-dark);
    background: rgba(102, 199, 204, 0.14);
    font-size: 1.28rem;
}

.module-card {
    padding: 20px;
}

.module-card h2,
.table-card h2 {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 820;
}

.module-card p {
    color: var(--kova-muted);
}

.table-card {
    overflow: hidden;
}

.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--kova-border);
}

.table > :not(caption) > * > * {
    padding: 0.92rem 1rem;
}

.status-pill {
    border-radius: 999px;
    padding: 0.32rem 0.62rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 800;
}

.status-ok {
    color: #19715e;
    background: rgba(91, 204, 174, 0.18);
}

.status-warn {
    color: #875700;
    background: rgba(201, 220, 78, 0.24);
}

.status-info {
    color: #17657a;
    background: rgba(102, 199, 204, 0.16);
}

.status-danger {
    color: #9b2f22;
    background: rgba(220, 92, 78, 0.14);
}

.loading-state {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--kova-muted);
    font-weight: 700;
}

.odontograma-board {
    border: 1px solid var(--kova-border);
    border-radius: 8px;
    padding: 18px;
    background: #fbfdfe;
    overflow-x: auto;
}

.dental-arch + .dental-midline,
.dental-midline + .dental-arch {
    margin-top: 18px;
}

.dental-arch-label {
    margin-bottom: 10px;
    color: var(--kova-muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.dental-midline {
    height: 1px;
    background: var(--kova-border);
}

.tooth-grid {
    display: grid;
    grid-template-columns: repeat(16, minmax(54px, 1fr));
    gap: 8px;
    min-width: 840px;
}

.tooth-card {
    position: relative;
    min-height: 112px;
    border: 1px solid #d9e4ea;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    padding: 8px 6px;
    color: var(--kova-ink);
    background: #fff;
    text-align: center;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.tooth-card:hover {
    border-color: var(--tooth-color, var(--kova-teal-dark));
    box-shadow: 0 8px 18px rgba(21, 38, 53, 0.08);
    transform: translateY(-1px);
}

.tooth-card.selected {
    border-color: var(--kova-teal-dark);
    box-shadow: 0 0 0 3px rgba(102, 199, 204, 0.24);
}

.tooth-card.has-detail {
    border-color: var(--tooth-color, #64748b);
    background: color-mix(in srgb, var(--tooth-color, #64748b) 12%, #fff);
}

.tooth-card-empty {
    justify-content: center;
    color: var(--kova-muted);
    background: #f4f7f9;
}

.tooth-crown {
    width: 32px;
    height: 42px;
    border: 2px solid var(--tooth-color, #cbd5e1);
    border-radius: 12px 12px 8px 8px;
    display: block;
    background: linear-gradient(180deg, #fff 0%, #eef4f7 100%);
}

.tooth-number {
    font-size: 0.9rem;
    line-height: 1.05;
    font-weight: 850;
}

.tooth-name {
    width: 100%;
    min-height: 26px;
    color: var(--kova-muted);
    font-size: 0.68rem;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tooth-count {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 19px;
    height: 19px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--tooth-color, #64748b);
    font-size: 0.68rem;
    font-weight: 850;
}

.condition-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.condition-chip {
    border: 1px solid var(--kova-border);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 6px 10px;
    color: var(--kova-ink);
    background: #fff;
    font-size: 0.78rem;
    font-weight: 750;
}

.condition-chip:hover {
    border-color: rgba(102, 199, 204, 0.55);
    background: rgba(102, 199, 204, 0.08);
}

.condition-dot {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    display: inline-block;
    flex: 0 0 auto;
}

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(380px, 480px) 1fr;
    background: #fff;
}

.login-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
}

.login-logo {
    width: 260px;
    max-width: 100%;
    margin-bottom: 34px;
}

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

.login-card h1 {
    margin: 0 0 8px;
    font-size: 1.7rem;
    font-weight: 850;
}

.login-card p {
    color: var(--kova-muted);
}

.login-visual {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(23, 138, 148, 0.95), rgba(21, 38, 53, 0.98)),
        var(--kova-sidebar);
}

.login-visual-inner {
    width: min(620px, 72%);
}

.login-visual img {
    width: 320px;
    max-width: 100%;
    margin-bottom: 40px;
}

.login-visual h2 {
    font-size: 2.4rem;
    font-weight: 850;
}

.login-visual p {
    max-width: 520px;
    color: rgba(255, 255, 255, 0.76);
    font-size: 1.02rem;
}

.login-mark {
    width: 74px;
    height: 74px;
    border-radius: 18px;
    margin-bottom: 22px;
    color: var(--kova-sidebar);
    background: var(--kova-lime);
    font-size: 2rem;
}

.alert-login {
    display: none;
}

.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-width-collapsed);
}

.sidebar-collapsed .app-main {
    margin-left: var(--sidebar-width-collapsed);
}

.sidebar-collapsed .brand-link img,
.sidebar-collapsed .profile-meta,
.sidebar-collapsed .menu-item span,
.sidebar-collapsed .menu-section-toggle span,
.sidebar-collapsed .menu-section-toggle .bi-chevron-down {
    display: none;
}

.sidebar-collapsed .sidebar-brand,
.sidebar-collapsed .sidebar-profile,
.sidebar-collapsed .menu-item,
.sidebar-collapsed .menu-section-toggle {
    justify-content: center;
}

.sidebar-collapsed .menu-sub {
    padding-left: 0;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 1199px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: min(86vw, var(--sidebar-width));
    }

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

    .sidebar-open .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1035;
        display: block;
        background: rgba(21, 38, 53, 0.48);
    }

    .app-main,
    .sidebar-collapsed .app-main {
        margin-left: 0;
    }

    .app-topbar {
        padding: 0 18px;
    }

    .app-content {
        padding: 18px;
    }

    .login-page {
        grid-template-columns: 1fr;
    }

    .login-visual {
        display: none;
    }
}

@media (max-width: 640px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .topbar-actions .btn-kova-soft span,
    .user-chip-text {
        display: none;
    }

    .login-panel {
        padding: 32px 22px;
    }

    .table-card-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .odontograma-board {
        padding: 12px;
    }

    .tooth-grid {
        grid-template-columns: repeat(8, minmax(54px, 1fr));
        min-width: 448px;
    }

    .tooth-card {
        min-height: 104px;
    }
}
