/* SAPCMTY Mega App - Refined Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

/* ═══════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════ */
:root {
    /* Primary */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.08);
    --primary-lighter: rgba(37, 99, 235, 0.04);

    /* Surfaces */
    --bg-body: #f4f6f9;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;

    /* Text */
    --text-main: #0f172a;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --text-placeholder: #a0aec0;

    /* Border */
    --border: #e8ecf1;
    --border-light: #f1f5f9;

    /* Feedback */
    --success: #10b981;
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --warning-bg: #fffbeb;
    --warning-text: #b45309;
    --danger-bg: #fef2f2;
    --danger-text: #dc2626;
    --info-bg: #eff6ff;
    --info-text: #2563eb;

    /* Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.625rem;
    --radius-xl: 0.875rem;
    --radius-2xl: 1.25rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
    --shadow-modal: 0 20px 40px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.06);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --header-height: 60px;

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 150ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;
}

/* ═══════════════════════════════════
   DARK MODE
   ═══════════════════════════════════ */
[data-theme="dark"] {
    --bg-body: #0c111b;
    --bg-surface: #151c2c;
    --bg-elevated: #1a2236;
    --text-main: #e8edf5;
    --text-secondary: #8896ab;
    --text-light: #5a6a80;
    --text-placeholder: #4a5568;
    --border: #1e293b;
    --border-light: #172032;
    --primary-light: rgba(37, 99, 235, 0.15);
    --primary-lighter: rgba(37, 99, 235, 0.06);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-modal: 0 20px 40px rgba(0, 0, 0, 0.5);
}

/* ═══════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 0.875rem;
    overflow: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--duration-fast) var(--ease-in-out);
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* Smooth scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

::selection {
    background: var(--primary);
    color: white;
}

/* ═══════════════════════════════════
   LAYOUT
   ═══════════════════════════════════ */
#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

#sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: width var(--duration-slow) var(--ease-out),
        transform var(--duration-slow) var(--ease-out);
    position: fixed;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

@media (min-width: 769px) {
    #sidebar {
        position: relative;
    }
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    width: 100%;
}

#top-navbar {
    height: var(--header-height);
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 40;
    transition: background-color var(--duration-normal) var(--ease-in-out);
}

[data-theme="dark"] #top-navbar {
    background-color: rgba(21, 28, 44, 0.85);
}

#page-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    scroll-behavior: smooth;
}

/* Page content fade-in */
#page-container>* {
    animation: pageIn 0.3s var(--ease-out) both;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════
   SIDEBAR STATES
   ═══════════════════════════════════ */
#sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

#sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.6rem;
    margin: 0.15rem 0.5rem;
    font-size: 0;
}

#sidebar.collapsed .nav-link .material-symbols-outlined {
    margin-right: 0;
    font-size: 1.35rem;
}

#sidebar.collapsed p {
    display: none;
}

#sidebar.collapsed h3 {
    display: none;
}

#sidebar.collapsed .nav-link span {
    display: block;
}

#sidebar.collapsed>div:first-child {
    justify-content: center;
    padding: 1.25rem 0;
}

#sidebar.collapsed>div:first-child h3 {
    display: none;
}

/* ═══════════════════════════════════
   INPUT GROUP (Search with icon)
   ═══════════════════════════════════ */
.input-group {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 1.15rem;
    pointer-events: none;
    z-index: 1;
}

/* ═══════════════════════════════════
   LABEL
   ═══════════════════════════════════ */
.label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════
   MOBILE OVERLAY BACKDROP
   ═══════════════════════════════════ */
#sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 49;
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-in-out);
}

#sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* ═══════════════════════════════════
   MOBILE — CORE LAYOUT
   ═══════════════════════════════════ */
