/* ============================================================
   RVIBS HRMS - Design System
   Brand: #0D4F81 (Primary Blue) | #EC268F (Accent Pink)
   Fonts: Fraunces (Display) | Inter (Body)
   ============================================================ */

/* ----- CSS Custom Properties / Design Tokens ----- */
:root {
    /* Brand Colors */
    --color-primary: #0D4F81;
    --color-primary-dark: #0A3D66;
    --color-primary-light: #1470B8;
    --color-primary-50: #E8F1F8;
    --color-primary-100: #D0E2F0;
    --color-primary-200: #A7C5E1;
    --color-primary-300: #7EA8D2;
    --color-primary-400: #4D8ABF;
    --color-primary-500: #2E76A8;
    --color-primary-600: #1A5F92;

    --color-accent: #EC268F;
    --color-accent-dark: #D11E7C;
    --color-accent-light: #F449A3;
    --color-accent-50: #FDF0F6;
    --color-accent-100: #FAE1EE;
    --color-accent-200: #F5C3D9;

    /* Semantic Colors */
    --color-success: #16A34A;
    --color-success-light: #DCFCE7;
    --color-warning: #EAB308;
    --color-warning-light: #FEF9C3;
    --color-danger: #DC2626;
    --color-danger-light: #FEE2E2;
    --color-info: #2563EB;
    --color-info-light: #DBEAFE;

    /* Neutrals */
    --color-dark: #1A1D29;
    --color-text: #2D3142;
    --color-text-muted: #6B7280;
    --color-text-light: #9CA3AF;
    --color-border: #E5E7EB;
    --color-border-light: #F3F4F6;
    --color-bg: #F8FAFC;
    --color-bg-card: #FFFFFF;
    --color-bg-hover: #F9FAFB;
    --color-sidebar: #0D4F81;
    --color-sidebar-item: rgba(255, 255, 255, 0.08);

    /* Typography */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Font Sizes */
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-base: 0.9375rem;
    --fs-md: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.25rem;
    --fs-2xl: 1.5rem;
    --fs-3xl: 1.875rem;
    --fs-4xl: 2.25rem;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 0.75rem;
    --space-base: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 2px 4px 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.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.06);
    --shadow-primary: 0 4px 14px rgba(13, 79, 129, 0.3);
    --shadow-accent: 0 4px 14px rgba(236, 38, 143, 0.3);

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    --content-max-width: 1280px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-overlay: 1000;
    --z-modal: 2000;
    --z-toast: 3000;
    --z-fab: 4000;
}

/* ----- Reset & Base ----- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-base);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--color-dark);
    line-height: 1.3;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
h6 { font-size: var(--fs-base); font-weight: 700; }

a { color: var(--color-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-primary-light); }

img { max-width: 100%; height: auto; display: block; }

button, input, textarea, select { font-family: inherit; font-size: inherit; }

/* ----- Layout Structure ----- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sticky);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
}

.sidebar__brand {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar__brand-logo {
    display: block;
    width: 100%;
    height: auto;
    padding: 0.5rem;
    background: #fff;
    border-radius: var(--radius-md);
}

.sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}

.sidebar__section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.75rem 0.75rem 0.5rem;
    font-weight: 600;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.sidebar__link:hover {
    background: var(--color-sidebar-item);
    color: #fff;
}

.sidebar__link.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--color-accent);
}

.sidebar__link-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 1.75;
}

.sidebar__link-badge {
    margin-left: auto;
    background: var(--color-accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

.sidebar__user {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar__user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.sidebar__user-info {
    flex: 1;
    min-width: 0;
}

.sidebar__user-name {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar__user-role {
    font-size: var(--fs-xs);
    color: rgba(255, 255, 255, 0.5);
}

/* ----- Main Content Area ----- */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ----- Top Header Bar ----- */
.topbar {
    height: var(--header-height);
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.topbar__toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    padding: 0.5rem;
}

.topbar__title {
    flex: 1;
}

