/* ======================================== */
/* === Global Styles & Variables ========== */
/* ======================================== */

/* Import modern, clean fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lato:wght@400;700&display=swap');

:root {
    /* Modern Color Palette - Professional and clean */
    --primary-color: #2563eb; /* Modern blue */
    --primary-hover-color: #1e40af; /* Darker blue */
    --primary-light: #dbeafe; /* Light blue background */
    --secondary-color: #64748b; /* Slate grey */
    --secondary-hover: #475569;
    --accent-color: #8b5cf6; /* Purple accent */
    --accent-hover: #7c3aed;

    /* Neutrals */
    --light-grey: #f8fafc; /* Almost white */
    --medium-grey: #e2e8f0; /* Borders */
    --dark-grey: #334155; /* Text headings */
    --text-color: #1e293b; /* Main text - darker */
    --text-muted: #64748b; /* Muted text */
    --white-color: #ffffff;
    --background-color: #f1f5f9; /* Slightly tinted background */

    /* Feedback Colors */
    --success-bg: #d1fae5;
    --success-border: #6ee7b7;
    --success-text: #065f46;
    --success-color: #10b981;
    --success-hover: #059669;

    --error-bg: #fee2e2;
    --error-border: #fca5a5;
    --error-text: #991b1b;
    --delete-color: #ef4444;
    --delete-hover-color: #dc2626;

    --warning-bg: #fef3c7;
    --warning-border: #fcd34d;
    --warning-text: #92400e;

    --info-color: #06b6d4;
    --info-bg: #cffafe;
    --info-border: #67e8f9;
    --info-text: #164e63;

    --save-color: #10b981;
    --save-hover-color: #059669;

    /* Typography */
    --body-font: 'Inter', 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --heading-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --base-font-size: 16px;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Spacing & Layout */
    --border-radius: 0.5rem; /* Slightly more rounded */
    --border-radius-lg: 0.75rem;
    --border-radius-sm: 0.375rem;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --box-shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --box-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --box-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --transition-speed: 0.2s; /* Smooth transitions */
    --transition-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--body-font);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    font-size: var(--base-font-size);
    font-weight: var(--font-weight-normal);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Overall page container */
.page-container {
    width: 100%;
    max-width: 1320px; /* Generous max-width */
    margin: 0 auto; /* Centers the container */
    padding: 0 15px; /* Horizontal padding */
    flex-grow: 1; /* Allow content area to grow */
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
     font-family: var(--heading-font);
     font-weight: var(--font-weight-bold);
     color: var(--dark-grey);
     margin-top: 1.5em;
     margin-bottom: 0.8em;
     line-height: 1.3;
     letter-spacing: -0.025em;
}

h1 {
    font-size: 2.25rem;
    font-weight: var(--font-weight-bold);
}
h2 {
    font-size: 1.875rem;
    font-weight: var(--font-weight-semibold);
}
h3 {
    font-size: 1.5rem;
    font-weight: var(--font-weight-semibold);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}
a:hover {
    color: var(--primary-hover-color);
    text-decoration: none;
}
p {
    margin-bottom: 1rem;
}

hr {
    border: none;
    border-top: 1px solid var(--medium-grey);
    margin: 2rem 0;
    opacity: 0.5;
}


/* ======================================== */
/* === Sidebar Navigation ================ */
/* ======================================== */

/* CSS Variables for sidebar */
:root {
    --sidebar-width-collapsed: 64px;
    --sidebar-width-expanded: 240px;
    --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --mobile-header-height: 56px;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1040;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Main Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width-collapsed);
    background-color: var(--white-color);
    border-right: 1px solid var(--medium-grey);
    box-shadow: var(--box-shadow);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: width var(--sidebar-transition);
    overflow: hidden;
}

/* Expanded state */
.sidebar.expanded,
.sidebar.hover-expanded {
    width: var(--sidebar-width-expanded);
}

/* Sidebar Header */
.sidebar-header {
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--medium-grey);
    min-height: 64px;
}

.sidebar.expanded .sidebar-header,
.sidebar.hover-expanded .sidebar-header {
    justify-content: flex-start;
    padding-left: 16px;
}

/* Toggle Button */
.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

.sidebar-toggle:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.sidebar-toggle:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Sidebar Logo */
.sidebar-logo {
    padding: 16px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--medium-grey);
}

.sidebar-logo a {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo .logo-full {
    height: 32px;
    width: auto;
    max-width: 40px;
    object-fit: contain;
    object-position: left center;
    overflow: hidden;
    transition: max-width var(--sidebar-transition);
}

.sidebar-logo .logo-icon {
    display: none; /* Hidden by default since we don't have an icon version */
}

.sidebar.expanded .sidebar-logo .logo-full,
.sidebar.hover-expanded .sidebar-logo .logo-full {
    max-width: 180px;
}

/* When icon exists, use it in collapsed state */
.sidebar-logo .logo-icon:not([style*="display: none"]) {
    display: block;
    height: 32px;
    width: 32px;
    object-fit: contain;
}

.sidebar-logo .logo-icon:not([style*="display: none"]) + .logo-full {
    display: none;
}

.sidebar.expanded .sidebar-logo .logo-icon,
.sidebar.hover-expanded .sidebar-logo .logo-icon {
    display: none;
}

.sidebar.expanded .sidebar-logo .logo-icon + .logo-full,
.sidebar.hover-expanded .sidebar-logo .logo-icon + .logo-full {
    display: block;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    margin: 2px 8px;
}

/* Navigation Links */
.nav-link {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--border-radius);
    color: var(--text-color);
    text-decoration: none;
    transition: all var(--transition-speed) ease;
    white-space: nowrap;
    overflow: hidden;
}

.nav-link:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
    text-decoration: none;
}

.nav-link.active {
    background-color: var(--primary-color);
    color: var(--white-color);
    box-shadow: var(--box-shadow-sm);
}

