/* Base Reset and Modern CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --light-bg: #868a8d;
    --dark-bg: #1e293b;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 0.25rem 0.375rem -1px rgb(0 0 0 / 0.1), 0 2px 0.25rem -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 0.625rem 0.9375rem -3px rgb(0 0 0 / 0.1), 0 0.25rem 0.375rem -0.25rem rgb(0 0 0 / 0.1);
    --shadow-xl: 0 1.25rem 1.5625rem -0.3125rem rgb(0 0 0 / 0.1), 0 0.625rem 0.625rem -0.3125rem rgb(0 0 0 / 0.1);
    --header-height: 3.75rem;
    --transition: all 0.3s ease-in-out;
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.bg-light {
    background-color: var(--light-bg) !important;
}

.bg-dark {
    background-color: var(--dark-bg) !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);    
}


/* Prevent horizontal overflow on all screen sizes */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

.layout-container {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Ensure main content doesn't exceed viewport */
.main-content {
    max-width: 100%;
    overflow-x: hidden;
}

/* Layout Container */
.layout-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 0;
    transition: var(--transition);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 100%;
    overflow-x: auto;
    position: relative;
    z-index: 1;
}

/* Responsive Utilities */
.container {
    max-width: 75rem;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Cards and Components */
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    max-width: 100%;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--light-bg);
}

.card-body {
    padding: 1.5rem;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    line-height: 1.25;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--light-bg);
}

/* Table Styles */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: 600;
    background-color: var(--light-bg);
    color: var(--text-primary);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

.table-hover tbody tr:hover {
    background-color: rgba(37, 99, 235, 0.05);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

.badge.bg-success {
    background-color: var(--success-color);
    color: white;
}

.badge.bg-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.badge.bg-info {
    background-color: var(--primary-color);
    color: white;
}

.badge.bg-warning {
    background-color: var(--warning-color);
    color: white;
}

/* Button group styles */
.btn-group {
    display: inline-flex;
    vertical-align: middle;
}

.btn-group .btn {
    position: relative;
    flex: 1 1 auto;
    margin-left: -1px;
}

.btn-group .btn:first-child {
    margin-left: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn-group .btn:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.btn-group .btn:not(:first-child):not(:last-child) {
    border-radius: 0;
}

.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Utility classes */
.d-flex {
    display: flex !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.align-items-center {
    align-items: center !important;
}

.text-center {
    text-align: center !important;
}

.text-decoration-none {
    text-decoration: none !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.text-muted {
    color: var(--text-light) !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.me-2 {
    margin-right: 0.5rem !important;
}

.py-3 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

.py-5 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
}

.p-3 {
    padding: 1rem !important;
}

.border {
    border: 1px solid var(--border-color) !important;
}

.rounded {
    border-radius: 0.375rem !important;
}

.bg-light {
    background-color: var(--light-bg) !important;
}

/* Grid system */
.container-fluid {
    width: 100%;
    padding-right: 0.9375rem;
    padding-left: 0.9375rem;
    margin-right: auto;
    margin-left: auto;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.9375rem;
    margin-left: -0.9375rem;
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
    padding-right: 0.9375rem;
    padding-left: 0.9375rem;
}

.col-md-3 {
    flex: 0 0 25%;
    max-width: 25%;
    padding-right: 0.9375rem;
    padding-left: 0.9375rem;
}

.col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
    padding-right: 0.9375rem;
    padding-left: 0.9375rem;
}

.col-md-9 {
    flex: 0 0 75%;
    max-width: 75%;
    padding-right: 0.9375rem;
    padding-left: 0.9375rem;
}

/* Responsive Design - Mobile First Approach */
@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
    }
    
    .container {
        padding: 0 0.5rem;
    }
    
    .card-header,
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }

    /* Restore touch-safe size for small button groups on mobile */
    .btn-group-sm .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        min-height: 2.5rem;
    }
}

/* Form styling additions */
.form-check {
    display: block;
    min-height: 1.5rem;
    padding-left: 1.5em;
    margin-bottom: 0.125rem;
}

.form-check-input {
    width: 1em;
    height: 1em;
    margin-top: 0.25em;
    vertical-align: top;
    background-color: #fff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    border: 1px solid var(--border-color);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;        
}