.topbar__title h2 {
    font-size: var(--fs-lg);
    margin: 0;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar__search {
    position: relative;
}

.topbar__search input {
    width: 280px;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    background: var(--color-bg);
    transition: all var(--transition-fast);
}

.topbar__search input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-50);
    background: #fff;
}

.topbar__search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-light);
    width: 18px;
    height: 18px;
}

/* ----- Notification Bell ----- */
.notif-bell {
    position: relative;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.notif-bell:hover { background: var(--color-bg-hover); }

.notif-bell__icon {
    width: 22px;
    height: 22px;
    color: var(--color-text-muted);
}

.notif-bell__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--color-accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ----- Dropdown Panel ----- */
.dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    max-height: 500px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: var(--z-dropdown);
}

.dropdown-panel.open { display: flex; }

.dropdown-panel__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dropdown-panel__header h3 {
    font-size: var(--fs-md);
    margin: 0;
}

.dropdown-panel__body {
    overflow-y: auto;
    flex: 1;
}

.dropdown-panel__footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

/* ----- Content Area ----- */
.content {
    flex: 1;
    padding: 1.5rem;
}

.content__header {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.content__header-title h2 {
    font-size: var(--fs-2xl);
    margin-bottom: 0.25rem;
}

.content__header-title p {
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
}

/* ----- Cards ----- */
.card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card__header h3 {
    font-size: var(--fs-md);
    margin: 0;
}

.card__body {
    padding: 1.25rem;
}

.card--no-pad .card__body {
    padding: 0;
}

/* ----- Stat Cards ----- */
.stat-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card__icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card__icon svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.75;
}

.stat-card__value {
    font-family: var(--font-display);
    font-size: var(--fs-3xl);
    font-weight: 700;
    line-height: 1;
    color: var(--color-dark);
}

.stat-card__label {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    font-weight: 500;
}

.stat-card__trend {
    font-size: var(--fs-xs);
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-card__trend.up { color: var(--color-success); }
.stat-card__trend.down { color: var(--color-danger); }

/* ----- Grid System ----- */
.grid {
    display: grid;
    gap: 1.25rem;
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--sidebar { grid-template-columns: 1fr 320px; }

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--color-primary);
    color: #fff;
}
.btn--primary:hover {
    background: var(--color-primary-dark);
    color: #fff;
    box-shadow: var(--shadow-primary);
}

.btn--accent {
    background: var(--color-accent);
    color: #fff;
}
.btn--accent:hover {
    background: var(--color-accent-dark);
    color: #fff;
    box-shadow: var(--shadow-accent);
}

.btn--outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}
.btn--outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-50);
}

.btn--ghost {
    background: transparent;
    color: var(--color-text-muted);
}
.btn--ghost:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.btn--danger {
    background: var(--color-danger);
    color: #fff;
}
.btn--danger:hover {
    background: #B91C1C;
    color: #fff;
}

.btn--success {
    background: var(--color-success);
    color: #fff;
}
.btn--success:hover {
    background: #15803D;
    color: #fff;
}

.btn--sm { padding: 0.4rem 0.85rem; font-size: var(--fs-xs); }
.btn--lg { padding: 0.75rem 1.75rem; font-size: var(--fs-md); }
.btn--block { width: 100%; justify-content: center; }
.btn--icon { padding: 0.5rem; }

.btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* ----- Forms ----- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.form-label .req { color: var(--color-accent); }

.form-control {
    width: 100%;
    padding: 0.65rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    color: var(--color-text);
    background: #fff;
    transition: all var(--transition-fast);
    font-family: var(--font-body);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-50);
}

.form-control::placeholder { color: var(--color-text-light); }

textarea.form-control {
    min-height: 100px;
    resize: vertical;
    line-height: 1.6;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 18px;
    padding-right: 2.5rem;
}

.form-hint {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin-top: 0.4rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ----- Tables ----- */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}

thead th {
    text-align: left;
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-bg-hover);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

tbody td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text);
    vertical-align: middle;
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: var(--color-primary-50);
}