.nav-link.active:hover {
    background-color: var(--primary-hover-color);
    color: var(--white-color);
}

/* Nav Icon */
.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
}

/* Nav Text */
.nav-text {
    margin-left: 12px;
    font-size: 0.9375rem;
    font-weight: var(--font-weight-medium);
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.sidebar.expanded .nav-text,
.sidebar.hover-expanded .nav-text {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* Sidebar Footer (Logout) */
.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--medium-grey);
    margin-top: auto;
}

.sidebar-footer .nav-link {
    margin: 0;
}

.sidebar-footer .logout-link {
    color: var(--secondary-color);
}

.sidebar-footer .logout-link:hover {
    background-color: var(--error-bg);
    color: var(--delete-color);
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-header-height);
    background-color: var(--white-color);
    border-bottom: 1px solid var(--medium-grey);
    box-shadow: var(--box-shadow-sm);
    z-index: 1030;
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
}

.mobile-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-toggle:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.mobile-logo img {
    height: 32px;
    width: auto;
}

/* Body layout adjustments - only when sidebar is present */
body.has-sidebar {
    padding-left: var(--sidebar-width-collapsed);
    transition: padding-left var(--sidebar-transition);
}

body.has-sidebar.sidebar-expanded {
    padding-left: var(--sidebar-width-expanded);
}

/* Page container adjustments */
.page-container {
    max-width: calc(1320px + 30px);
    padding: 0 15px;
}

/* ======================================== */
/* === Sidebar Responsive Behavior ======= */
/* ======================================== */

@media (max-width: 768px) {
    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width-expanded);
    }

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

    /* Disable hover expand on mobile */
    .sidebar.hover-expanded {
        width: var(--sidebar-width-expanded);
    }

    /* Show mobile header */
    .mobile-header {
        display: flex;
    }

    /* Remove body padding on mobile */
    body.has-sidebar {
        padding-left: 0;
        padding-top: var(--mobile-header-height);
    }

    body.has-sidebar.sidebar-expanded {
        padding-left: 0;
    }

    /* Show nav text in mobile drawer */
    .sidebar .nav-text {
        opacity: 1;
        transform: translateX(0);
        pointer-events: auto;
    }

    /* Show full logo in mobile drawer */
    .sidebar .sidebar-logo .logo-full {
        max-width: 180px;
    }
}


/* ======================================== */
/* === Main Content Area & Containers ===== */
/* ======================================== */

/* General content area within the page container */
.content-area {
    padding: 25px 0; /* Vertical padding */
    flex-grow: 1; /* Takes up remaining space */
}

/* Card-like containers for content sections */
.card,
.dashboard-container,
.content-container,
.login-container {
    background: var(--white-color);
    border: 1px solid var(--medium-grey);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
    margin-bottom: 2rem;
    overflow: visible;
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

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

/* Specific Centering for Login Container */
.login-container {
    max-width: 500px; /* Adjust max-width as needed */
    margin-left: auto;
    margin-right: auto;
    margin-top: 40px; /* Add some top margin */
}

.card-header,
.content-container > h1,
.login-container > h1 {
    padding: 1.5rem 2rem;
    margin: 0;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--white-color) 100%);
    border-bottom: 2px solid var(--primary-color);
    font-size: 1.75rem;
    font-weight: var(--font-weight-bold);
    color: var(--primary-color);
    text-align: center;
    letter-spacing: -0.025em;
}
/* Reset margin for other headers within content-container if needed */
.content-container > h2,
.content-container > h3 {
     margin-top: 1.5em; /* Restore default margin */
     text-align: left; /* Keep sub-headers left-aligned */
}

.card-header h2, .card-header h3 { /* Nested headers within a card header */
    font-size: 1.2rem;
    color: var(--dark-grey);
    text-align: left;
    padding: 0;
    margin-bottom: 0;
    border-bottom: none;
    background-color: transparent;
}

/* Padding for container bodies */
.card-body,
.content-container > *:not(h1),
.login-container > *:not(h1) {
    padding: 2rem;
}

/* Remove top margin from first element after a styled header */
.card-header + .card-body > *:first-child,
.content-container > h1 + *,
.login-container > h1 + * {
     margin-top: 0;
}


/* ======================================== */
/* === Buttons (Refined) ================== */
/* ======================================== */

/* Base button style */
.button,
button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: var(--font-weight-semibold);
    line-height: 1.5;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    transition: all var(--transition-speed) ease;
    text-decoration: none;
    margin: 0.25rem;
    position: relative;
    overflow: hidden;
}

.button::before,
button::before,
input[type="submit"]::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.button:active::before,
button:active::before,
input[type="submit"]:active::before {
    width: 300px;
    height: 300px;
}

