:root {
    --primary: #1a6fc4;
    --primary-dark: #0a1628;
    --primary-light: #4db8ff;
    --bg: #f0f4f8;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
}

.app-shell {
    display: flex;
    width: 100vw;
    max-width: 100vw;
    overflow: hidden;
}

.app-content {
    margin-left: 280px;
    width: calc(100vw - 280px);
    max-width: calc(100vw - 280px);
    min-width: 0;
    overflow-x: hidden;
}

.content-inner {
    max-width: 100%;
    overflow-x: hidden;
}

.app-sidebar {
    width: 280px;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    background: #0a1628;
    color: #ffffff;
    z-index: 1040;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

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

.sidebar-brand-zone {
    min-height: 130px;
    background: #0a1628;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: static;
    margin: 0;
    gap: 0.55rem;
}

.sidebar-logo-panel {
    background: rgba(255, 255, 255, 0.952);
    border-radius: 12px;
    padding: 2px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(4px);
    max-width: 100%;
    min-height: 130px;
    margin: 0 auto;
    width: 100%;
}

.sidebar-brand-main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    text-align: center;
    padding: 0;
}

.sidebar-clinic-logo {
    max-height: 105px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.sidebar-fallback-name {
    color: #f8fafc;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    max-width: 100%;
    word-break: break-word;
    text-align: center;
}

.sidebar-clinic-name {
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.3;
    max-width: 90%;
    word-break: break-word;
}

.sidebar-powered-by {
    color: #ffffff30;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: center;
    margin-top: 0;
    line-height: 1;
}

.sidebar-close {
    color: #ffffff;
    border: 0;
    background: transparent;
    align-self: flex-end;
    margin: 0 0 0.2rem;
}

.sidebar-user-zone {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    position: static;
    margin: 0;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1a6fc4;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-meta {
    min-width: 0;
}

.sidebar-user-name {
    color: #ffffff;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.1;
}

.sidebar-user-role {
    color: #a8b8d0;
    font-size: 0.72rem;
    line-height: 1.1;
    margin-top: 0.15rem;
    text-transform: uppercase;
}

.sidebar-nav-zone {
    padding: 0.65rem 0.5rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #dce8ff;
    text-decoration: none;
    border-radius: 8px;
    padding: 0.62rem 0.7rem;
    border-left: 3px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.sidebar-nav-link.active {
    background: #1a6fc4;
    color: #ffffff;
    border-left-color: #ffffff;
    font-weight: 600;
}

img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
    height: auto;
}

/* Keep any table overflow inside local wrapper */
.table-responsive,
.dataTables_wrapper {
    max-width: 100%;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > table {
    width: 100%;
}

/* Fallback for tables not wrapped yet */
.content-inner table {
    max-width: 100%;
}

.table {
    table-layout: fixed;
    width: 100% !important;
}

@media (max-width: 768px) {
    .app-content {
        margin-left: 0;
        width: 100vw;
        max-width: 100vw;
    }

    .top-navbar {
        left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .dt-hide-mobile {
        display: none !important;
    }

    .sidebar-brand-zone {
        min-height: 110px;
        padding: 12px;
    }

    .sidebar-logo-panel {
        min-height: 74px;
    }

    .sidebar-fallback-name {
        font-size: 16px;
    }
}

@media (min-width: 992px) {
    .app-sidebar {
        transform: translateX(0);
    }

    .sidebar-close {
        display: none;
    }
}

/* Global pattern: desktop tables + mobile cards */
.smx-table-desktop-wrap {
    width: 100%;
    overflow-x: auto;
}

.smx-cards-mobile {
    display: grid;
    gap: 0.75rem;
}

.smx-mobile-card {
    background: #ffffff;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
    padding: 0.95rem;
}

.smx-mobile-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.smx-mobile-card-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.smx-mobile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1a6fc4;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.smx-mobile-name {
    font-weight: 600;
    line-height: 1.2;
}

.smx-mobile-meta {
    font-size: 0.86rem;
    color: #64748b;
    margin-bottom: 0.2rem;
}

.smx-mobile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.55rem;
}