tbody tr:last-child td {
    border-bottom: none;
}

.table-avatar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.table-avatar img {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.table-avatar__initials {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-xs);
    font-weight: 600;
    flex-shrink: 0;
}

/* ----- Badges ----- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.7rem;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1.4;
}

.badge-success { background: var(--color-success-light); color: #15803D; }
.badge-warning { background: var(--color-warning-light); color: #B45309; }
.badge-danger { background: var(--color-danger-light); color: #B91C1C; }
.badge-info { background: var(--color-info-light); color: #1D4ED8; }
.badge-primary { background: var(--color-primary-50); color: var(--color-primary); }
.badge-accent { background: var(--color-accent-50); color: var(--color-accent); }
.badge-secondary { background: var(--color-bg-hover); color: var(--color-text-muted); }

/* ----- Alerts ----- */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert--success { background: var(--color-success-light); color: #15803D; }
.alert--error { background: var(--color-danger-light); color: #B91C1C; }
.alert--warning { background: var(--color-warning-light); color: #B45309; }
.alert--info { background: var(--color-info-light); color: #1D4ED8; }

/* ----- Modal ----- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn var(--transition);
}

.modal--lg { max-width: 800px; }
.modal--sm { max-width: 420px; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal__header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal__header h3 {
    font-size: var(--fs-lg);
    margin: 0;
}

.modal__close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal__close:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.modal__body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ----- Tabs ----- */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab {
    padding: 0.75rem 1.25rem;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab:hover { color: var(--color-primary); }
.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ----- Role Selector ----- */
.role-tabs {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.role-tab {
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    color: var(--color-text-muted);
}

.role-tab:hover { border-color: var(--color-primary); color: var(--color-primary); }
.role-tab.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* ----- AI Floating Button & Chat ----- */
.ai-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(13, 79, 129, 0.35);
    z-index: var(--z-fab);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.ai-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 32px rgba(13, 79, 129, 0.4);
}

.ai-fab svg { width: 26px; height: 26px; }

.ai-fab__pulse {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    background: var(--color-accent);
    animation: aiPulse 2s ease-out infinite;
    z-index: -1;
}

@keyframes aiPulse {
    0% { opacity: 0.6; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.6); }
}

.ai-chat {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 400px;
    max-height: 600px;
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    display: none;
    flex-direction: column;
    z-index: var(--z-fab);
    overflow: hidden;
    animation: aiChatIn var(--transition);
}

.ai-chat.open { display: flex; }

@keyframes aiChatIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-chat__header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-chat__header-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat__header h4 {
    color: #fff;
    margin: 0;
    font-size: var(--fs-md);
    font-family: var(--font-body);
    font-weight: 600;
}

.ai-chat__header span {
    font-size: var(--fs-xs);
    color: rgba(255, 255, 255, 0.7);
}

.ai-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    background: var(--color-bg);
}

.ai-chat__msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    font-size: var(--fs-sm);
    line-height: 1.5;
    animation: msgIn var(--transition);
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-chat__msg--user {
    background: var(--color-primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-chat__msg--assistant {
    background: #fff;
    color: var(--color-text);
    align-self: flex-start;
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 4px;
}

.ai-chat__msg--assistant pre {
    background: var(--color-bg);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: var(--fs-xs);
    margin-top: 0.5rem;
}

.ai-chat__typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.ai-chat__typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-light);
    animation: typing 1.4s infinite;
}

.ai-chat__typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-chat__typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.ai-chat__input-area {
    padding: 0.75rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 0.5rem;
    background: #fff;
}

.ai-chat__input {
    flex: 1;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.4;
}

.ai-chat__input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-50);
}

.ai-chat__send {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.ai-chat__send:hover { background: var(--color-primary-dark); }
.ai-chat__send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----- Empty States ----- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-text-muted);
}

.empty-state__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--color-text-light);
}

