:root {
    --bg-primary: #0B0F19;
    --bg-secondary: #111827;
    --bg-surface: #1A1F2E;
    --bg-surface-hover: #222840;
    --bg-elevated: #252B3B;
    --border: #2A3144;
    --border-light: #374151;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent-cyan: #06B6D4;
    --accent-cyan-dim: rgba(6, 182, 212, 0.15);
    --accent-purple: #8B5CF6;
    --accent-purple-dim: rgba(139, 92, 246, 0.15);
    --accent-amber: #F59E0B;
    --accent-green: #10B981;
    --accent-rose: #EC4899;
    --accent-red: #EF4444;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
#sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-cyan);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav-links {
    list-style: none;
    padding: 12px 10px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-link:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
}

/* Main Content */
#content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.view-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-toggle {
    display: flex;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.toggle-btn {
    padding: 10px 18px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

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

.toggle-btn.active {
    background: var(--accent-cyan);
    color: #0B0F19;
}

/* Pillbox Filter */
.pillbox {
    display: flex;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
}

.pill {
    cursor: pointer;
    user-select: none;
    margin: 0;
}

.pill input { display: none; }

.pill-label {
    display: block;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition);
}

.pill-label:hover {
    color: var(--text-secondary);
}

.pill input:checked + .pill-label {
    background: var(--accent-cyan);
    color: #0B0F19;
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--accent-cyan);
    color: #0B0F19;
}

.btn-primary:hover {
    background: #22D3EE;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.btn-danger {
    background: transparent;
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--card-accent, var(--accent-cyan));
}

.card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

.card-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.card-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-cost {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cost-label { font-size: 12px; color: var(--text-muted); }
.cost-value { font-size: 18px; font-weight: 700; color: var(--accent-green); }

.card-people {
    display: flex;
    gap: 4px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.person-chip {
    padding: 2px 8px;
    background: var(--bg-elevated);
    border-radius: 12px;
    font-size: 11px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* FullCalendar Dark Theme */
#calendar {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-surface);
}

.fc {
    --fc-border-color: var(--border);
    --fc-page-bg-color: var(--bg-surface);
    --fc-neutral-bg-color: var(--bg-secondary);
    --fc-list-event-hover-bg-color: var(--bg-surface-hover);
    --fc-today-bg-color: rgba(6, 182, 212, 0.08);
    --fc-event-border-color: transparent;
    --fc-neutral-text-color: var(--text-secondary);
    --fc-button-bg-color: var(--bg-elevated);
    --fc-button-border-color: var(--border);
    --fc-button-text-color: var(--text-primary);
    --fc-button-hover-bg-color: var(--bg-surface-hover);
    --fc-button-hover-border-color: var(--border-light);
    --fc-button-active-bg-color: var(--accent-cyan);
    --fc-button-active-border-color: var(--accent-cyan);
    font-family: inherit;
}

.fc .fc-toolbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.fc .fc-button {
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    box-shadow: none !important;
    text-transform: capitalize;
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    color: #0B0F19;
}

.fc .fc-col-header-cell {
    background: var(--bg-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 0;
}

.fc .fc-col-header-cell-cushion {
    color: var(--text-secondary);
    text-decoration: none;
}

.fc .fc-daygrid-day-number {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    padding: 6px 10px;
}

.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
    background: var(--accent-cyan);
    color: #0B0F19;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 4px 4px 0 auto;
}

.fc .fc-daygrid-day.fc-day-other .fc-daygrid-day-number {
    color: var(--text-muted);
    opacity: 0.5;
}

.fc .fc-daygrid-day-frame {
    min-height: 100px;
}

.fc .fc-daygrid-event {
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    margin: 1px 2px;
    border: none;
    cursor: pointer;
}

.fc .fc-daygrid-event .fc-event-title {
    font-weight: 600;
}

.fc .fc-daygrid-event .fc-event-main {
    color: #fff;
}

.fc .fc-daygrid-dot-event .fc-event-title {
    font-weight: 600;
}

.fc .fc-h-event {
    border: none;
}

.fc .fc-daygrid-more-link {
    color: var(--accent-cyan);
    font-size: 12px;
    font-weight: 600;
}

.fc .fc-popover {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.fc .fc-popover-header {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
}

.fc .fc-popover-body {
    padding: 4px;
}

.fc-theme-standard td,
.fc-theme-standard th {
    border-color: var(--border);
}

.fc .fc-scrollgrid {
    border-color: var(--border);
}

.fc-day-sat,
.fc-day-sun {
    background: rgba(0, 0, 0, 0.15);
}

.fc .fc-daygrid-event-harness {
    margin-bottom: 1px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.open {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 520px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

/* Forms */
.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-dim);
}

.form-group input[type="color"] {
    height: 40px;
    padding: 4px;
    cursor: pointer;
}

.form-group select[multiple] {
    min-height: 80px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-cyan);
    cursor: pointer;
}

.confirmed-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-green);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
    margin-left: 4px;
}