.button:focus,
button:focus,
input[type="button"]:focus,
input[type="submit"]:focus {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
input[type="button"], input[type="submit"], input[type="reset"] {
    appearance: button;
}

/* Primary Button */
.button,
button[type="submit"],
input[type="submit"],
.button-primary {
    color: var(--white-color);
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: var(--box-shadow-sm);
}
.button:hover,
button[type="submit"]:hover,
input[type="submit"]:hover,
.button-primary:hover {
    color: var(--white-color);
    background-color: var(--primary-hover-color);
    border-color: var(--primary-hover-color);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

/* Secondary / Cancel Button */
.button.cancel-button,
button[type="button"],
input[type="button"],
input[type="reset"],
.button-secondary {
    color: var(--text-color);
    background-color: var(--white-color);
    border-color: var(--medium-grey);
    box-shadow: var(--box-shadow-sm);
}
.button.cancel-button:hover,
button[type="button"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
.button-secondary:hover {
    color: var(--text-color);
    background-color: var(--light-grey);
    border-color: var(--secondary-color);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

/* Delete Button */
.button.delete-button,
.button.delete-button-inline,
.button-danger {
    color: var(--white-color);
    background-color: var(--delete-color);
    border-color: var(--delete-color);
    box-shadow: var(--box-shadow-sm);
}
.button.delete-button:hover,
.button.delete-button-inline:hover,
.button-danger:hover {
    color: var(--white-color);
    background-color: var(--delete-hover-color);
    border-color: var(--delete-hover-color);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

/* Disabled Button */
.button.button-disabled,
.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: auto;
    transform: none !important;
    box-shadow: none !important;
}

/* Save Button */
.button.save-button,
.button-success {
    color: var(--white-color);
    background-color: var(--save-color);
    border-color: var(--save-color);
    box-shadow: var(--box-shadow-sm);
}
.button.save-button:hover,
.button-success:hover {
    color: var(--white-color);
    background-color: var(--save-hover-color);
    border-color: var(--save-hover-color);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

/* Smaller Buttons */
.button-sm,
.button.inline-button,
.button.edit-button-inline,
.button.delete-button-inline,
.save-button {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: var(--border-radius-sm);
}

/* Button group styling */
.action-buttons,
.action-buttons-inline {
     margin-bottom: 1rem;
     display: flex;
     flex-wrap: wrap;
     gap: 10px;
}
.action-buttons-inline { margin-bottom: 0; }


/* ======================================== */
/* === Forms (Refined) ==================== */
/* ======================================== */

form {
    margin-bottom: 1.5rem;
}

fieldset {
    border: 2px solid var(--medium-grey);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius-lg);
    background-color: var(--light-grey);
    transition: border-color var(--transition-speed) ease;
}

fieldset:focus-within {
    border-color: var(--primary-color);
    background-color: var(--white-color);
}

legend {
    font-weight: var(--font-weight-bold);
    color: var(--primary-color);
    padding: 0 0.75rem;
    font-size: 1.125rem;
    margin-left: 0.5rem;
    margin-bottom: 1rem;
    background-color: var(--white-color);
    border-radius: var(--border-radius);
}

form label {
    font-weight: var(--font-weight-semibold);
    margin-bottom: 0.5rem;
    display: inline-block;
    color: var(--dark-grey);
    font-size: 0.9375rem;
}

form input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]),
form textarea,
form select {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-weight: var(--font-weight-normal);
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--white-color);
    background-clip: padding-box;
    border: 2px solid var(--medium-grey);
    appearance: none;
    border-radius: var(--border-radius);
    transition: all var(--transition-speed) ease;
    margin-bottom: 1rem;
}

form input:read-only {
    background-color: var(--light-grey);
    cursor: not-allowed;
    opacity: 0.6;
    border-style: dashed;
}

form input:focus,
form textarea:focus,
form select:focus {
    color: var(--text-color);
    background-color: var(--white-color);
    border-color: var(--primary-color);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

form textarea {
    min-height: 120px;
    resize: vertical;
    font-family: var(--body-font);
}

form select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
}

form small {
    display: block;
    margin-top: -0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875em;
    color: var(--text-muted);
}

/* ======================================== */
/* === Tables (Refined) =================== */
/* ======================================== */

/* Wrapper for horizontal scrolling */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    background-color: var(--white-color);
    border: 1px solid var(--medium-grey);
    box-shadow: var(--box-shadow-sm);
}



.data-table th,
.data-table td {
    padding: 0.875rem 1.125rem;
    border: none;
    border-bottom: 1px solid var(--medium-grey);
    text-align: left;
    vertical-align: middle;
    line-height: 1.5;
    overflow-wrap: break-word;
}

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

.data-table thead th {
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--light-grey) 100%);
    font-weight: var(--font-weight-bold);
    color: var(--primary-color);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    vertical-align: middle;
    border-bottom: 2px solid var(--primary-color);
}

.data-table thead th[data-sortable="true"],
.data-table thead th[data-column] {
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-speed) ease;
}

.data-table thead th[data-sortable="true"]:hover,
.data-table thead th[data-column]:hover {
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-hover-color) 100%);
    color: var(--white-color);
}

/* Row Striping & Hover */
.data-table tbody tr:nth-of-type(odd) {
    background-color: var(--white-color);
}

.data-table tbody tr:nth-of-type(even) {
    background-color: var(--light-grey);
}

.data-table tbody tr {
    transition: all var(--transition-speed) ease;
}

.data-table tbody tr:hover {
    background-color: var(--primary-light);
    cursor: pointer;
}

/* Footer styling */
.data-table tfoot td {
    font-weight: var(--font-weight-bold);
    background: linear-gradient(180deg, var(--light-grey) 0%, var(--medium-grey) 100%);
    border-top: 3px solid var(--primary-color);
    color: var(--dark-grey);
    font-size: 0.9375rem;
}

/* Inline Editing Styles */
.data-table td.editing { padding: 0; }
.data-table td .edit-input { width: 100%; box-sizing: border-box; padding: .5rem .75rem; margin: 0; border: 1px solid var(--primary-color); border-radius: 0; font-family: inherit; font-size: inherit; line-height: 1.5; }
.data-table td .edit-input:focus { outline: none; box-shadow: none; }
.data-table td.saving { background-color: var(--warning-bg) !important; }
.data-table td.update-success { background-color: var(--success-bg) !important; transition: background-color 0.5s ease; }
.data-table td.update-error { background-color: var(--error-bg) !important; }
.inline-error-message { color: var(--error-text); font-size: 0.8em; padding: 2px 5px; margin-top: 2px; display: block; }

/* Sorting Indicators */
th .sort-indicator {
    margin-left: 0.375rem;
    font-size: 0.75em;
    color: var(--text-muted);
    transition: color var(--transition-speed) ease;
}

th.sorted-asc .sort-indicator,
th.sorted-desc .sort-indicator {
    color: var(--primary-color);
}