.empty-state__title {
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.empty-state__text {
    font-size: var(--fs-sm);
    max-width: 400px;
    margin: 0 auto 1.5rem;
}

/* ----- Login Page ----- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 50%, #082F4F 100%);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(236, 38, 143, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.auth-page::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(20, 112, 184, 0.2) 0%, transparent 70%);
    border-radius: 50%;
}

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
}

.auth-card__logo {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto 2rem;
}

.auth-card__panel {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-xl);
}

.auth-card__panel h2 {
    font-size: var(--fs-xl);
    margin-bottom: 0.5rem;
}

.auth-card__panel > p {
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
    margin-bottom: 1.5rem;
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: #fff;
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.google-btn:hover {
    background: var(--color-bg-hover);
    box-shadow: var(--shadow-sm);
}

.google-btn svg { width: 22px; height: 22px; }

/* ----- Progress / Timeline ----- */
.timeline {
    position: relative;
    padding-left: 1.75rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}

.timeline__item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline__item:last-child { padding-bottom: 0; }

.timeline__dot {
    position: absolute;
    left: -1.75rem;
    top: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--color-primary);
}

.timeline__item--success .timeline__dot { border-color: var(--color-success); }
.timeline__item--warning .timeline__dot { border-color: var(--color-warning); }
.timeline__item--danger .timeline__dot { border-color: var(--color-danger); }

.timeline__content {
    font-size: var(--fs-sm);
}

.timeline__content strong {
    display: block;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.timeline__content span {
    color: var(--color-text-muted);
    font-size: var(--fs-xs);
}

/* ----- Progress Bar ----- */
.progress {
    height: 8px;
    background: var(--color-border-light);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress__bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress__bar--accent {
    background: linear-gradient(90deg, var(--color-accent), var(--color-accent-light));
}

/* ----- Avatar ----- */
.avatar {
    border-radius: var(--radius-full);
    object-fit: cover;
}

.avatar--sm { width: 28px; height: 28px; }
.avatar--md { width: 40px; height: 40px; }
.avatar--lg { width: 56px; height: 56px; }
.avatar--xl { width: 80px; height: 80px; }

.avatar--initials {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: #fff;
    font-weight: 600;
}

/* ----- Toast Notifications ----- */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    padding: 1rem 1.25rem;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--color-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: var(--fs-sm);
    min-width: 300px;
    max-width: 400px;
    animation: toastIn var(--transition);
}

.toast--success { border-left-color: var(--color-success); }
.toast--error { border-left-color: var(--color-danger); }
.toast--warning { border-left-color: var(--color-warning); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ----- File Upload ----- */
.file-upload {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.file-upload:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-50);
}

.file-upload input[type="file"] { display: none; }

.file-upload__icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    color: var(--color-text-light);
}

.file-upload__text {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
}

.file-upload__text strong { color: var(--color-primary); }

/* ----- Misc Utilities ----- */
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.font-display { font-family: var(--font-display); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.w-full { width: 100%; }
.rounded-full { border-radius: var(--radius-full); }
.cursor-pointer { cursor: pointer; }
.relative { position: relative; }
.absolute { position: absolute; }

/* ----- Pagination ----- */
.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem;
}