@media (max-width: 768px) {
    html {
        overflow-x: hidden;
    }

    body {
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
        -webkit-tap-highlight-color: transparent;
    }

    #app {
        flex-direction: column;
    }

    #sidebar {
        width: 280px;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        will-change: transform;
    }

    #sidebar.collapsed {
        width: 280px;
        transform: translateX(-100%);
    }

    #top-navbar {
        padding: 0 0.75rem;
        height: 56px;
        position: sticky;
        top: 0;
        z-index: 40;
    }

    #page-container {
        padding: 0.75rem;
        min-height: calc(100vh - 56px);
        overflow-x: hidden;
    }

    /* ═══════════════════════════════════
       PAGE HEADERS & ACTIONS
       Stack only the main page header and the search/button groups.
       ═══════════════════════════════════ */
    
    /* Target only top-level header rows (usually first children or near top) */
    #page-container > div[style*="display: flex"],
    #page-container > div > div[style*="justify-content: space-between"],
    .header-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    /* Search + Button groups should wrap but remain compact */
    #page-container div[style*="display: flex"][style*="gap"] {
        flex-wrap: wrap !important;
    }

    /* ═══════════════════════════════════
       CARD INTERNALS (REVERT STACKING)
       Ensure icons, badges, and action buttons inside cards stay horizontal.
       ═══════════════════════════════════ */
    .card [style*="display: flex"],
    .grid-dashboard .card [style*="display: flex"],
    .card div[style*="justify-content: space-between"],
    .card div[style*="justify-content: flex-end"],
    .card div[style*="align-items: center"] {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }

    /* Specifically fix the icon + badge row at the top of cards */
    .card > div[style*="justify-content: space-between"]:first-child {
        margin-bottom: 0.5rem !important;
    }

    /* ═══════════════════════════════════
       FILTER BARS
       ═══════════════════════════════════ */
    #page-container .card[style*="display: flex"][style*="align-items: center"] {
        flex-wrap: wrap !important;
        flex-direction: row !important; /* Filters should stay in a row/wrap */
        gap: 0.5rem !important;
        padding: 0.75rem !important;
    }

    #page-container .card[style*="display: flex"] > * {
        flex: 1 1 auto;
    }

    /* ═══════════════════════════════════
       SEARCH INPUTS & GROUPS
       ═══════════════════════════════════ */
    #page-container .input-group {
        width: 100% !important;
        flex: 1 1 100% !important;
    }

    #page-container .input-group .input,
    #page-container .search-input {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* ═══════════════════════════════════
       FORMS & GRIDS
       ═══════════════════════════════════ */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns: repeat(auto-fit"],
    [style*="grid-template-columns: repeat(auto-fill"] {
        grid-template-columns: 1fr !important;
    }

    /* ═══════════════════════════════════
       TYPOGRAPHY
       ═══════════════════════════════════ */
    h1, #page-container h2 { font-size: 1.15rem !important; }
    h3, .card h3 { font-size: 1rem !important; }
    p, .card p { font-size: 0.8rem !important; }

    /* ═══════════════════════════════════
       TABLES
       ═══════════════════════════════════ */
    .table-container {
        overflow-x: auto !important;
        border-radius: var(--radius);
    }
    table { min-width: 600px; }

    /* ═══════════════════════════════════
       MODALS
       ═══════════════════════════════════ */
    #page-container div[style*="position: fixed"][style*="z-index"] {
        align-items: flex-end !important;
    }

    #page-container div[style*="position: fixed"] > .card {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        margin: 0 !important;
        padding: 1.5rem !important;
    }

    /* ═══════════════════════════════════
       FILTER SELECTS — Remove max-width caps
       Pages set "max-width: 200px / 150px" on selects.
       ═══════════════════════════════════ */
    #page-container select[style*="max-width"] {
        max-width: 100% !important;
        flex: 1 1 calc(50% - 0.5rem) !important;
        min-width: 0 !important;
    }

    /* ═══════════════════════════════════
       INLINE WIDTH INPUTS — General override
       Any input/select inside page-container with a
       fixed width via inline style
       ═══════════════════════════════════ */
    #page-container input[style*="width:"],
    #page-container select[style*="width:"] {
        width: 100% !important;
    }

    /* ═══════════════════════════════════
       CARDS
       ═══════════════════════════════════ */
    .card {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }

    /* ═══════════════════════════════════
       GRIDS
       ═══════════════════════════════════ */
    .grid-dashboard {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    /* ═══════════════════════════════════
       BUTTONS — Touch-friendly sizing
       ═══════════════════════════════════ */
    .btn {
        padding: 0.55rem 0.9rem;
        font-size: 0.8rem;
        min-height: 40px;
    }

    .btn-sm {
        min-height: 36px;
        padding: 0.4rem 0.65rem;
    }

    /* ═══════════════════════════════════
       INPUTS — Prevent iOS zoom
       ═══════════════════════════════════ */
    .input, select.input, textarea.input {
        font-size: 16px !important;
        padding: 0.6rem 0.75rem;
        min-height: 44px;
    }

    /* ═══════════════════════════════════
       TABLES — Horizontal scroll
       ═══════════════════════════════════ */
    .table-container {
        border-radius: var(--radius-lg);
        -webkit-overflow-scrolling: touch;
        overflow-x: auto !important;
    }

    /* Also target cards that directly contain tables */
    .card:has(> table),
    .card:has(> .table-container),
    #page-container .card[style*="overflow: hidden"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 0 !important;
    }

    table {
        min-width: 580px;
    }

    th {
        padding: 0.6rem 0.75rem;
        font-size: 0.65rem;
        white-space: nowrap;
    }

    td {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }

    /* ═══════════════════════════════════
       BADGES
       ═══════════════════════════════════ */
    .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.45rem;
    }

    /* ═══════════════════════════════════
       AVATAR
       ═══════════════════════════════════ */
    .avatar {
        height: 2rem;
        width: 2rem;
        font-size: 0.7rem;
    }

    /* ═══════════════════════════════════
       SIDEBAR NAVIGATION
       ═══════════════════════════════════ */
    .nav-link {
        padding: 0.7rem 0.875rem;
        margin: 0.15rem 0.5rem;
        font-size: 0.85rem;
        min-height: 44px;
    }

    /* ═══════════════════════════════════
       MODALS — Bottom sheet style
       ═══════════════════════════════════ */
    .modal-container,
    #page-container div[style*="position: fixed"][style*="z-index"] {
        align-items: flex-end !important;
    }

    .modal-container > .card,
    #page-container div[style*="position: fixed"][style*="z-index"] > .card,
    #page-container div[style*="position: fixed"][style*="z-index"] > div[class*="card"] {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        margin: 0 !important;
        animation: slideFromBottom 0.3s var(--ease-out);
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
    }

    /* ═══════════════════════════════════
       INLINE GRID LAYOUTS — Stack on mobile
       For 2-column form grids, stat grids, etc.
       ═══════════════════════════════════ */
    #page-container [style*="grid-template-columns: 1fr 1fr"],
    #page-container [style*="grid-template-columns: repeat(auto-fit"],
    #page-container [style*="grid-template-columns: repeat(auto-fill"] {
        grid-template-columns: 1fr !important;
    }

    /* Spans that cross 2 cols should reset */
    #page-container [style*="grid-column: span 2"] {
        grid-column: span 1 !important;
    }

    /* ═══════════════════════════════════
       FLEX ROW WRAPPING — General
       Any flex row inside the page with flex-wrap hint
       ═══════════════════════════════════ */
    .header-actions {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* ═══════════════════════════════════
       TABS — Horizontal scroll
       ═══════════════════════════════════ */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        white-space: nowrap;
        min-height: 44px;
        font-size: 0.8rem !important;
    }

    /* ═══════════════════════════════════
       MAPPING ROWS (Form Builder)
       5-column grids become stacked
       ═══════════════════════════════════ */
    .mapping-row {
        grid-template-columns: 1fr !important;
        gap: 0.4rem !important;
    }

    /* ═══════════════════════════════════
       PREVENT HORIZONTAL OVERFLOW
       ═══════════════════════════════════ */
    #page-container * {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Allow tables to exceed for scroll */
    #page-container table,
    #page-container table * {
        max-width: none;
    }

    img, video, iframe, svg {
        max-width: 100%;
        height: auto;
    }
}