th[data-column]::after {
    content: '⇅';
    margin-left: 0.5rem;
    opacity: 0.3;
    font-size: 0.875rem;
    transition: all var(--transition-speed) ease;
}

th.sorted-asc::after {
    content: '↑';
    opacity: 1;
    color: var(--primary-color);
}

th.sorted-desc::after {
    content: '↓';
    opacity: 1;
    color: var(--primary-color);
}

/* ======================================== */
/* === Messages (Refined) ================= */
/* ======================================== */

.alert {
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    border: 2px solid transparent;
    border-radius: var(--border-radius-lg);
    text-align: left;
    box-shadow: var(--box-shadow-sm);
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-heading {
    color: inherit;
    font-size: 1.125rem;
    font-weight: var(--font-weight-bold);
    margin-bottom: 0.5rem;
}

.alert-link {
    font-weight: var(--font-weight-semibold);
}

.alert-success,
.success-message {
    color: var(--success-text);
    background-color: var(--success-bg);
    border-color: var(--success-border);
    border-left-width: 4px;
}

.alert-danger,
.error-message {
    color: var(--error-text);
    background-color: var(--error-bg);
    border-color: var(--error-border);
    border-left-width: 4px;
}

.alert-warning,
.warning-message {
    color: var(--warning-text);
    background-color: var(--warning-bg);
    border-color: var(--warning-border);
    border-left-width: 4px;
}

.alert-info,
.info-message {
    color: var(--info-text);
    background-color: var(--info-bg);
    border-color: var(--info-border);
    border-left-width: 4px;
}

table .error-message, table .alert-danger { background-color: transparent; border: none; padding: 2px; margin: 0; text-align: inherit; font-weight: normal; font-size: 0.9em; }


/* ======================================== */
/* === Specific Component Styles ========== */
/* ======================================== */

/* ======================================== */
/* === Modals ============================= */
/* ======================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: var(--white-color);
    margin: 10% auto;
    padding: 2rem;
    border: none;
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--box-shadow-lg);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h2 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 1.25rem;
    font-weight: var(--font-weight-bold);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.75rem;
}

.modal-content ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.modal-content ul li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.close-button {
    color: var(--text-muted);
    float: right;
    font-size: 2rem;
    font-weight: var(--font-weight-bold);
    line-height: 1;
    transition: all var(--transition-speed) ease;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
}

.close-button:hover,
.close-button:focus {
    color: var(--delete-color);
    transform: scale(1.2) rotate(90deg);
}

/* ======================================== */
/* === Specific Component Styles ========== */
/* ======================================== */

/* Details Lists (view_client, view_provider) */
.details-section {
    margin-bottom: 1.5rem;
}
.details-section p {
    margin-bottom: 0.75em;
    line-height: 1.5;
    display: flex;
    flex-wrap: wrap;
}
.details-section strong {
    color: var(--dark-grey);
    min-width: 150px;
    flex-shrink: 0;
    margin-right: 10px;
    font-weight: 700;
}

/* Notes Section */
.notes-list { margin-top: 1.5rem; }
.note-entry { border: 1px solid var(--medium-grey); padding: 15px; margin-bottom: 15px; border-radius: var(--border-radius); background-color: var(--white-color); box-shadow: var(--box-shadow-sm); }
.note-meta { font-size: 0.85rem; color: var(--secondary-color); margin-bottom: 8px; border-bottom: 1px dashed var(--medium-grey); padding-bottom: 8px; }
.note-content { margin-bottom: 10px; }
.note-entry .action-buttons-inline { margin-top: 10px; justify-content: flex-end; }

/* Search Container */
.search-container {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--white-color) 0%, var(--light-grey) 100%);
    border-radius: var(--border-radius-lg);
    border: 2px solid var(--medium-grey);
    box-shadow: var(--box-shadow);
}

.search-container label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: var(--font-weight-semibold);
    color: var(--dark-grey);
    font-size: 1rem;
}

.search-container input[type="search"],
.search-container input[type="text"] {
    display: inline-block;
    width: auto;
    min-width: 300px;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--medium-grey);
    border-radius: var(--border-radius);
    margin-right: 0.75rem;
    font-size: 0.9375rem;
    transition: all var(--transition-speed) ease;
}

