/**
 * Regatta Expenses - Clean Modern Design
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&subset=cyrillic,latin&display=swap');

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

:root {
    --primary: #0369a1;
    --primary-dark: #075985;
    --primary-light: #e0f2fe;
    
    --dark: #111827;
    --gray-800: #1f2937;
    --gray-700: #374151;
    --gray-600: #4b5563;
    --gray-500: #6b7280;
    --gray-400: #9ca3af;
    --gray-300: #d1d5db;
    --gray-200: #e5e7eb;
    --gray-100: #f3f4f6;
    --white: #ffffff;
    
    --success: #059669;
    --success-bg: #d1fae5;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --radius: 12px;
}

html { font-size: 16px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--dark);
    background: var(--gray-100);
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* Typography */
h1 { 
    font-size: 1.625rem; 
    font-weight: 700; 
    letter-spacing: -0.025em; 
    white-space: nowrap;
    color: var(--dark);
}

h2 { 
    font-size: 1.125rem; 
    font-weight: 600; 
    letter-spacing: -0.02em;
    white-space: nowrap;
    color: var(--dark);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Icons - small by default */
.icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 40px; height: 40px; }

/* Layout */
.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 900px; margin: 0 auto; padding: 0 16px; }
main { flex: 1; padding: 20px 0 40px; }

/* ===== Header ===== */
.header { 
    background-color: var(--dark);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='16' viewBox='0 0 80 16' preserveAspectRatio='none'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-opacity='0.08' stroke-width='2' stroke-linecap='round' d='M0 8 Q20 0 40 8 Q60 16 80 8'/%3E%3C/svg%3E");
    background-size: 50px 10px;
    background-repeat: repeat;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--white);
    white-space: nowrap;
}

.logo:hover { text-decoration: none; color: var(--white); }
.logo svg { width: 22px; height: 22px; flex-shrink: 0; }

.role-badge {
    background: var(--primary);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.role-toggle {
    cursor: pointer;
    transition: background 0.15s;
}

.role-toggle:hover {
    background: var(--primary-dark);
    text-decoration: none;
    color: var(--white);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--gray-400);
    font-size: 0.875rem;
    padding: 8px 12px;
    border-radius: 8px;
    white-space: nowrap;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
    text-decoration: none;
}

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

/* Navigation */
.nav-main { 
    background: var(--dark);
    border-top: 1px solid rgba(255,255,255,0.08);
}

.nav-main > .container {
    display: flex;
    height: 48px;
    align-items: center;
    gap: 4px;
}

.nav-main a {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-400);
    border-radius: 8px;
    white-space: nowrap;
}

.nav-main a:hover {
    color: var(--white);
    background: rgba(255,255,255,0.08);
    text-decoration: none;
}

.nav-main a.active {
    color: var(--white);
    background: var(--primary);
}

.nav-main a svg { width: 16px; height: 16px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    padding: 0 20px;
    font-family: inherit;
    font-size: 0.938rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }

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

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 2px solid var(--gray-300);
}
.btn-secondary:hover { border-color: var(--gray-400); }

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

.btn-sm { height: 36px; padding: 0 14px; font-size: 0.875rem; }

.btn-action { 
    min-width: 150px; 
    justify-content: center;
    text-align: center;
}

.btn-action-form {
    flex: 0 0 auto;
}

.btn-gold {
    background: linear-gradient(135deg, #f7e89e 0%, #d4af37 25%, #f7e89e 50%, #d4af37 75%, #c5a028 100%);
    background-size: 200% 200%;
    color: #5c4813;
    border: 1px solid #b8960c;
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.5),
        inset 0 -1px 0 rgba(0,0,0,0.1);
    font-weight: 700;
}

.btn-gold:hover {
    background-position: 100% 100%;
    color: #4a3a0f;
    box-shadow: 
        0 4px 12px rgba(212,175,55,0.4),
        inset 0 1px 0 rgba(255,255,255,0.6),
        inset 0 -1px 0 rgba(0,0,0,0.1);
}

.btn-gold:active {
    box-shadow: 
        0 1px 2px rgba(0,0,0,0.3),
        inset 0 2px 4px rgba(0,0,0,0.1);
}

.btn-receipt {
    height: 36px;
    padding: 0 12px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.875rem;
}
.btn-receipt:hover { background: var(--primary); color: var(--white); }

