* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== Base layout ===== */

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f3f4f6;
    min-height: 100vh;
    color: #111827;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

/* ===== Header - Full width with fixed color ===== */

header {
    background: #2563eb !important;
    color: #ffffff;
    padding: 16px 20px;
    border-bottom: 1px solid #1d4ed8;
    width: 100%;
    position: relative;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
}

header h1 {
    font-size: clamp(18px, 2.2vw, 22px);
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}

header p {
    font-size: clamp(12px, 1.5vw, 13px);
    opacity: 0.92;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: clamp(36px, 5vw, 42px);
    height: clamp(36px, 5vw, 42px);
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

/* ===== Logout button ===== */

.btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #bc0000;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid #e1a500;
    cursor: pointer;
    font-size: clamp(12px, 1.5vw, 13px);
    font-weight: 500;
    letter-spacing: 0.01em;
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.btn-logout:hover {
    background: #1e40af;
    border-color: #1e40af;
}

/* ===== Navigation tabs - ORIGINAL GAP RESTORATION ===== */

nav {
    display: flex;
    align-items: center;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
    scrollbar-width: thin;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

nav::-webkit-scrollbar {
    height: 4px;
}

nav::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.7);
    border-radius: 999px;
}

nav button {
    flex: 1;
    min-width: clamp(140px, 20vw, 180px);
    padding: 12px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: clamp(13px, 1.6vw, 14px);
    font-weight: 500;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    margin-right: 4px;
    /* ORIGINAL 4px gap between nav buttons restored */
}

nav button:last-child {
    margin-right: 0;
}

nav button i {
    font-size: clamp(14px, 2vw, 16px);
    color: #9ca3af;
}

nav button:hover {
    background: #e5e7eb;
    color: #111827;
}

nav button.active {
    background: #e0ebff;
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
}

nav button.active i {
    color: #1d4ed8;
}

/* ===== Content area ===== */