.search-container input[type="search"]:focus,
.search-container input[type="text"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

.search-container .buttons {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Authenticator Store Links */
.store-table { border-collapse: collapse; margin: 20px auto; width: auto; }
.store-table td { border: none; padding: 10px; vertical-align: middle; }
.authenticator-name { font-weight: bold; text-align: right; padding-right: 20px; color: var(--dark-grey); }
.store-links a { margin-right: 10px; display: inline-block; transition: transform 0.2s ease, opacity 0.2s ease; opacity: 0.9; }
.store-links a:hover { transform: scale(1.05); opacity: 1; }
.store-links img { height: 45px; width: auto; vertical-align: middle; }

/* Footer styling */
.footer,
footer {
     background: linear-gradient(135deg, var(--dark-grey) 0%, var(--secondary-color) 100%);
     color: var(--light-grey);
     text-align: center;
     padding: 1.25rem 0;
     margin-top: auto;
     font-size: 0.875rem;
     border-top: 3px solid var(--primary-color);
     box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

.footer p,
footer p {
     margin: 0.5rem 0;
     line-height: 1.6;
}

.footer a,
footer a {
     color: var(--primary-light);
     text-decoration: none;
     transition: all var(--transition-speed) ease;
     font-weight: var(--font-weight-medium);
}

.footer a:hover,
footer a:hover {
     color: var(--white-color);
     text-decoration: underline;
}

.version-info {
     font-size: 0.75rem;
     color: var(--medium-grey);
     margin-top: 0.5rem;
     opacity: 0.8;
}

/* ======================================== */
/* === Responsive Adjustments ============ */
/* ======================================== */

@media (max-width: 992px) {
    .page-container { max-width: 960px; }
}

@media (max-width: 768px) {
    body { font-size: 15px; }
    .page-container { padding: 0 10px; }
    .content-area { padding: 15px 0; }

    /* Reduce padding/font size for card/container headers */
    .card-header, .content-container > h1, .login-container > h1 { padding: 0.8rem 1rem; font-size: 1.3rem; }
    /* Reduce padding for container bodies */
    .card-body, .content-container > *:not(h1), .login-container > *:not(h1) { padding: 1rem; }

    /* Reduce button size */
    .button, button, input[type="button"], input[type="submit"] { padding: .375rem .75rem; font-size: 0.9rem; }
    .button-sm, .button.inline-button, .save-button { padding: .2rem .4rem; font-size: .8rem; }

    /* Responsive table adjustments */
    .table-responsive { margin-bottom: 0.5rem; }
    .data-table th, .data-table td { padding: .5rem .5rem; font-size: .85rem; line-height: 1.4; }
    .data-table thead th { font-size: 0.8rem; }

    /* --- Responsive Column Hiding (CHECK INDICES!) --- */
    /* Assuming 13 total columns initially:
       0: Provider, 1: Billed, 2: DOS, 3: Neg, 4: Comm, 5: PayAmt, 6: ApprRed,
       7: ClientChk, 8: CollAmt, 9: CollDate, 10: FirmChk, 11: PayDate, 12: Actions
       Let's hide: ApprRed(6), ClientChk(7), CollDate(9), FirmChk(10)
    */
    #transactionsTable th:nth-child(7), #transactionsTable td:nth-child(7), /* Approved Reduction */
    #transactionsTable th:nth-child(8), #transactionsTable td:nth-child(8), /* Client Check # */
    #transactionsTable th:nth-child(10), #transactionsTable td:nth-child(10),/* Date Collected */
    #transactionsTable th:nth-child(11), #transactionsTable td:nth-child(11) { /* Firm Check # */
        display: none;
    }
    /* Hide corresponding footer cells (check indices carefully) */
     #transactionsTable tfoot td:nth-child(7), /* ApprRed */
     #transactionsTable tfoot td:nth-child(8), /* Client Check Spacer */
     #transactionsTable tfoot td:nth-child(10),/* CollDate Spacer */
     #transactionsTable tfoot td:nth-child(11) { /* FirmCheck Spacer */
         display: none;
     }
    /* Adjust final colspan in footer:
       Original: 13 cols. Hidden 4 = 9 data cols + Actions = 10.
       Footer structure: Totals(1), Billed(1), DOS(1), Neg(1), Comm(1), PayAmt(1), Red(1), Chk#(1), Coll(1), DateColl(1), FirmChk(1), PayDate(1), Act(1)
       Footer w/ hiding: Totals(1), Billed(1), DOS(1), Neg(1), Comm(1), PayAmt(1), Coll(1), PayDate(1), Act(1) = 9 Cells shown
       Need to adjust the final colspan to account for the missing cells.
       Original colspan=3 covered PayDate, Actions + 1 more? Let's assume it should cover the remaining *visible* columns after CollTotal.
       Visible after CollTotal: PayDate(1), Actions(1). Need colspan=1 if we mean the PayDate column.
       Let's simplify and assume the colspan should cover everything after Collected Amount.
       Visible cells: ProviderTotal(1), Billed(1), DOS Spacer(1), Neg(1), Comm(1), PayAmt(1), Red(1), Chk Spacer(1), Coll(1), DateColl Spacer(1), FirmChk Spacer(1), PayDate(1), Action Spacer(1)
       After Hiding (Indices from 1): Billed(2), DOS(3), Neg(4), Comm(5), PayAmt(6), Coll(9), PayDate(12), Actions(13)
       Visible Footer Cells: Totals(1), Billed(2), DOS Spacer(3), Neg(4), Comm(5), PayAmt(6), Coll(9), PayDate(12), Actions(13) + Hidden[Red(7), Chk(8), CollDate(10), FirmChk(11)]
       Structure: td(Totals), td#billed, td(Spacer), td#neg, td#comm, td#pay, td#red(HIDDEN), td(Spacer_Chk)(HIDDEN), td#coll, td(Spacer_CollDate)(HIDDEN), td(Spacer_FirmChk)(HIDDEN), td#paydate(should exist?), td(Actions Spacer?)
       Let's adjust the colspan based on the *updated* number of columns after Commission was added (13 total initially). Hiding 4 leaves 9.
       Structure in HTML: Totals, Billed, Spacer, Neg, Comm, Pay, Red, Spacer, Coll, Spacer*3 = 13.
       Footer cells: 1(Total Label) + 1(Billed) + 1(Spacer) + 1(Neg) + 1(Comm) + 1(Pay) + 1(Red) + 1(Spacer) + 1(Coll) + 3(Colspan) = 12? Let's re-check the PHP.
       PHP tfoot: Totals(1), Billed(1), Spacer(1), Neg(1), Comm(1), Pay(1), Red(1), Spacer(1), Coll(1), colspan="3" (covering DateColl, FirmChk, PayDate, Actions?) -> 1+1+1+1+1+1+1+1+1+3 = 12. Wait, 13 columns in thead.
       thead: Prov, Bill, DOS, Neg, Comm, Pay, ApprRed, ClientChk, CollAmt, CollDate, FirmChk, PayDate, Actions = 13
       tbody: td (Prov), td(Bill), td(DOS), td(Neg), td(Comm), td(Pay), td(ApprRed), td(ClientChk), td(CollAmt), td(CollDate), td(UserChk), td(PayDate), td(Actions) = 13
       tfoot: Totals(1), Billed(1), SpacerDOS(1), Neg(1), Comm(1), Pay(1), Red(1), SpacerChk(1), Coll(1), colspan="3" (Should cover CollDate, FirmChk, PayDate, Actions? - needs colspan 4!)
       Let's assume the initial colspan=3 was wrong and should be 4.
       Now hiding 4 columns (ApprRed(7), ClientChk(8), CollDate(10), FirmChk(11)).
       The corresponding footer cells/spacers: RedTotal(7), SpacerChk(8), SpacerCollDate(10), SpacerFirmChk(11) are hidden.
       Remaining footer: Totals(1), Billed(2), SpacerDOS(3), Neg(4), Comm(5), Pay(6), Coll(9), SpacerPayDate(12?), Actions(13?). Colspan needs adjustment.
       Visible data columns: 1,2,3,4,5,6, 9, 12, 13 (9 columns)
       Visible footer columns: Totals(1), Billed(2), SpacerDOS(3), Neg(4), Comm(5), Pay(6), Coll(9), SpacerPayDate(12), SpacerActions(13)?
       Let's assume the colspan covers the columns starting from Date Collected. Hiding CollDate(10), FirmChk(11). Still visible: PayDate(12), Actions(13). Need colspan=2?
    */
     #transactionsTable tfoot td[colspan="4"], /* Target original colspan */
     #transactionsTable tfoot td[colspan="3"] { /* Or target previous incorrect one */
         colspan: 2; /* Adjust based on PayDate and Actions remaining visible */
     }


    /* Stack details labels/values */
    .details-section p { flex-direction: column; }
    .details-section strong { min-width: unset; margin-bottom: 3px; }
}