.pagination button, .pagination a {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    color: var(--color-text);
    background: #fff;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination button:hover, .pagination a:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.pagination .active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* ----- Divider ----- */
.divider {
    height: 1px;
    background: var(--color-border);
    margin: 1.5rem 0;
    border: none;
}

.divider--text {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--color-text-muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.divider--text::before,
.divider--text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* ============================================================
   RESPONSIVE DESIGN
   Native look on mobile and desktop
   ============================================================ */

/* Tablet & below */
@media (max-width: 1024px) {
    .grid--4 { grid-template-columns: repeat(2, 1fr); }
    .grid--sidebar { grid-template-columns: 1fr; }
    .topbar__search input { width: 200px; }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }

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

    .main-area {
        margin-left: 0;
    }

    .topbar {
        padding: 0 1rem;
    }

    .topbar__toggle {
        display: flex;
    }

    .topbar__search {
        display: none;
    }

    .content {
        padding: 1rem;
    }

    .grid--2, .grid--3, .grid--4 {
        grid-template-columns: 1fr;
    }

    .grid--sidebar {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .content__header {
        flex-direction: column;
    }

    .ai-chat {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 88px;
        max-height: calc(100vh - 120px);
    }

    .ai-fab {
        bottom: 16px;
        right: 16px;
    }

    .modal {
        max-width: 100%;
        margin: 0.5rem;
    }

    .dropdown-panel {
        width: calc(100vw - 32px);
        right: -8px;
    }

    .table-wrap {
        -webkit-overflow-scrolling: touch;
    }

    thead th {
        font-size: 0.65rem;
    }

    .tabs {
        gap: 0;
    }

    .tab {
        padding: 0.6rem 0.85rem;
        font-size: var(--fs-xs);
    }

    h1 { font-size: var(--fs-2xl); }
    h2 { font-size: var(--fs-xl); }
    h3 { font-size: var(--fs-lg); }

    .auth-card__panel {
        padding: 1.75rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .stat-card__value {
        font-size: var(--fs-2xl);
    }

    .content__header-title h2 {
        font-size: var(--fs-xl);
    }

    .btn {
        padding: 0.55rem 1rem;
        font-size: var(--fs-xs);
    }

    .btn--block { width: 100%; }

    .role-tab {
        padding: 0.5rem 0.85rem;
        font-size: var(--fs-xs);
    }
}

/* Sidebar Backdrop (mobile) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-sticky) - 1);
}

.sidebar-backdrop.open {
    display: block;
}

/* Mobile bottom nav */
.mobile-nav {
    display: none;
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid var(--color-border);
        z-index: var(--z-sticky);
        justify-content: space-around;
        padding: 0.5rem 0;
    }

    .mobile-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        font-size: 0.65rem;
        color: var(--color-text-muted);
        padding: 0.35rem 0.5rem;
        text-decoration: none;
    }

    .mobile-nav a.active {
        color: var(--color-primary);
    }

    .mobile-nav svg {
        width: 22px;
        height: 22px;
    }

    .content {
        padding-bottom: 4.5rem;
    }
}

/* Print styles */
@media print {
    .sidebar, .topbar, .ai-fab, .ai-chat, .mobile-nav { display: none !important; }
    .main-area { margin-left: 0; }
}
/* ----- Notification Items ----- */
.notif-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.notif-item:hover { background: var(--color-primary-50); }
.notif-item.unread { background: var(--color-accent-50); }
.notif-item.unread:hover { background: var(--color-accent-100); }

.notif-item__icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--color-primary-50);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-item__body { flex: 1; min-width: 0; }
.notif-item__title { font-size: var(--fs-sm); font-weight: 600; color: var(--color-text); }
.notif-item__msg { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 2px; line-height: 1.5; }
.notif-item__time { font-size: var(--fs-xs); color: var(--color-text-light); margin-top: 4px; }

/* ----- Contract Expiry Reminder Banner ----- */
.expiry-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--color-warning-light), #FFF7E0);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-warning);
    margin-bottom: 1rem;
}

.expiry-banner__icon {
    width: 40px;
    height: 40px;
    background: var(--color-warning);
    color: #fff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.expiry-banner__content { flex: 1; }
.expiry-banner__title { font-size: var(--fs-sm); font-weight: 600; color: #92400E; }
.expiry-banner__text { font-size: var(--fs-xs); color: #78350F; }

/* ----- Scrollbar Styling ----- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--color-border-light); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-light); }

.sidebar__nav::-webkit-scrollbar { width: 4px; }
.sidebar__nav::-webkit-scrollbar-track { background: transparent; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: var(--radius-full); }

/* ----- Focus visible for keyboard nav ----- */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ----- Skeleton loader ----- */
.skeleton {
    background: linear-gradient(90deg, var(--color-bg-hover) 25%, var(--color-border-light) 50%, var(--color-bg-hover) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