.btn-group { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-block { width: 100%; }

.btn-group-split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.btn-group-split .btn-group {
    flex-wrap: nowrap;
}

@media (max-width: 600px) {
    .btn-group {
        width: 100%;
        gap: 8px;
    }
    
    .btn-group-split {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .btn-group-split > .btn {
        width: 100%;
        justify-content: center;
    }
    .btn-group .btn-action,
    .btn-group .btn-action-form {
        flex: 1 1 0;
        min-width: 0;
    }
    .btn-action-form .btn-action {
        width: 100%;
    }
    .btn-group > .btn {
        flex: 1 1 0;
        min-width: 0;
        justify-content: center;
    }
}

/* ===== Cards ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.card-header h2 {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 1rem;
    white-space: nowrap;
}

.card-header h2 svg { 
    width: 18px; 
    height: 18px; 
    color: var(--primary); 
    flex-shrink: 0;
}

.card-body { padding: 16px; }
.card-body:has(.form-control) { padding: 16px !important; }

/* ===== Stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--white);
    padding: 16px 8px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--primary);
    white-space: nowrap;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-top: 4px;
    text-transform: uppercase;
}

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

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

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

.table th {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray-500);
    background: var(--gray-100);
}

.table tbody tr:hover { background: var(--gray-100); }
.table .text-right { text-align: right; }

.expense-payer { font-weight: 700; color: var(--dark); }
.expense-date { font-size: 0.875rem; color: var(--gray-500); }

/* ===== Mobile Cards ===== */
.cards-list { display: none; }

@media (max-width: 700px) {
    .table-responsive { display: none; }
    
    .cards-list { display: block; }
    
    .data-card {
        padding: 14px 16px;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .data-card:last-child { border-bottom: none; }
    
    .data-card-header {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        margin-bottom: 10px;
    }
    
    .data-card-header .expense-payer { font-size: 1.05rem; }
    .data-card-header .expense-date { font-size: 0.875rem; }
    
    .data-card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
    }
    
    .data-card-label { font-size: 0.938rem; color: var(--gray-600); }
    .data-card-value { font-size: 1rem; font-weight: 700; color: var(--dark); }
    
    .data-card-actions {
        display: flex;
        gap: 10px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--gray-200);
    }
    
    .data-card-actions .btn { flex: 1; }
}

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }

.form-inline-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-inline-group .form-control {
    flex: 1 1 auto;
    height: 48px;
    min-height: 48px;
}

.form-inline-group .btn {
    width: 100%;
    justify-content: center;
}

@media (min-width: 601px) {
    .form-inline-group {
        flex-direction: row;
        align-items: center;
    }
    
    .form-inline-group .btn {
        width: auto;
        flex-shrink: 0;
    }
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: 0.938rem;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    font-family: inherit;
    font-size: 1rem;
    border: 2px solid var(--gray-300);
    border-radius: 10px;
    background: var(--white);
    color: var(--dark);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

select.form-control {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 44px;
}

textarea.form-control {
    height: auto;
    min-height: 100px;
    padding: 14px 16px;
    resize: vertical;
}

.form-text {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 6px;
}

/* ===== Alerts ===== */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.938rem;
    font-weight: 500;
}

.alert svg { width: 20px; height: 20px; flex-shrink: 0; }

.alert-success { background: var(--success-bg); color: #065f46; }
.alert-danger { background: var(--danger-bg); color: #991b1b; }
.alert-warning { background: var(--warning-bg); color: #92400e; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state svg {
    width: 40px;
    height: 40px;
    color: var(--gray-400);
    margin-bottom: 16px;
}

.empty-state h3 { font-size: 1.125rem; margin-bottom: 8px; }
.empty-state p { color: var(--gray-500); margin-bottom: 16px; }

/* ===== Upload ===== */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    background: var(--gray-100);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone svg {
    width: 36px;
    height: 36px;
    color: var(--gray-400);
    margin-bottom: 12px;
}

.upload-zone-text { font-size: 1rem; font-weight: 600; color: var(--gray-700); }
.upload-zone-hint { font-size: 0.875rem; color: var(--gray-500); margin-top: 6px; }

.upload-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    justify-content: center;
}

.file-preview-list { margin-top: 16px; }

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-100);
    border-radius: 8px;
    margin-bottom: 8px;
}