/* ── Slide-from-bottom animation for modals ── */
@keyframes slideFromBottom {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════
   SMALL MOBILE (≤ 480px)
   ═══════════════════════════════════ */
@media (max-width: 480px) {
    #page-container {
        padding: 0.5rem;
    }

    .card {
        padding: 0.875rem;
        border-radius: var(--radius);
    }

    .grid-dashboard {
        gap: 0.5rem;
    }

    h1, #page-container h2 {
        font-size: 1.15rem !important;
    }

    h3 {
        font-size: 0.95rem !important;
    }

    /* Stack filter bar items fully */
    #page-container select[style*="max-width"] {
        flex: 1 1 100% !important;
    }
}

.hidden {
    display: none !important;
}

.md\:hidden {
    display: inline-flex;
}

@media (min-width: 769px) {
    .md\:hidden {
        display: none;
    }
}

/* ═══════════════════════════════════
   BUTTONS
   ═══════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    font-weight: 500;
    font-size: 0.8125rem;
    transition: all var(--duration-fast) var(--ease-in-out);
    cursor: pointer;
    border: 1px solid transparent;
    gap: 0.4rem;
    line-height: 1.4;
    position: relative;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background-color: var(--primary) !important;
    color: white;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3), var(--shadow-xs);
}

.btn-primary:hover {
    background-color: var(--primary-hover) !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35), var(--shadow-sm);
}

.btn-primary:active {
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}

.btn-primary.active-filter {
    background-color: var(--primary);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background-color: var(--bg-body);
    border-color: var(--text-light);
    color: var(--text-main);
}

/* ═══════════════════════════════════
   CARDS
   ═══════════════════════════════════ */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--duration-normal) var(--ease-in-out),
        border-color var(--duration-normal) var(--ease-in-out);
}