.cal-confirmed {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.9);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
    cursor: default;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Detail Panel */
.detail-panel {
    position: fixed;
    top: 0;
    right: -520px;
    width: 520px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 900;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
}

.detail-panel.open { right: 0; }

.detail-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 850;
    background: rgba(0, 0, 0, 0.3);
}

.detail-overlay.open { display: block; }

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
    gap: 12px;
}

.detail-header h2 {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
    min-width: 0;
}

.detail-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.icon-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-light);
}

#detail-body {
    padding: 24px;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.detail-field {
    margin-bottom: 12px;
}

.detail-link {
    display: block;
    padding: 8px 10px;
    font-size: 14px;
    color: var(--accent-cyan);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
    text-decoration: none;
    border-radius: var(--radius-sm);
}

.detail-link:hover {
    background: var(--bg-surface-hover);
}

.detail-link:last-child {
    border-bottom: none;
}

.detail-inline-link {
    display: inline;
    padding: 0;
    font-size: inherit;
    color: var(--accent-cyan);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.detail-inline-link:hover {
    color: #22D3EE;
}

.detail-field-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.detail-field-value {
    font-size: 14px;
    color: var(--text-primary);
}

/* Line Items Table */
.line-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.line-items-table th {
    text-align: left;
    padding: 8px 10px;
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}

.line-items-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.line-items-table .amount {
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.line-items-table .total-row td {
    font-weight: 700;
    color: var(--accent-green);
    border-top: 2px solid var(--border-light);
    padding-top: 10px;
}

.line-items-table .delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    transition: color var(--transition);
}

.line-items-table .delete-btn:hover { color: var(--accent-red); }

/* Add line item form */
.add-line-item {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    align-items: flex-end;
}

.add-line-item input {
    flex: 1;
    padding: 7px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
}

.add-line-item input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

/* Inline edit mode in detail panel */
.detail-edit-group {
    margin-bottom: 14px;
}

.detail-edit-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.detail-edit-group input,
.detail-edit-group textarea,
.detail-edit-group select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
}

.detail-edit-group input:focus,
.detail-edit-group textarea:focus,
.detail-edit-group select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-dim);
}

.detail-edit-group select[multiple] {
    min-height: 72px;
}

.detail-edit-group input[type="color"] {
    height: 36px;
    padding: 3px;
    cursor: pointer;
}

.detail-edit-row {
    display: flex;
    gap: 12px;
}

.detail-edit-row .detail-edit-group {
    flex: 1;
}

.detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    z-index: 2000;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow);
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* List View */
.list-section {
    margin-bottom: 36px;
}

.list-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.list-section-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

#list-events-toggle,
#list-campaigns-toggle {
    padding: 8px 14px;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.data-table thead th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr {
    cursor: pointer;
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-surface-hover);
}

.data-table tbody tr.row-past {
    opacity: 0.6;
}

.data-table tbody tr.row-past:hover {
    opacity: 0.8;
}

.data-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

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

.data-table .col-color {
    width: 6px;
    padding: 0;
}

.data-table .color-dot {
    width: 6px;
    height: 100%;
    min-height: 38px;
    display: block;
}

.data-table .row-name {
    font-weight: 600;
    color: var(--text-primary);
}

.data-table .col-cost {
    text-align: right;
}

.data-table .row-cost {
    text-align: right;
    font-weight: 700;
    color: var(--accent-green);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.data-table .row-people {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* Login Page */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    width: 360px;
    max-width: 90vw;
    box-shadow: var(--shadow);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 14px;
}