.file-preview-img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.file-preview-name { flex: 1; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-size { font-size: 0.813rem; color: var(--gray-500); }

.receipts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.receipt-thumb {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid var(--gray-200);
    position: relative;
}

.receipt-thumb:hover { border-color: var(--primary); }
.receipt-thumb img { width: 100%; height: 100%; object-fit: cover; }

.receipt-thumb .delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.receipt-thumb:hover .delete-btn { opacity: 1; }

/* ===== Lightbox ===== */
/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 90vh;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: var(--white);
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
}

.lightbox-close:hover { background: rgba(255,255,255,0.25); }

.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: var(--white);
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
}

.lightbox-nav:hover { background: rgba(255,255,255,0.25); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.lightbox-counter {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 0.875rem;
    background: rgba(0,0,0,0.5);
    padding: 6px 12px;
    border-radius: 20px;
}

/* ===== Section Title ===== */
.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 16px;
    white-space: nowrap;
}

.section-title svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ===== Expense Credit Cards ===== */
.expense-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.expense-card {
    position: relative;
    border-radius: 16px;
    padding: 20px;
    color: #fff;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.expense-card-clickable:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

.expense-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle at center, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.expense-card-chip {
    width: 40px;
    height: 28px;
    background: linear-gradient(135deg, #f0d850 0%, #d4a800 50%, #f0d850 100%);
    border-radius: 5px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.expense-card-chip::before {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 3px;
}

.expense-card-chip::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 3px;
    bottom: 3px;
    width: 1px;
    background: rgba(0,0,0,0.2);
}

.expense-card-amount {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 8px;
    white-space: nowrap;
}

.expense-card-desc {
    font-size: 0.875rem;
    opacity: 0.85;
    flex-grow: 1;
    margin-bottom: 12px;
    line-height: 1.4;
}

.expense-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.expense-card-holder,
.expense-card-date {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.expense-card-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
}

.expense-card-name,
.expense-card-value {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.expense-card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
}

.expense-card-clickable {
    cursor: pointer;
}

.expense-card-clickable:active {
    transform: translateY(-2px) scale(0.98);
}

.expense-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.expense-card-top .expense-card-chip {
    margin-bottom: 0;
}

.expense-card-receipts {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 40px;
    height: 28px;
    background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.1) 100%);
    border-radius: 5px;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.2);
}

.expense-card-receipts svg {
    width: 14px;
    height: 14px;
}

.expense-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.expense-card-btn:hover {
    background: rgba(255,255,255,0.35);
    color: #fff;
}

.expense-card-btn svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 480px) {
    .expense-cards-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .expense-card {
        min-height: 160px;
        padding: 16px;
    }
    
    .expense-card-chip,
    .expense-card-receipts {
        width: 36px;
        height: 24px;
    }
    
    .expense-card-top {
        margin-bottom: 12px;
    }
    
    .expense-card-amount {
        font-size: 1.5rem;
    }
}

/* ===== Crew Badges ===== */
.crew-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.crew-badge {
    position: relative;
    background: linear-gradient(160deg, #0f2138 0%, #1a3550 40%, #0f2138 100%);
    border-radius: 20px;
    padding: 32px 20px 24px;
    text-align: center;
    color: #fff;
    box-shadow: 
        0 8px 32px rgba(0,0,0,0.25),
        0 2px 8px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.12),
        inset 0 -2px 0 rgba(0,0,0,0.15);
    overflow: hidden;
    border: 1px solid rgba(212,175,55,0.25);
    transform: perspective(1000px) rotateX(2deg);
    transform-style: preserve-3d;
}

.crew-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(212,175,55,0.5) 50%, transparent 100%);
}

.crew-badge::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(212,175,55,0.03) 0%, transparent 50%);
    pointer-events: none;
}

