/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: white;
    box-shadow: var(--shadow);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-links a:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

/* Badges */
.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    text-transform: uppercase;
    font-weight: 600;
}

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

.badge-member {
    background: var(--gray-200);
    color: var(--gray-700);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-outline {
    background: white;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-block {
    width: 100%;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 1.5rem;
}

.flash {
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
}

.flash-success {
    background: var(--success-light);
    color: #166534;
    border: 1px solid #bbf7d0;
}

.flash-error {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.flash-info {
    background: var(--info-light);
    color: #155e75;
    border: 1px solid #a5f3fc;
}

/* Login Page */
.login-container {
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-box {
    background: white;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
}

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

.login-header h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--gray-500);
}

.login-form {
    margin-bottom: 2rem;
}

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

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.required {
    color: var(--danger);
}

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

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Demo Users Section */
.demo-section {
    border-top: 1px solid var(--gray-200);
    padding-top: 1.5rem;
}

.demo-section h3 {
    font-size: 1rem;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.demo-section > p {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.demo-users {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.demo-user-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 0.75rem;
    background: var(--gray-50);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.demo-user-btn:hover {
    border-color: var(--primary);
    background: white;
}

.demo-admin {
    border-color: rgba(37, 99, 235, 0.3);
    background: rgba(37, 99, 235, 0.05);
}

.demo-admin:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

.demo-user-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-200);
}

.demo-admin .demo-user-icon {
    background: var(--primary);
    color: white;
}

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

.demo-user-info {
    display: flex;
    flex-direction: column;
}

.demo-user-name {
    font-weight: 600;
    color: var(--gray-800);
}

.demo-user-role {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* Dashboard */
.dashboard {
    max-width: 1100px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
}

a.stat-card,
a.stat-card:visited,
a.stat-card:hover,
a.stat-card:active {
    text-decoration: none;
    color: inherit;
}

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

.stat-card * {
    pointer-events: none;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.stat-pending .stat-icon {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-approved .stat-icon {
    background: var(--success-light);
    color: var(--success);
}

.stat-refunded .stat-icon {
    background: var(--info-light);
    color: var(--info);
}

.stat-rejected .stat-icon {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-docs-requested .stat-icon {
    background: #faf5ff;
    color: #7c3aed;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.stat-amount {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* Section */
.section {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.section-header h2 {
    font-size: 1.125rem;
    color: var(--gray-800);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--gray-50);
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table tbody tr[onclick] {
    cursor: pointer;
}

.amount {
    font-weight: 600;
    color: var(--gray-900);
}

.amount-large {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell form {
    margin-left: 0.25rem;
}

/* Status badges */
.status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending {
    background: var(--warning-light);
    color: #92400e;
}

.status-approved {
    background: var(--success-light);
    color: #166534;
}

.status-refunded {
    background: var(--info-light);
    color: #155e75;
}

.status-rejected {
    background: var(--danger-light);
    color: #991b1b;
}

.status-docs_requested {
    background: #faf5ff;
    color: #7c3aed;
}

.status-large {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

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

.empty-state p {
    margin-bottom: 1rem;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-bar span {
    color: var(--gray-600);
    font-weight: 500;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--gray-600);
    background: white;
    border: 1px solid var(--gray-300);
    transition: all 0.2s;
}

.filter-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Form Page */
.form-page {
    max-width: 640px;
    margin: 0 auto;
}

.form-container {
    background: white;
    border-radius: 0.75rem;
    padding: 2rem;
    box-shadow: var(--shadow);
}

/* Expense Detail */
.expense-detail {
    max-width: 800px;
    margin: 0 auto;
}

.back-link {
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.back-link:hover {
    color: var(--primary);
}

.detail-card {
    background: white;
    border-radius: 0.75rem;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.detail-item label {
    display: block;
    font-size: 0.8125rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.detail-item span {
    font-size: 1rem;
    color: var(--gray-800);
    font-weight: 500;
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section label {
    display: block;
    font-size: 0.8125rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.detail-section p {
    color: var(--gray-700);
    line-height: 1.6;
}

.detail-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--gray-500);
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

.review-notes {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

/* Admin Actions */
.admin-actions {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.action-forms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.action-form {
    padding: 1rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--gray-500);
    font-size: 0.875rem;
    background: white;
    border-top: 1px solid var(--gray-200);
}

/* 5-column stats grid */
.stats-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

/* Document Section */
.documents-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

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

.document-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.document-info {
    display: flex;
    flex-direction: column;
}

.document-name {
    font-weight: 500;
    color: var(--gray-800);
}

.document-meta {
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.no-documents {
    color: var(--gray-500);
    font-style: italic;
}

.upload-requested-notice {
    background: #faf5ff;
    border: 1px solid #e9d5ff;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
    color: #7c3aed;
}

.upload-form {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 0.5rem;
}

.upload-form-compact {
    padding: 0.75rem;
    margin-top: 0.75rem;
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.form-group-inline input[type="file"] {
    flex: 1;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.file-list {
    margin-top: 0.5rem;
}

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

.file-list li {
    padding: 0.5rem 0.75rem;
    background: var(--gray-100);
    border-radius: 0.25rem;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.file-list li.file-too-large {
    background: var(--danger-light);
    color: var(--danger);
}

.doc-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    background: var(--primary);
    color: white;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-info {
    color: var(--gray-600);
    font-style: italic;
}

/* Admin Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
}

.action-form-panel {
    display: none;
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--gray-50);
    border-radius: 0.5rem;
}

.action-form-panel.active {
    display: block;
}

.action-form-panel .form-group {
    margin-bottom: 1rem;
}

.action-form-panel .form-actions {
    margin-top: 1rem;
    justify-content: flex-start;
}

.status-notice {
    color: var(--gray-500);
    font-style: italic;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 1rem;
    }

    .nav-links {
        order: 3;
        width: 100%;
        padding-top: 1rem;
        justify-content: center;
        border-top: 1px solid var(--gray-200);
        margin-top: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid-5 {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-group-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .form-group-inline input[type="file"] {
        margin-bottom: 0.5rem;
    }

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

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

    .action-forms {
        grid-template-columns: 1fr;
    }
}