.content {
    padding: clamp(16px, 2.5vw, 24px);
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ===== Sections ===== */

.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Headings ===== */

h2 {
    color: #111827;
    margin-bottom: 16px;
    font-size: clamp(18px, 2.5vw, 20px);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

h2 i {
    font-size: clamp(16px, 2.2vw, 18px);
    color: #2563eb;
}

h3 {
    color: #111827;
    font-size: clamp(15px, 2.1vw, 17px);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

h3 i {
    color: #2563eb;
}

/* ===== Forms ===== */

.form-group {
    margin-bottom: 14px;
}

label {
    display: block;
    margin-bottom: 6px;
    color: #374151;
    font-weight: 500;
    font-size: clamp(13px, 1.7vw, 14px);
}

input,
select,
textarea {
    width: 100%;
    padding: clamp(8px, 1.2vw, 9px) clamp(10px, 1.4vw, 11px);
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: clamp(13px, 1.7vw, 14px);
    color: #111827;
    background-color: #ffffff;
    transition: border-color 0.15s ease, outline 0.15s ease, background-color 0.15s ease;
}

input::placeholder,
textarea::placeholder {
    color: #9ca3af;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
    border-color: #2563eb;
    background-color: #ffffff;
    box-shadow: none;
}

/* ===== Row layout ===== */

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

/* ===== Radio & Checkbox ===== */

.radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.radio-group label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #4b5563;
    cursor: pointer;
    border: 1px solid transparent;
}

.radio-group input[type="radio"] {
    width: auto;
    margin: 0;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    font-size: 13px;
    cursor: pointer;
    color: #374151;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* ===== Buttons ===== */

button[type="submit"],
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: clamp(8px, 1.2vw, 9px) clamp(16px, 2.2vw, 18px);
    border-radius: 999px;
    border: 1px solid #2563eb;
    background: #2563eb;
    color: #ffffff;
    cursor: pointer;
    font-size: clamp(12px, 1.6vw, 13px);
    font-weight: 500;
    letter-spacing: 0.01em;
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

button[type="submit"] i,
.btn i {
    font-size: clamp(12px, 1.6vw, 13px);
}

button[type="submit"]:hover,
.btn:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

button[type="submit"]:active,
.btn:active {
    background: #1e40af;
    border-color: #1e40af;
}

/* Button variants */

.btn-secondary {
    background: #6b7280 !important;
    border-color: #6b7280 !important;
}

.btn-secondary:hover {
    background: #4b5563 !important;
    border-color: #4b5563 !important;
}

.btn-danger {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
}

.btn-danger:hover {
    background: #b91c1c !important;
    border-color: #b91c1c !important;
}

.btn-success {
    background: #16a34a !important;
    border-color: #16a34a !important;
}

.btn-success:hover {
    background: #15803d !important;
    border-color: #15803d !important;
}

.btn-small {
    padding: 7px 14px !important;
    font-size: 12px !important;
}

/* Button spacing - ORIGINAL MARGIN APPROACH */

.form-actions button,
.form-actions .btn,
.action-buttons .btn,
.action-buttons button,
.export-buttons .btn,
.export-buttons button {
    margin-right: 8px;
    margin-bottom: 8px;
}

.form-actions button:last-child,
.action-buttons button:last-child,
.export-buttons button:last-child {
    margin-right: 0;
}

.form-actions,
.action-buttons,
.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    /* Original margin-based spacing restored */
}

/* ===== Messages ===== */

.message {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: clamp(12px, 1.6vw, 13px);
    display: none;
    border: 1px solid transparent;
}

.message.success {
    background: #ecfdf3;
    color: #166534;
    border-color: #bbf7d0;
}

.message.error {
    background: #fef2f2;
    color: #7f1d1d;
    border-color: #fecaca;
}

/* ===== Event list & cards - SINGLE COLUMN STACKED ===== */

.event-list {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 1.5vw, 12px);
}

.event-item {
    background: #ffffff;
    padding: clamp(12px, 2vw, 14px);
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    box-shadow: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    cursor: pointer;
    width: 100%;
}

.event-item:hover {
    border-color: #2563eb;
    background: #f9fafb;
}

.event-item h3 {
    font-size: clamp(14px, 2vw, 16px);
    margin-bottom: 6px;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.event-item h3 .expand-icon {
    font-size: 14px;
    color: #6b7280;
    transition: transform 0.15s ease, color 0.15s ease, background-color 0.15s ease;
    cursor: pointer;
    padding: 4px;
    border-radius: 999px;
}

.event-item h3 .expand-icon:hover {
    color: #2563eb;
    background: #e5e7eb;
}

.event-item.expanded h3 .expand-icon {
    transform: rotate(90deg);
}

.event-item p {
    color: #6b7280;
    margin: 3px 0;
    font-size: clamp(12px, 1.6vw, 13px);
}

.event-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.event-item.expanded .event-details {
    max-height: 2000px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
}

/* ===== Context card ===== */

.context-card {
    background: #e0ebff;
    color: #111827;
    padding: clamp(12px, 2vw, 14px);
    border-radius: 8px;
    margin-bottom: 16px;
    margin-top: 10px;
    border: 1px solid #bfdbfe;
}

.context-card h3 {
    font-size: clamp(15px, 2vw, 16px);
    margin-bottom: 4px;
}

.context-card p {
    font-size: 12px;
    margin: 3px 0;
}

/* ===== Tables ===== */

.table-container {
    width: 100%;
    overflow-x: auto;
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
}

.table-container::-webkit-scrollbar {
    height: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.9);
    border-radius: 999px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(11px, 1.5vw, 12px);
    min-width: 600px;
}

table th,
table td {
    padding: clamp(6px, 1.2vw, 8px) clamp(8px, 1.4vw, 10px);
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

table th {
    background: #f9fafb;
    font-weight: 600;
    color: #4b5563;
}

table tr:hover td {
    background: #f3f4f6;
}

/* ===== Summary card ===== */

.summary-card {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    padding: clamp(14px, 2.2vw, 16px) clamp(12px, 2vw, 14px);
    margin-top: 14px;
}

.summary-card h3 {
    color: #1d4ed8;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
    font-size: clamp(15px, 2vw, 16px);
}

.summary-section {
    margin-bottom: 16px;
}

.summary-section h4 {
    color: #374151;
    margin-bottom: 8px;
    font-size: 14px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: clamp(12px, 1.6vw, 13px);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row span:first-child {
    color: #6b7280;
}

.summary-row span:last-child {
    font-weight: 500;
    color: #111827;
}

.summary-row.total {
    font-weight: 600;
    padding-top: 8px;
}

.summary-row.highlight {
    margin-top: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    background: #ecfdf3;
    color: #166534;
    border: 1px solid #bbf7d0;
    font-size: 14px;
}

/* ===== Spinner ===== */

.spinner {
    width: clamp(28px, 4vw, 32px);
    height: clamp(28px, 4vw, 32px);
    margin: 26px auto;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #2563eb;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ===== Modal ===== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

.modal-content {
    background: #ffffff;
    margin: clamp(10%, 5vw, 12%) auto;
    padding: clamp(18px, 3vw, 20px) clamp(16px, 3vw, 18px);
    border-radius: 10px;
    width: clamp(90%, 80vw, 420px);
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ===== Toast ===== */

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #16a34a;
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 2000;
    font-size: clamp(12px, 1.6vw, 13px);
}

.toast.error {
    background: #dc2626;
}

/* ===== Print ===== */

@media print {

    nav,
    .export-buttons,
    .action-buttons,
    .btn-logout {
        display: none !important;
    }

    body {
        background: #ffffff;
    }

    .no-print,
    .btn-delete-expense {
        display: none !important;
    }

    .container {
        max-width: 100%;
    }
}

/* ===== Responsive Breakpoints ===== */

/* Large Desktop */
@media (min-width: 1200px) {

    .container,
    .header-content,
    nav,
    .content {
        max-width: 1200px;
    }
}

/* Desktop */
@media (min-width: 992px) and (max-width: 1199px) {

    .container,
    .header-content,
    nav,
    .content {
        max-width: 960px;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 991px) {

    .container,
    .header-content,
    nav,
    .content {
        max-width: 720px;
    }

    header {
        padding: 14px 18px;
    }
}

/* Mobile Large */
@media (min-width: 576px) and (max-width: 767px) {
    header {
        padding: 14px 16px;
    }

    .content {
        padding: 18px 16px 22px;
    }
}

/* Mobile */
@media (max-width: 575px) {
    header {
        padding: 12px 14px;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .btn-logout {
        width: 100%;
        justify-content: center;
    }

    .content {
        padding: 16px 12px 20px;
    }

    nav button {
        min-width: 120px;
        font-size: 13px;
        padding: 10px 8px;
    }

    table {
        min-width: 500px;
        font-size: 11px;
    }

    .form-actions,
    .action-buttons,
    .export-buttons {
        flex-direction: column;
    }

    .form-actions button,
    .form-actions .btn,
    .action-buttons .btn,
    .export-buttons .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Extra Small Mobile */
@media (max-width: 360px) {
    header {
        padding: 10px 12px;
    }

    .content {
        padding: 14px 10px 18px;
    }

    nav button {
        min-width: 110px;
        padding: 9px 6px;
        font-size: 12px;
    }
}