.crew-badge-avatar {
    position: relative;
    z-index: 1;
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: linear-gradient(145deg, #d4af37 0%, #f5e6a3 30%, #d4af37 60%, #a38728 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a2f4a;
    box-shadow: 
        0 6px 20px rgba(212,175,55,0.4),
        inset 0 2px 4px rgba(255,255,255,0.5),
        inset 0 -2px 4px rgba(0,0,0,0.2);
    border: 3px solid rgba(255,255,255,0.3);
    text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

.crew-badge-name {
    position: relative;
    z-index: 1;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
}

.crew-badge-meta {
    position: relative;
    z-index: 1;
    font-size: 0.75rem;
    color: rgba(212,175,55,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
    letter-spacing: 0.3px;
    min-height: 20px;
}

.crew-badge-status-inactive {
    color: rgba(255,255,255,0.5);
    font-weight: 500;
}

.crew-badge-locked {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #d4af37;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
}

.crew-badge-locked svg {
    width: 11px;
    height: 11px;
    opacity: 0.9;
}

/* Inactive badge state */
.crew-badge-inactive {
    background: linear-gradient(160deg, #1a1a1a 0%, #2a2a2a 50%, #1a1a1a 100%);
    border-color: rgba(255,255,255,0.1);
    opacity: 0.7;
}

.crew-badge-inactive::before {
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
}

.crew-badge-inactive .crew-badge-avatar {
    background: linear-gradient(145deg, #666 0%, #888 30%, #666 60%, #555 100%);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.crew-badge-inactive:not(.crew-badge-static):hover {
    opacity: 1;
}

/* Toggle form/button (only for accountant) */
.crew-badge-toggle-form {
    display: contents;
}

.crew-badge-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    text-align: center;
    transition: transform 0.15s;
}

.crew-badge-toggle:hover {
    transform: scale(1.02);
}

/* Non-clickable badge for viewers */
.crew-badge-static {
    cursor: default;
}

.crew-badge-static .crew-badge-avatar,
.crew-badge-static .crew-badge-name,
.crew-badge-static .crew-badge-meta {
    pointer-events: none;
}

.crew-badge-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    z-index: 2;
}

.crew-badge-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: linear-gradient(145deg, rgba(212,175,55,0.2) 0%, rgba(212,175,55,0.1) 100%);
    border: 1px solid rgba(212,175,55,0.3);
    border-radius: 12px;
    color: #d4af37;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.crew-badge-btn:hover {
    background: linear-gradient(145deg, rgba(212,175,55,0.4) 0%, rgba(212,175,55,0.2) 100%);
    color: #f5e6a3;
    transform: scale(1.05);
}

.crew-badge-btn-danger {
    background: linear-gradient(145deg, rgba(239,68,68,0.2) 0%, rgba(239,68,68,0.1) 100%);
    border-color: rgba(239,68,68,0.3);
    color: #f87171;
}

.crew-badge-btn-danger:hover {
    background: linear-gradient(145deg, rgba(239,68,68,0.4) 0%, rgba(239,68,68,0.2) 100%);
    color: #fca5a5;
}

.crew-badge-btn svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 480px) {
    .crew-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .crew-badge {
        padding: 28px 14px 20px;
        border-radius: 16px;
    }
    
    .crew-badge-avatar {
        width: 56px;
        height: 56px;
        font-size: 1.4rem;
        margin-bottom: 12px;
    }
    
    .crew-badge-name {
        font-size: 0.95rem;
    }
    
    .crew-badge-actions {
        top: 8px;
        right: 8px;
        gap: 6px;
    }
    
    .crew-badge-btn {
        width: 36px;
        height: 36px;
    }
    
    .crew-badge-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* ===== Balances ===== */
.balance-positive { color: var(--success); font-weight: 800; white-space: nowrap; }
.balance-negative { color: var(--danger); font-weight: 800; white-space: nowrap; }
.balance-zero { color: var(--gray-500); font-weight: 600; white-space: nowrap; }

/* ===== Transfers ===== */
.transfer-list { display: flex; flex-direction: column; gap: 10px; }

.transfer-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--gray-100);
    border-radius: 10px;
    border-left: 4px solid var(--primary);
}

.transfer-from { font-weight: 700; color: var(--danger); }
.transfer-arrow { color: var(--gray-400); }
.transfer-arrow svg { width: 18px; height: 18px; }
.transfer-to { font-weight: 700; color: var(--success); }

.transfer-amount {
    margin-left: auto;
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}

/* Grouped Transfers */
.transfers-grouped {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.debtor-group {
    background: var(--gray-100);
    border-radius: 12px;
    padding: 16px;
    border-left: 4px solid var(--danger);
}

.debtor-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--gray-300);
}

.debtor-debts {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.debt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--white);
    border-radius: 8px;
}

.debt-arrow {
    color: var(--gray-400);
    flex-shrink: 0;
}