@media (max-width: 576px) {
    /* Stack navbar items on very small screens */
    /* .navbar-container { flex-direction: column; align-items: center; } */
    /* .navbar-brand { margin-bottom: 10px; } */
    /* .navbar ul { justify-content: center; width: 100%; } */
    /* .navbar ul li { margin: 3px; } */
    /* Keep mobile toggle behavior from 768px */

    /* Force full width buttons */
    .action-buttons, .search-container .buttons { flex-direction: column; align-items: stretch; }
    .action-buttons .button, .search-container .button { width: 100%; margin-left: 0; margin-right: 0; }

    .login-container { margin: 15px; max-width: none; /* Allow login to fill small screen */ }
}


/* ======================================== */
/* === Enhanced UI Components ============= */
/* ======================================== */

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: var(--white-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-lg);
    animation: toastSlideIn 0.3s ease-out;
    border-left: 4px solid var(--primary-color);
    max-width: 100%;
}

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

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast.success .toast-icon { color: var(--success-color); }
.toast.error .toast-icon { color: var(--delete-color); }
.toast.warning .toast-icon { color: var(--warning-text); }
.toast.info .toast-icon { color: var(--info-color); }

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: var(--font-weight-semibold);
    color: var(--dark-grey);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-speed) ease;
}

.toast-close:hover {
    background: var(--light-grey);
    color: var(--dark-grey);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* --- Loading Spinner --- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--medium-grey);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading overlay for sections */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
}

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

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-card {
    height: 120px;
    border-radius: var(--border-radius-lg);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

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

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

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    color: var(--medium-grey);
    opacity: 0.6;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold);
    color: var(--dark-grey);
    margin-bottom: 0.5rem;
}

.empty-state-description {
    font-size: 0.9375rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state .button {
    margin-top: 0.5rem;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 0;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.breadcrumbs a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.breadcrumbs a:hover {
    color: var(--primary-color);
}

.breadcrumbs-separator {
    color: var(--medium-grey);
    font-size: 0.75rem;
}

.breadcrumbs-current {
    color: var(--dark-grey);
    font-weight: var(--font-weight-medium);
}

/* --- Activity List --- */
.activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.activity-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--light-grey);
    transition: background-color var(--transition-speed) ease;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item:hover {
    background-color: var(--light-grey);
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: var(--border-radius);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--primary-light);
    color: var(--primary-color);
}

.activity-icon.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.activity-icon.warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-weight: var(--font-weight-medium);
    color: var(--dark-grey);
    margin-bottom: 2px;
}

.activity-title a {
    color: inherit;
    text-decoration: none;
}

.activity-title a:hover {
    color: var(--primary-color);
}

.activity-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --- Enhanced Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary-color);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.badge-danger {
    background: var(--error-bg);
    color: var(--error-text);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info-text);
}

/* --- Password Input with Toggle --- */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-speed) ease;
}

.password-toggle:hover {
    color: var(--primary-color);
}

/* --- Enhanced Login Page --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--background-color) 50%, var(--white-color) 100%);
}

.login-card {
    background: var(--white-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--medium-grey);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo img {
    width: 120px;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-sm);
}

.login-title {
    text-align: center;
    font-size: 1.5rem;
    color: var(--dark-grey);
    margin: 0 0 0.5rem 0;
    font-weight: var(--font-weight-bold);
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.9375rem;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: var(--font-weight-medium);
    color: var(--dark-grey);
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--medium-grey);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all var(--transition-speed) ease;
}

.login-form input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

.login-form button[type="submit"] {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* --- Icon containers for consistent sizing --- */
.icon-container {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.icon-container svg {
    width: 24px;
    height: 24px;
}

.icon-container.primary {
    background: var(--primary-light);
    color: var(--primary-color);
}

.icon-container.success {
    background: var(--success-bg);
    color: var(--success-color);
}

.icon-container.warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.icon-container.info {
    background: var(--info-bg);
    color: var(--info-color);
}

.icon-container.accent {
    background: #ede9fe;
    color: var(--accent-color);
}

/* --- Dashboard Grid Layout --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
}

.dashboard-grid .col-8 {
    grid-column: span 8;
}

.dashboard-grid .col-4 {
    grid-column: span 4;
}

.dashboard-grid .col-6 {
    grid-column: span 6;
}

.dashboard-grid .col-12 {
    grid-column: span 12;
}

@media (max-width: 992px) {
    .dashboard-grid .col-8,
    .dashboard-grid .col-4,
    .dashboard-grid .col-6 {
        grid-column: span 12;
    }
}

/* --- Pulse animation for alerts --- */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ============================================
   Notification System Styles
   ============================================ */

/* Sidebar notification bell — matches sidebar-footer pattern */
.sidebar-notifications {
    padding: 4px 8px;
    border-top: 1px solid var(--medium-grey);
    position: relative;
}

/* Bell button — reuses .nav-link styling from sidebar */
.notification-bell-btn {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--border-radius);
    color: var(--text-color);
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    transition: all var(--transition-speed) ease;
    font-family: var(--body-font);
    font-size: 0.9375rem;
    font-weight: var(--font-weight-medium);
}