.form-check-input[type="checkbox"] {
    border-radius: 0.25em;
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-label {
    color: var(--text-primary);
    cursor: pointer;
}

/* Additional button styles */
.btn-outline-primary {
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    background-color: transparent;
}

.btn-outline-primary:hover {
    color: white;
    background-color: var(--primary-color);
}

.btn-outline-warning {
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
    background-color: transparent;
}

.btn-outline-warning:hover {
    color: white;
    background-color: var(--warning-color);
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
    border: 1px solid var(--warning-color);
}

.btn-warning:hover {
    background-color: #d97706;
    border-color: #d97706;
}

.btn-info {
    background-color: #06b6d4;
    color: white;
    border: 1px solid #06b6d4;
}

.btn-info:hover {
    background-color: #0891b2;
    border-color: #0891b2;
}

/* Icon styles for Font Awesome alternative */
.fas {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

/* Simple icon replacements */
.fa-plus::before { content: "+"; }
.fa-eye::before { content: "👁"; }
.fa-edit::before { content: "✏"; }
.fa-save::before { content: "💾"; }
.fa-arrow-left::before { content: "←"; }
.fa-folder-open::before { content: "📁"; }

/* Position utilities */
.position-absolute {
    position: absolute !important;
}

.top-0 {
    top: 0 !important;
}

.end-0 {
    right: 0 !important;
}

/* Small text */
.small {
    font-size: 0.875em;
}

.sidebar-logo {
    width: 40vw;         /* Responsive to viewport width */
    max-width: 11.25rem;    /* Prevents it from getting too large */
    height: auto;
    display: block;
    object-fit: contain;
    border: none;
    background: none;
}

/* Skip to main content link for screen readers */
.skip-to-content {
    position: absolute;
    top: -2.5rem;
    left: 0.375rem;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem;
    text-decoration: none;
    border-radius: 0.25rem;
    z-index: 9999;
}

.skip-to-content:focus {
    top: 0.375rem;
}

/* Improved focus indicators */
.form-input:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Active navigation state improvements */
.nav-link.active {
    background: var(--primary-color);
    color: white;
    position: relative;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: white;
    border-radius: 0 2px 2px 0;
}

/* Module sidebar accordion styles */
.module-sidebar {
    display: block;
}

.module-sidebar .nav-section-title {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.module-sidebar details > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-light, #cbd5e0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.2s;
    border-radius: 0.375rem;
}

.module-sidebar details > summary:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.module-sidebar details > summary::-webkit-details-marker {
    display: none;
}

.module-sidebar details > summary::after {
    content: '›';
    font-size: 1.2rem;
    line-height: 1;
    transition: transform 0.2s ease;
    margin-left: 0.5rem;
}

.module-sidebar details[open] > summary::after {
    transform: rotate(90deg);
}

.module-sidebar details .nav-item {
    padding-left: 0.75rem;
}

.module-sidebar details[open] summary ~ * {
    animation: slideDown 0.2s ease-in-out;
}

/* Unified application navigation */
:root {
    --app-sidebar-width: 17rem;
    --app-sidebar-collapsed: 4.75rem;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 950;
    width: var(--app-sidebar-width);
    display: flex;
    flex-direction: column;
    color: #dce5f2;
    background: #0b1320;
    border-right: 1px solid #233044;
    transition: width 180ms ease, transform 180ms ease;
}

.app-sidebar__brand {
    min-height: 4.5rem;
    padding: 0.875rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid #233044;
}

.app-sidebar__company {
    flex: 0 0 100%;
    min-width: 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.app-sidebar__company p { margin: 0; }

.app-brand {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 750;
    letter-spacing: 0.02em;
}

.app-brand img { flex: 0 0 auto; }
.app-sidebar button {
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 0.5rem;
}

.app-sidebar__collapse,
.app-sidebar__mobile-close {
    width: 2.25rem;
    height: 2.25rem;
    cursor: pointer;
}

.app-sidebar__mobile-close { display: none; }
.app-sidebar__nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem 0.625rem;
}

.app-sidebar__link,
.app-sidebar__module > summary,
.app-sidebar__user {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5625rem;
    color: #b8c5d6;
    text-decoration: none;
    cursor: pointer;
}

.app-sidebar__link i,
.app-sidebar__module > summary > i:first-child {
    width: 1.25rem;
    flex: 0 0 1.25rem;
    text-align: center;
}

.app-sidebar__link:hover,
.app-sidebar__module > summary:hover {
    color: #fff;
    background: #162338;
}

.app-sidebar__link.active {
    color: #fff;
    background: #1d4f78;
    box-shadow: inset 3px 0 #65b7e8;
}

.app-sidebar__module > summary {
    list-style: none;
    font-weight: 650;
}

.app-sidebar__module > summary::-webkit-details-marker { display: none; }
.app-sidebar__chevron {
    margin-left: auto;
    font-size: 0.72rem;
    transition: transform 160ms ease;
}
.app-sidebar__module[open] .app-sidebar__chevron { transform: rotate(90deg); }
.app-sidebar__module-links { padding: 2px 0 0.5rem 0.875rem; }
.app-sidebar__sub-link { min-height: 2.5rem; font-size: 0.9rem; }
.app-sidebar__group-label {
    display: block;
    padding: 0.5rem 0.75rem 3px;
    color: #74859b;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.app-sidebar__footer {
    padding: 0.625rem;
    border-top: 1px solid #233044;
}
.app-sidebar__avatar {
    width: 1.5rem;
    height: 1.5rem;
    display: inline-grid;
    place-items: center;
    flex: 0 0 1.5rem;
    border-radius: 50%;
    color: #0b1320;
    background: #dce5f2;
    font-size: 0.67rem;
    font-weight: 800;
}
.layout-container { margin-left: var(--app-sidebar-width); transition: margin-left 180ms ease; }
.nav-collapsed .app-sidebar { width: var(--app-sidebar-collapsed); }
.nav-collapsed .app-sidebar__brand { flex-wrap: nowrap; }
.nav-collapsed .layout-container { margin-left: var(--app-sidebar-collapsed); }
.nav-collapsed .app-nav-label,
.nav-collapsed .app-sidebar__chevron { display: none; }
.nav-collapsed .app-sidebar__module-links { padding-left: 0; }
.nav-collapsed .app-sidebar__link,
.nav-collapsed .app-sidebar__module > summary,
.nav-collapsed .app-sidebar__user { justify-content: center; }
.app-nav-trigger,
.app-nav-backdrop { display: none; }

.dashboard-welcome {
    max-width: 47.5rem;
    margin: clamp(3rem, 12vh, 8rem) auto;
    padding: clamp(2rem, 5vw, 4rem);
    border-left: 0.25rem solid #1d4f78;
    background: #fff;
    box-shadow: 0 1.125rem 3.125rem rgba(15, 23, 42, 0.08);
}
.dashboard-welcome__eyebrow {
    color: #1d4f78;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.dashboard-welcome h1 { margin: 0.35rem 0 0.75rem; text-wrap: balance; }

.app-sidebar a:focus-visible,
.app-sidebar button:focus-visible,
.app-sidebar summary:focus-visible,
.app-nav-trigger:focus-visible {
    outline: 3px solid #65b7e8;
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .app-sidebar {
        width: min(88vw, 20rem);
        transform: translateX(-100%);
        box-shadow: 1.25rem 0 3.125rem rgba(0, 0, 0, 0.3);
    }
    .nav-drawer-open .app-sidebar { transform: translateX(0); }
    .layout-container,
    .nav-collapsed .layout-container { margin-left: 0; padding-top: 3.625rem; }
    .app-nav-trigger {
        position: fixed;
        top: 0.625rem;
        left: 0.75rem;
        z-index: 940;
        width: 2.625rem;
        height: 2.625rem;
        display: grid;
        place-items: center;
        color: #fff;
        background: #0b1320;
        border: 0;
        border-radius: 0.5625rem;
    }
    .app-nav-backdrop {
        position: fixed;
        inset: 0;
        z-index: 945;
        background: rgba(3, 8, 16, 0.58);
    }
    .nav-drawer-open .app-nav-backdrop { display: block; }
    .nav-drawer-open { overflow: hidden; }
    .app-sidebar__collapse { display: none; }
    .app-sidebar__mobile-close { display: block; }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar, .layout-container, .app-sidebar__chevron { transition: none; }
}

@keyframes slideDown {
    0% {
        opacity: 0;
        transform: translateY(-0.625rem);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading and transition states */
.nav-link[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.1);
}

.nav-link[data-loading="true"] {
    opacity: 0.6;
    pointer-events: none;
}

/* =================================================================
   FORM VALIDATION & USER FEEDBACK SYSTEM - Task 1.2
   ================================================================= */

/* Form Input Base Styles */
.form-input,
.form-control {
    display: block;
    width: 100%;
    padding: 0.75rem;
    min-height: 2.75rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: white;
    background-image: none;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-input:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.form-label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Required field indicator */
.form-label.required::after {
    content: " *";
    color: var(--danger-color);
    font-weight: bold;
}

/* Validation States */
.form-input.is-valid,
.form-control.is-valid {
    border-color: var(--success-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2310b981' d='m2.3 6.73.8-.8 1.4-1.4-1.4-1.4-.8.8L3.7 5.3l2.3-2.3.8.8-3.1 3.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    padding-right: 2.5rem;
}

.form-input.is-invalid,
.form-control.is-invalid {
    border-color: var(--danger-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23ef4444'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m6 3v4'/%3e%3cpath d='m6 8h.01'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    padding-right: 2.5rem;
}

.form-input.is-invalid:focus,
.form-control.is-invalid:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.form-input.is-valid:focus,
.form-control.is-valid:focus {
    border-color: var(--success-color);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Validation Feedback */
.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--danger-color);
}

.valid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--success-color);
}

/* Real-time validation indicators */
.field-validating {
    position: relative;
}

.field-validating::after {
    content: '';
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Form Group Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group.has-error .form-label {
    color: var(--danger-color);
}

.form-group.has-success .form-label {
    color: var(--success-color);
}

/* Validation Summary */
.validation-summary {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--danger-color);
    border-radius: 0.375rem;
    background-color: rgba(239, 68, 68, 0.05);
    display: none;
}

.validation-summary.show {
    display: block;
}

.validation-summary h4 {
    color: var(--danger-color);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.validation-summary ul {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--danger-color);
    font-size: 0.8125rem;
}

.validation-summary li {
    margin-bottom: 0.25rem;
}

/* Payment Percentage Indicators */
.payment-percentage-indicator {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
    background-color: var(--light-bg);
    color: var(--text-secondary);
}

.payment-percentage-indicator.valid {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.payment-percentage-indicator.invalid {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.total-percentage-display {
    font-weight: 600;
    padding: 0.5rem;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
    text-align: center;
}

.total-percentage-display.valid {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.total-percentage-display.invalid {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1rem;
    z-index: 9999;
    max-width: 21.875rem;
    /* Bottom placement: visible above keyboard, in thumb reach, clear of sticky nav */
}

.toast {
    display: none;
    flex-direction: column;
    min-width: 15.625rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.toast.show {
    display: flex;
    transform: translateX(0);
    opacity: 1;
}

.toast.toast-success {
    border-left: 0.25rem solid var(--success-color);
}

.toast.toast-error {
    border-left: 0.25rem solid var(--danger-color);
}

.toast.toast-warning {
    border-left: 0.25rem solid var(--warning-color);
}

.toast.toast-info {
    border-left: 0.25rem solid var(--primary-color);
}

.toast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.toast-body {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* ================================================================
   Global Modal (framework-free, HTMX-friendly)
   Place modal HTML into #modal-root via hx-target="#modal-root"
   To close: respond with an empty #modal-root or an element with
             hx-swap-oob="true" id="modal-root" and no children
   ================================================================ */
#modal-root {
    position: fixed;
    inset: 0;
    z-index: 1100; /* above header/sidebar */
    pointer-events: none; /* allow clicks through when empty */
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55); /* slate-900 @ 55% */
    backdrop-filter: blur(2px);
    opacity: 0;
    animation: modalFadeIn 150ms ease forwards;
}

.modal-container {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: start center; /* near top, centered */
    padding: 10vh 1rem 2rem;
    pointer-events: auto; /* enable interaction */
}

.modal-panel {
    width: min(92vw, 45rem);
    background: #fff;
    color: var(--text-primary);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transform: translateY(0.5rem) scale(0.98);
    opacity: 0;
    animation: modalZoomIn 160ms ease forwards;
    max-height: 80vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--light-bg);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-body {
    padding: 1rem 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: #fafafa;
}

/* Closing state hooks (optional) */
.modal-closing .modal-overlay {
    animation: modalFadeOut 150ms ease forwards;
}
.modal-closing .modal-panel {
    animation: modalZoomOut 150ms ease forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modalFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
@keyframes modalZoomIn {
    from { opacity: 0; transform: translateY(0.5rem) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalZoomOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(0.5rem) scale(0.98); }
}

/* Loading Spinner for Forms */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading .loading-spinner {
    margin-right: 0.5rem;
}

/* HTMX Loading States */
.htmx-request .loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.htmx-request .loading-spinner {
    width: 2rem;
    height: 2rem;
}

/* Form Loading State */
.form-loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Progress Indicators */
.progress {
    height: 0.5rem;
    background-color: var(--light-bg);
    border-radius: 0.25rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.progress-bar.bg-success {
    background-color: var(--success-color);
}

.progress-bar.bg-warning {
    background-color: var(--warning-color);
}

.progress-bar.bg-danger {
    background-color: var(--danger-color);
}

/* Enhanced Date Field Styles - Task 1.3 Preview */
.form-input[type="date"],
.form-control[type="date"] {
    position: relative;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.form-input[type="date"]::-webkit-calendar-picker-indicator,
.form-control[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.form-input[type="date"]:hover::-webkit-calendar-picker-indicator,
.form-control[type="date"]:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

/* Date validation styles */
.date-range-error {
    font-size: 0.75rem;
    color: var(--danger-color);
    margin-top: 0.25rem;
}

.date-format-help {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}