.debt-arrow svg {
    width: 16px;
    height: 16px;
}

.debt-to {
    font-weight: 600;
    color: var(--success);
    flex: 1;
}

.debt-amount {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

@media (max-width: 480px) {
    .debtor-group {
        padding: 14px;
    }
    
    .debtor-name {
        font-size: 1rem;
    }
    
    .debt-item {
        padding: 6px 10px;
    }
    
    .debt-amount {
        font-size: 0.95rem;
    }
}

/* ===== Status ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-open { background: var(--success-bg); color: var(--success); }
.status-closed { background: var(--gray-200); color: var(--gray-600); }

/* ===== Login ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--dark) 0%, #1e3a5f 100%);
}

.login-card { width: 100%; max-width: 400px; }
.login-card .card-body { padding: 32px 24px; }

.login-header { text-align: center; margin-bottom: 28px; }
.login-header svg { width: 48px; height: 48px; color: var(--primary); margin-bottom: 16px; }
.login-header h1 { font-size: 1.5rem; margin-bottom: 6px; white-space: normal; }
.login-header p { color: var(--gray-500); }

/* ===== Utilities ===== */
.hidden { display: none !important; }
.text-muted { color: var(--gray-500); }
.text-small { font-size: 0.875rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 12px; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .container { padding: 0 12px; }
    
    h1 { font-size: 1.25rem; }
    
    .header-inner { height: 52px; }
    
    .logo { font-size: 1rem; }
    .logo svg { width: 20px; height: 20px; }
    
    .role-badge { font-size: 0.6rem; padding: 4px 8px; }
    
    .btn-logout span { display: none; }
    .btn-logout { padding: 8px; }
    
    .nav-main > .container { 
        height: auto; 
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }
    .nav-main a { 
        flex: 1 1 auto;
        min-width: 0;
        padding: 0 8px; 
        height: 40px; 
        font-size: 0.813rem;
        justify-content: center;
    }
    .nav-main a svg { width: 14px; height: 14px; }
    
    .stats-grid { gap: 8px; }
    .stat-card { padding: 12px 6px; }
    .stat-value { font-size: 1.1rem; }
    .stat-label { font-size: 0.7rem; }
    
    .btn-action { 
        min-width: 0; 
        flex: 1 1 0; 
        font-size: 0.875rem; 
        padding: 0 12px;
    }
    
    .card-header { padding: 12px 14px; }
    .card-header h2 { font-size: 0.938rem; }
    .card-header h2 svg { width: 16px; height: 16px; }
    
    .card:has(.cards-list) > .card-body { padding: 0; }
    .card:has(.table-responsive) > .card-body { padding: 0; }
    
    .data-card { padding: 12px 14px; }
}

@media (max-width: 360px) {
    .container { padding: 0 8px; }
    
    .nav-main a { 
        padding: 0 6px; 
        height: 36px; 
        font-size: 0.75rem; 
    }
    .nav-main a svg { width: 12px; height: 12px; }
    
    .btn-action {
        height: 40px;
        font-size: 0.8rem;
        padding: 0 8px;
    }
    .btn-action svg { width: 14px; height: 14px; }
    
    h1 { font-size: 1.25rem; }
    
    .expense-card { padding: 14px; min-height: 150px; }
    .expense-card-amount { font-size: 1.35rem; }
    .expense-card-chip,
    .expense-card-receipts { width: 32px; height: 22px; }
    .expense-card-top { margin-bottom: 10px; }
    
    .stat-value { font-size: 1rem; }
}

@media (min-width: 768px) {
    .stat-value { font-size: 1.5rem; }
    main { padding: 28px 0 50px; }
}

/* ===== Period Cards ===== */
.periods-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.period-card {
    background: var(--white);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.period-card-open {
    border-left: 4px solid var(--primary);
}

.period-card-main {
    display: flex;
    align-items: center;
    gap: 24px;
    flex: 1;
    min-width: 0;
}

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

.period-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
}

.period-card-dates {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.period-card-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.period-card-amount {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--dark);
    white-space: nowrap;
}

.period-card-action {
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .period-card {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 16px;
    }
    
    .period-card-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .period-card-stats {
        width: 100%;
        justify-content: space-between;
    }
    
    .period-card-action .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Print */
@media print {
    .header, .btn, .upload-zone, .data-card-actions { display: none !important; }
    body { background: white; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