.notification-bell-btn:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.notification-bell-btn .nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    flex-shrink: 0;
    position: relative;
}

.notification-bell-btn .nav-icon svg {
    width: 20px;
    height: 20px;
}

/* Bell text — follows .nav-text opacity pattern */
.notification-bell-btn .nav-text {
    margin-left: 12px;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.sidebar.expanded .notification-bell-btn .nav-text,
.sidebar.hover-expanded .notification-bell-btn .nav-text {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* Red badge */
.notification-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--delete-color);
    color: var(--white-color);
    border-radius: 9px;
    font-size: 11px;
    font-weight: var(--font-weight-bold);
    line-height: 1;
    z-index: 1;
    border: 2px solid var(--white-color);
}

/* Notification Dropdown — positioned outside sidebar */
.notification-dropdown {
    display: none;
    position: fixed;
    width: 360px;
    max-height: 480px;
    background: var(--white-color);
    border-radius: var(--border-radius-lg, 12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    overflow: hidden;
    flex-direction: column;
    border: 1px solid var(--medium-grey);
}

.notification-dropdown.show {
    display: flex;
}

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--medium-grey);
    background: var(--light-grey);
}

.notif-dropdown-title {
    font-weight: var(--font-weight-semibold);
    font-size: 15px;
    color: var(--dark-grey);
}

.notif-mark-all-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 12px;
    font-family: var(--body-font);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    transition: background 0.15s;
}

.notif-mark-all-btn:hover {
    background: var(--primary-light);
}

.notif-dropdown-list {
    flex: 1;
    overflow-y: auto;
    max-height: 360px;
}

.notif-dropdown-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--medium-grey);
    text-align: center;
    background: var(--light-grey);
}

.notif-dropdown-footer a {
    color: var(--primary-color);
    font-size: 13px;
    text-decoration: none;
    font-weight: var(--font-weight-medium);
}

.notif-dropdown-footer a:hover {
    text-decoration: underline;
}

/* Notification Items */
.notif-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid var(--light-grey);
    transition: background 0.15s;
    cursor: default;
}

.notif-item:hover {
    background: var(--light-grey);
}

.notif-unread {
    background: var(--primary-light);
    border-left: 3px solid var(--primary-color);
}

.notif-unread:hover {
    background: #dbeafe;
}

.notif-item-content {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.notif-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    margin-top: 2px;
}

.notif-severity-info .notif-icon {
    background: var(--primary-light);
    color: var(--primary-color);
}

.notif-severity-warning .notif-icon {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.notif-severity-critical .notif-icon {
    background: var(--error-bg);
    color: var(--delete-color);
}

.notif-text {
    flex: 1;
    min-width: 0;
}

.notif-title {
    font-size: 13px;
    font-weight: var(--font-weight-semibold);
    color: var(--dark-grey);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-message {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    opacity: 0.7;
}

.notif-dismiss {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    border-radius: var(--border-radius);
    margin-left: 4px;
}

.notif-dismiss:hover {
    background: var(--light-grey);
    color: var(--dark-grey);
}

.notif-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Collapsed sidebar: center bell, hide text */
.sidebar:not(.expanded):not(.hover-expanded):not(.mobile-open) .notification-bell-btn {
    justify-content: center;
}

/* Mobile notification dropdown */
@media (max-width: 768px) {
    .notification-dropdown {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-height: 70vh;
        border-radius: 12px 12px 0 0;
        margin-left: 0;
    }
}

/* Admin notification tab styles */
.notif-settings-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}

.notif-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.notif-setting-row label {
    font-weight: 500;
    color: #374151;
}

.notif-setting-row .toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.notif-setting-row .toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.notif-setting-row .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #d1d5db;
    border-radius: 12px;
    transition: 0.3s;
}

.notif-setting-row .toggle-slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.notif-setting-row .toggle-switch input:checked + .toggle-slider {
    background: #3b82f6;
}

.notif-setting-row .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.escalation-rules-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.escalation-rules-table th,
.escalation-rules-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
}

.escalation-rules-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.severity-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.severity-badge.info {
    background: #dbeafe;
    color: #1d4ed8;
}

.severity-badge.warning {
    background: #fef3c7;
    color: #b45309;
}

.severity-badge.critical {
    background: #fee2e2;
    color: #dc2626;
}

.notif-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.notif-stat-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.notif-stat-card .stat-number {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
}

.notif-stat-card .stat-label {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

/* =========================================================================
   Autocomplete Widget
   ========================================================================= */
.ac-wrapper {
    position: relative;
    width: 100%;
}

.ac-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--medium-grey, #d1d5db);
    border-top: none;
    border-radius: 0 0 var(--border-radius, 6px) var(--border-radius, 6px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 260px;
    overflow-y: auto;
    z-index: 1000;
}

.ac-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--light-grey, #f3f4f6);
    transition: background 0.15s ease;
}

.ac-item:last-child {
    border-bottom: none;
}

