:root {
    --primary: #0d6e6e;
    --primary-dark: #0a5858;
    --primary-light: #e6f4f4;
    --primary-rgb: 13, 110, 110;
    --accent: #1565c0;
    --bs-primary: #0d6e6e;
    --bs-primary-rgb: 13, 110, 110;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --border: #e3e8ef;
    --border-strong: #cfd8e3;
    --text: #1c2530;
    --text-muted: #6b7a8c;
    --sidebar-bg: #15202b;
    --sidebar-text: #a8b5c4;
    --sidebar-active-bg: rgba(13, 110, 110, 0.14);
    --sidebar-active-text: #5eead4;
    --sidebar-width: 260px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(21, 32, 43, 0.05);
    --shadow-md: 0 4px 16px rgba(21, 32, 43, 0.08);
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* Material Symbols */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 20px;
    line-height: 1;
    vertical-align: middle;
    user-select: none;
}
.material-symbols-outlined.icon-sm { font-size: 18px; }
.material-symbols-outlined.icon-lg { font-size: 24px; }
.material-symbols-outlined.icon-xl { font-size: 28px; }
.material-symbols-outlined.filled { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.material-symbols-outlined.icon-hero { font-size: 64px; opacity: 0.35; color: var(--text-muted); }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
}
.app-content { padding: 28px 32px; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.app-dev-footer { margin-top: auto; background: var(--surface-1, #fff); }
.app-dev-footer a { color: var(--brand, #0d6e6e); text-decoration: none; }
.token-badge {
    display: inline-block;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    background: linear-gradient(135deg, #0d6e6e 0%, #0a5858 100%);
    color: #fff;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}
.app-sidebar::-webkit-scrollbar { width: 5px; }
.app-sidebar::-webkit-scrollbar-thumb { background: #2d3a47; border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--primary);
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
}
.brand-logo .material-symbols-outlined { font-size: 22px; color: #fff; }
.brand-text strong { display: block; font-size: 16px; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-text small {
    color: var(--sidebar-text);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-section {
    color: #6d7d8f;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 18px 14px 8px;
}
.nav-link-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 2px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 13.5px;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}
.nav-link-item .material-symbols-outlined { font-size: 20px; opacity: 0.85; }
.nav-link-item:hover { background: rgba(255, 255, 255, 0.05); color: #e8edf2; }
.nav-link-item.active {
    background: var(--sidebar-active-bg);
    color: #fff;
    border-left-color: var(--primary);
    font-weight: 600;
}
.nav-link-item.active .material-symbols-outlined {
    color: var(--sidebar-active-text);
    opacity: 1;
}
.sidebar-footer {
    padding: 12px 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-footer .nav-link-item.text-danger { color: #f87171; }
.sidebar-footer .nav-link-item.text-danger:hover { background: rgba(248, 113, 113, 0.1); }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 20, 25, 0.55); z-index: 1035; }

/* ---------- Topbar ---------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 19px; font-weight: 700; margin: 0; color: var(--text); letter-spacing: -0.02em; }
.topbar-date { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-search {
    display: flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    gap: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.topbar-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}
.topbar-search input { border: 0; background: transparent; outline: none; width: 200px; font-size: 13px; }
.topbar-search .material-symbols-outlined { color: var(--text-muted); font-size: 20px; }

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    display: grid;
    place-items: center;
    color: var(--text-muted);
    transition: background 0.15s, border-color 0.15s;
}
.btn-icon:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.topbar-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; background: #e53935; border-radius: 50%; border: 2px solid #fff; }
.notif-menu { width: 300px; border: 1px solid var(--border); border-radius: var(--radius); }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    padding: 6px 12px 6px 6px;
    transition: border-color 0.15s;
}
.topbar-user:hover { border-color: var(--border-strong); }
.topbar-user small { display: block; color: var(--text-muted); font-size: 11px; }
.topbar-user strong { font-size: 13px; font-weight: 600; }
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 13px;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 72px; height: 72px; border-radius: 14px; font-size: 26px; }

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    overflow: hidden;
}
.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
    padding: 16px 20px;
    color: var(--text);
}
.card-body { padding: 20px; }

/* ---------- Stat cards ---------- */
.stat-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    height: 100%;
    transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.stat-icon .material-symbols-outlined { font-size: 24px; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; color: var(--text); }
.stat-label { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.stat-trend { font-size: 12px; font-weight: 500; margin-top: 6px; }

.bg-soft-primary { background: var(--primary-light); color: var(--primary); }
.bg-soft-success { background: #e8f5e9; color: #2e7d32; }
.bg-soft-warning { background: #fff8e1; color: #f57c00; }
.bg-soft-info { background: #e3f2fd; color: #1565c0; }
.bg-soft-danger { background: #ffebee; color: #c62828; }
.bg-soft-purple { background: #f3e5f5; color: #7b1fa2; }

/* ---------- Tables ---------- */
.table { margin: 0; }
.table thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    white-space: nowrap;
}
.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f3f7;
    font-size: 13.5px;
}
.table tbody tr:hover { background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-card { overflow: visible; }
.table-card > .table-responsive {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}
.table-card .dropdown-menu {
    min-width: 11rem;
    white-space: nowrap;
}

.badge {
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    letter-spacing: 0.02em;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    padding: 8px 16px;
    transition: all 0.15s;
}
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}
.btn-outline-primary {
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.35);
}
.btn-outline-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.form-control, .form-select {
    border-radius: 8px;
    border-color: var(--border);
    padding: 10px 12px;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}
.form-control-lg { border-radius: 9px; }

/* ---------- Page header ---------- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.03em;
    color: var(--text);
}
.page-header p { color: var(--text-muted); margin: 4px 0 0; font-size: 14px; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .material-symbols-outlined { font-size: 48px; opacity: 0.3; color: var(--text-muted); }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); border: 1px solid transparent; font-size: 13.5px; }
.alert-success { background: #e8f5e9; border-color: #c8e6c9; color: #1b5e20; }
.alert-danger { background: #ffebee; border-color: #ffcdd2; color: #b71c1c; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-aside {
    background: var(--sidebar-bg);
    color: #e8edf2;
    padding: 56px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.auth-aside::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(13, 110, 110, 0.25) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(21, 101, 192, 0.12) 0%, transparent 45%);
    pointer-events: none;
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 12px; }
.auth-aside .lead { font-size: 16px; color: #94a3b8; max-width: 400px; }
.auth-feature {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-top: 24px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.auth-feature .material-symbols-outlined {
    font-size: 24px;
    color: var(--sidebar-active-text);
    background: rgba(13, 110, 110, 0.2);
    padding: 10px;
    border-radius: 8px;
}
.auth-form-side { display: grid; place-items: center; padding: 40px; background: var(--surface-2); }
.auth-card { width: 100%; max-width: 420px; }
.auth-logo {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--primary);
    display: grid;
    place-items: center;
    color: #fff;
    margin-bottom: 20px;
}
.auth-logo .material-symbols-outlined { font-size: 28px; color: #fff; }
.auth-demo-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
@media (max-width: 900px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

/* ---------- Platform admin ---------- */
.platform-shell { display: flex; min-height: 100vh; }
.platform-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #e8edf2;
    padding: 16px 12px;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}
.platform-sidebar .platform-brand {
    padding: 8px 10px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 12px;
}
.platform-sidebar a {
    color: var(--sidebar-text);
    text-decoration: none;
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}
.platform-sidebar a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.platform-sidebar a.active {
    background: var(--sidebar-active-bg);
    color: #fff;
    border-left-color: var(--primary);
    font-weight: 600;
}
.platform-sidebar a.active .material-symbols-outlined { color: var(--sidebar-active-text); }
.platform-sidebar a.text-danger { color: #f87171; }
.platform-main { flex: 1; background: var(--surface-2); min-width: 0; }
.platform-topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    box-shadow: var(--shadow-sm);
}
.platform-content { padding: 28px 32px; }

/* ---------- Odontogram ---------- */
.odontogram { display: flex; flex-direction: column; gap: 18px; }
.tooth-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.tooth {
    width: 46px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    text-align: center;
    cursor: pointer;
    padding: 6px 2px;
    transition: all 0.12s;
    user-select: none;
}
.tooth:hover { border-color: var(--primary); transform: translateY(-2px); }
.tooth .tnum { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.tooth .ticon { font-size: 20px; line-height: 1; }
.tooth.sel { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15); }
.tooth.caries { background: #fef2f2; }
.tooth.filled { background: #eff6ff; }
.tooth.crown { background: #fffbeb; }
.tooth.missing { background: #f8fafc; opacity: 0.5; }
.tooth.root_canal { background: #f5f3ff; }
.tooth.implant { background: #ecfdf5; }

/* ---------- Misc ---------- */
.list-tight li { padding: 9px 0; border-bottom: 1px solid #f0f3f7; }
.list-tight li:last-child { border: 0; }
.timeline-item {
    position: relative;
    padding-left: 26px;
    padding-bottom: 18px;
    border-left: 2px solid var(--border);
    margin-left: 6px;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
}
.timeline-item:last-child { border-color: transparent; }
.text-muted-2 { color: var(--text-muted); }
.divider-label {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 18px 0 12px;
}
.divider-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.profile-head { display: flex; gap: 18px; align-items: center; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.info-grid .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.info-grid .value { font-weight: 600; }

.nav-pills .nav-link { color: var(--text-muted); border-radius: 8px; font-weight: 600; font-size: 13px; }
.nav-pills .nav-link.active { background: var(--primary); }
.nav-tabs .nav-link { color: var(--text-muted); font-weight: 600; border: 0; }
.nav-tabs .nav-link.active { color: var(--primary); border-bottom: 2px solid var(--primary); background: transparent; }

.dropdown-menu { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 6px; z-index: 1080; }
.dropdown-item { border-radius: 6px; font-size: 13.5px; padding: 8px 12px; }
.dropdown-item:hover { background: var(--surface-2); }

@media (max-width: 992px) {
    .app-main { margin-left: 0; }
    .app-sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
    .app-sidebar.show { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .app-content { padding: 20px 16px; }
    .app-topbar { padding: 14px 16px; }
}

@media print {
    .app-sidebar, .app-topbar, .page-actions, .btn { display: none !important; }
    .app-main { margin-left: 0 !important; }
}