/* ═══════════════════════════════════
   INPUTS
   ═══════════════════════════════════ */
.input {
    width: 100%;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 0.8125rem;
    line-height: 1.5;
    transition: border-color var(--duration-fast) var(--ease-in-out),
        box-shadow var(--duration-fast) var(--ease-in-out);
    outline: none;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input::placeholder {
    color: var(--text-placeholder);
}

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

input[type="search"],
.search-input {
    border-radius: var(--radius-full) !important;
    padding-left: 1rem;
}

/* ═══════════════════════════════════
   NAVIGATION
   ═══════════════════════════════════ */
.nav-link {
    display: flex;
    align-items: center;
    padding: 0.55rem 0.875rem;
    margin: 0.1rem 0.75rem;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--duration-fast) var(--ease-in-out);
    font-size: 0.835rem;
    position: relative;
}

.nav-link .material-symbols-outlined {
    margin-right: 0.65rem;
    font-size: 1.2rem;
    transition: transform var(--duration-fast) var(--ease-in-out);
}

.nav-link:hover {
    background-color: var(--primary-lighter);
    color: var(--text-main);
}

.nav-link:hover .material-symbols-outlined {
    transform: scale(1.05);
}

.nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

/* ═══════════════════════════════════
   TABLES
   ═══════════════════════════════════ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-surface);
    min-width: 600px;
}

th {
    background-color: var(--bg-body);
    text-align: left;
    padding: 0.75rem 1.15rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.75rem 1.15rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    font-size: 0.835rem;
    vertical-align: middle;
}

tbody tr {
    transition: background-color var(--duration-fast) var(--ease-in-out);
}

tbody tr:hover {
    background-color: var(--primary-lighter);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ═══════════════════════════════════
   BADGES
   ═══════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    gap: 0.3rem;
    letter-spacing: 0.01em;
    line-height: 1.4;
}

.badge-dot {
    width: 0.35rem;
    height: 0.35rem;
    border-radius: 50%;
}

.badge-success {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.badge-success .badge-dot {
    background-color: var(--success-text);
}

.badge-warning {
    background-color: var(--warning-bg);
    color: var(--warning-text);
}

.badge-warning .badge-dot {
    background-color: var(--warning-text);
}

.badge-info {
    background-color: var(--info-bg);
    color: var(--info-text);
}

/* ═══════════════════════════════════
   AVATAR
   ═══════════════════════════════════ */
.avatar {
    height: 2.25rem;
    width: 2.25rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* ═══════════════════════════════════
   ICONS
   ═══════════════════════════════════ */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
    font-size: 1.25rem;
}

.filled {
    font-variation-settings: 'FILL' 1;
}

/* ═══════════════════════════════════
   GRID LAYOUTS
   ═══════════════════════════════════ */
.grid-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

/* ═══════════════════════════════════
   MODAL / OVERLAY ANIMATIONS
   ═══════════════════════════════════ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, -48%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ═══════════════════════════════════
   MODALS
   ═══════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s var(--ease-out);
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s var(--ease-out);
}

.modal-content {
    background-color: var(--bg-surface);
    border-radius: var(--radius-2xl);
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-modal);
    border: 1px solid var(--border);
    animation: scaleIn 0.3s var(--ease-out);
    position: relative;
}

[data-theme="dark"] .modal-overlay {
    background-color: rgba(0, 0, 0, 0.6);
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast);
}

.close-modal-btn:hover {
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* ═══════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════ */
.text-secondary {
    color: var(--text-secondary);
}

.text-center {
    text-align: center;
}

/* Smooth loading skeleton pulse */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.loading-pulse {
    animation: pulse 1.5s var(--ease-in-out) infinite;
}

/* Focus-visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Print styles */
@media print {

    #sidebar,
    #top-navbar {
        display: none !important;
    }

    #page-container {
        padding: 0 !important;
    }
}