.ac-item:hover,
.ac-item.ac-active {
    background: var(--primary-light, #eff6ff);
    color: var(--primary-color, #2563eb);
}

.ac-item .ac-item-title {
    font-weight: 600;
}

.ac-item .ac-item-sub {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
    margin-top: 1px;
}

.ac-loading,
.ac-no-results {
    padding: 0.75rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted, #6b7280);
}

.ac-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--medium-grey, #d1d5db);
    border-top-color: var(--primary-color, #2563eb);
    border-radius: 50%;
    animation: ac-spin 0.6s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

@keyframes ac-spin {
    to { transform: rotate(360deg); }
}

/* Selected state display for autocomplete fields */
.ac-selected-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--primary-light, #eff6ff);
    border: 2px solid var(--primary-color, #2563eb);
    border-radius: var(--border-radius, 6px);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--primary-color, #2563eb);
}

.ac-selected-display .ac-clear-btn {
    background: none;
    border: none;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 0.25rem;
    margin-left: auto;
    line-height: 1;
}

.ac-selected-display .ac-clear-btn:hover {
    color: var(--delete-color, #ef4444);
}

/* Attorney mode toggle */
.attorney-mode-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.attorney-mode-toggle button {
    padding: 0.4rem 1rem;
    border: 2px solid var(--medium-grey, #d1d5db);
    border-radius: var(--border-radius, 6px);
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.attorney-mode-toggle button.active {
    background: var(--primary-color, #2563eb);
    border-color: var(--primary-color, #2563eb);
    color: #fff;
}

/* Transaction import modal */
.txn-import-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.txn-import-modal {
    background: #fff;
    border-radius: var(--border-radius-lg, 12px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.txn-import-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--medium-grey, #d1d5db);
}

.txn-import-modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
}

.txn-import-modal-header .close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted, #6b7280);
    padding: 0.25rem;
}

.txn-import-modal-body {
    padding: 1rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.txn-import-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--medium-grey, #d1d5db);
}

/* ======================================== */
/* === Help Tooltips (hover-only) ========= */
/* ======================================== */

/* Inline help indicator — small ? icon next to labels/headers */
.help-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--medium-grey);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    cursor: help;
    margin-left: 4px;
    vertical-align: middle;
    flex-shrink: 0;
    line-height: 1;
    transition: background var(--transition-speed) ease, color var(--transition-speed) ease;
}
.help-tip:hover {
    background: var(--primary-color);
    color: #fff;
}
/* Tooltip bubble — appears on hover, no click needed */
.help-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark-grey);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    padding: 0.55rem 0.75rem;
    border-radius: var(--border-radius-sm);
    white-space: normal;
    width: max-content;
    max-width: 280px;
    z-index: 9000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    text-align: left;
}
/* Tooltip arrow */
.help-tip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--dark-grey);
    z-index: 9001;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}
.help-tip:hover::after,
.help-tip:hover::before {
    opacity: 1;
    visibility: visible;
}
/* When tooltip would overflow top, show below instead */
.help-tip.tip-below::after {
    bottom: auto;
    top: calc(100% + 8px);
}
.help-tip.tip-below::before {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: var(--dark-grey);
}
/* When tooltip would overflow right, align to right edge */
.help-tip.tip-left::after {
    left: auto;
    right: -8px;
    transform: none;
}
.help-tip.tip-left::before {
    left: auto;
    right: 2px;
    transform: none;
}
/* When tooltip would overflow left (near sidebar), show to the right */
.help-tip.tip-right::after {
    left: calc(100% + 10px);
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
}
.help-tip.tip-right::before {
    left: calc(100% + 4px);
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    border-top-color: transparent;
    border-right-color: var(--dark-grey);
    border-bottom-color: transparent;
    border-left-color: transparent;
}
/* Table header variant — smaller, no margin shift */
th .help-tip {
    width: 13px;
    height: 13px;
    font-size: 9px;
    margin-left: 3px;
}

/* ======================================== */
/* === Help Page Styles =================== */
/* ======================================== */

.help-page { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }
.help-search-box {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 2px solid var(--medium-grey);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: var(--white-color);
    transition: border-color var(--transition-speed);
}
.help-search-box:focus { outline: none; border-color: var(--primary-color); }
.help-search-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}
.help-search-wrapper::before {
    content: '\1F50D';
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    opacity: 0.4;
    pointer-events: none;
}
.help-toc {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.help-toc-card {
    background: var(--white-color);
    border: 1px solid var(--medium-grey);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
    text-decoration: none;
    color: inherit;
}
.help-toc-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--box-shadow-sm);
}
.help-toc-card h3 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    color: var(--primary-color);
}
.help-toc-card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.help-section {
    background: var(--white-color);
    border: 1px solid var(--medium-grey);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.help-section h2 {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    color: var(--dark-grey);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-light);
}
.help-section h3 {
    margin: 1.25rem 0 0.5rem;
    font-size: 1rem;
    color: var(--dark-grey);
}
.help-term {
    display: flex;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--light-grey);
    font-size: 0.9rem;
    line-height: 1.5;
}
.help-term:last-child { border-bottom: none; }
.help-term dt {
    min-width: 160px;
    font-weight: var(--font-weight-semibold);
    color: var(--dark-grey);
    flex-shrink: 0;
}
.help-term dd {
    margin: 0;
    color: var(--text-color);
}
.help-formula {
    display: inline-block;
    background: var(--light-grey);
    border: 1px solid var(--medium-grey);
    border-radius: var(--border-radius-sm);
    padding: 2px 8px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.82rem;
    color: var(--accent-color);
}
.help-back-top {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--primary-color);
    text-decoration: none;
    margin-top: 0.5rem;
}
.help-back-top:hover { text-decoration: underline; }
@media (max-width: 768px) {
    .help-term { flex-direction: column; gap: 0.15rem; }
    .help-term dt { min-width: 0; }
}
