* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; height: 100dvh; margin: 0; overflow: hidden; }
html { height: -webkit-fill-available; }
body {
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    font-family: 'Geist', system-ui, -apple-system, sans-serif;
    background: #f7f8f5;
    color: #0e0f0c;
    font-weight: 600;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "calt" 1;
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; position: relative; }

#sidebar {
    width: 220px; min-width: 220px;
    background: #0a1a06; color: #fff;
    display: flex; flex-direction: column;
    overflow: hidden;
    z-index: 40;
    transition: transform 0.25s ease;
}
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-logo { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-logo svg { width: 100%; height: 100%; }
.sidebar-link { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px; font-size: 0.8125rem; font-weight: 500; color: rgba(255,255,255,0.5); text-decoration: none; transition: all 0.15s; margin: 1px 8px; }
.sidebar-link:hover { background: rgba(159,232,112,0.08); color: #fff; }
.sidebar-link.active { background: #9fe870; color: #163300; font-weight: 600; }
.sidebar-link.active svg { color: #163300; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.06); padding: 12px 16px; }
.sidebar-footer .shadcn-btn-ghost { color: rgba(255,255,255,0.4); font-size: 0.75rem; padding: 6px 10px; height: 30px; border-radius: 6px; }
.sidebar-footer .shadcn-btn-ghost:hover { background: rgba(159,232,112,0.08); color: #fff; }
.sidebar-avatar { width: 28px; height: 28px; border-radius: 6px; background: rgba(255,255,255,0.06); display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.sidebar-hamburger { display: none; background: transparent; border: none; color: #868685; cursor: pointer; padding: 8px; border-radius: 6px; }
.sidebar-hamburger:hover { background: #e8ebe6; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 35; }

#mainContent { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
#topBar { display: flex; align-items: center; justify-content: space-between; padding: calc(12px + env(safe-area-inset-top)) 24px 12px; min-height: 57px; border-bottom: 1px solid rgba(14,15,12,0.12); background: #fff; flex-shrink: 0; gap: 12px; }
#pageTitle { font-size: 1.125rem; font-weight: 600; color: #0e0f0c; white-space: nowrap; }
#contentArea { flex: 1; overflow-y: auto; padding: 24px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* Thin scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(14,15,12,0.15); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(14,15,12,0.3); }
* { scrollbar-width: thin; scrollbar-color: rgba(14,15,12,0.15) transparent; }

.shadcn-card { border-radius: 12px; border: 1px solid rgba(14,15,12,0.12); background: #fff; box-shadow: rgba(14,15,12,0.12) 0px 0px 0px 1px; overflow: clip; }
.shadcn-card-header { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.shadcn-card-body { padding: 20px 24px; }
#actualPaymentsCard .shadcn-card-body { padding: 12px 24px; }
.shadcn-card-footer { padding: 16px 24px; border-top: 1px solid #e8ebe6; overflow: clip; }
.metric-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; color: #0e0f0c; }
.metric-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #868685; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }

.shadcn-btn { display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; font-size: 0.875rem; font-weight: 600; transition: all 0.15s; cursor: pointer; border: none; gap: 6px; padding: 8px 16px; height: 36px; text-decoration: none; font-feature-settings: "calt" 1; }
.shadcn-btn-primary { background: #9fe870; color: #163300; }
.shadcn-btn-primary:hover { transform: scale(1.05); background: #9fe870; }
.shadcn-btn-primary:active { transform: scale(0.95); }
.shadcn-btn-sm { padding: 4px 12px; height: 32px; font-size: 0.8125rem; }
.shadcn-btn-xs { padding: 2px 8px; height: 28px; font-size: 0.75rem; }
.shadcn-btn-outline { background: #fff; border: 1px solid rgba(14,15,12,0.12); color: #0e0f0c; }
.shadcn-btn-outline:hover { background: #e8ebe6; }
.shadcn-btn-ghost { background: transparent; color: #868685; border-radius: 12px; }
.shadcn-btn-ghost:hover { background: #e8ebe6; color: #0e0f0c; }
.dash-month-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #e8ebe6;
    border-radius: 10px;
    padding: 2px 4px;
    transition: background 0.15s ease;
}
.dash-month-bar:hover {
    background: #d3d6d0;
}
.shadcn-btn-danger { background: #d03238; color: #fff; }
.shadcn-btn-danger:hover { transform: scale(1.05); background: #d03238; }
.shadcn-btn-danger:active { transform: scale(0.95); }
.shadcn-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.shadcn-input { display: flex; height: 38px; width: 100%; border-radius: 8px; border: 1px solid rgba(14,15,12,0.12); background: #fff; padding: 0 13px; font-size: 0.875rem; font-weight: 500; outline: none; transition: border-color 0.15s; font-family: inherit; font-feature-settings: "calt" 1; }
.shadcn-input:focus { border-color: #9fe870; box-shadow: rgb(134,134,133) 0px 0px 0px 1px inset; }
.shadcn-input-sm { height: 34px; font-size: 0.8125rem; padding: 0 10px; }
textarea.shadcn-input { height: auto; min-height: 60px; padding-top: 8px; }
.shadcn-select { height: 38px; border-radius: 10px; border: 1px solid rgba(14,15,12,0.12); background: #fff; padding: 0 10px; font-size: 0.875rem; font-weight: 500; outline: none; cursor: pointer; font-family: inherit; font-feature-settings: "calt" 1; }
.shadcn-select:focus { border-color: #9fe870; }

.shadcn-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.shadcn-table th { text-align: center; padding: 12px 16px; font-weight: 600; color: #868685; border-bottom: 1px solid rgba(14,15,12,0.12); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.shadcn-table td { padding: 12px 16px; border-bottom: 1px solid #e8ebe6; font-weight: 500; }
.shadcn-table tbody tr:hover td { background: #e2f6d5; }

.shadcn-badge { display: inline-flex; align-items: center; border-radius: 9999px; padding: 2px 10px; font-size: 0.75rem; font-weight: 600; gap: 4px; cursor: pointer; }
.shadcn-badge-default { background: #e8ebe6; color: #0e0f0c; }
.shadcn-badge-active { background: #0e0f0c; color: #fff; }
.shadcn-badge-success { background: #e2f6d5; color: #054d28; }
.shadcn-badge-outline { background: transparent; border: 1px solid rgba(14,15,12,0.12); color: #868685; }

.shadcn-progress { height: 8px; border-radius: 9999px; background: #e8ebe6; overflow: hidden; }
.shadcn-progress-bar { height: 100%; border-radius: 9999px; background: #9fe870; transition: width 0.3s; }
.shadcn-checkbox { width: 16px; height: 16px; border-radius: 4px; border: 1px solid #868685; accent-color: #9fe870; cursor: pointer; }

.modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; background: rgba(14,15,12,0.4); }
.modal-open { display: flex; }
.modal-box { width: 100%; max-width: 480px; margin: 16px; border-radius: 12px; background: #fff; box-shadow: rgba(14,15,12,0.12) 0px 0px 0px 1px; overflow: clip; }
.modal-box-body { padding: 26px; }
.modal-box-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 20px 26px; border-top: 1px solid #e8ebe6; }
.modal-box h3 { color: #0e0f0c; font-size: 1.125rem; font-weight: 600; margin-bottom: 12px; }

.toast { position: fixed; bottom: 24px; right: 24px; z-index: 100; transition: all 0.2s; }
.toast.hidden { opacity: 0; pointer-events: none; }
.toast-inner { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 9999px; font-size: 0.875rem; font-weight: 600; box-shadow: rgba(14,15,12,0.12) 0px 0px 0px 1px; }
.toast-success { background: #054d28; color: #fff; }
.toast-error { background: #d03238; color: #fff; }

.dropzone { border: 2px dashed #868685; border-radius: 12px; padding: 24px; text-align: center; cursor: pointer; transition: all 0.15s; }
.dropzone:hover { border-color: #9fe870; background: #e2f6d5; }
.empty-state { text-align: center; padding: 48px 24px; color: #868685; font-size: 0.875rem; font-weight: 500; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }
.shadcn-table td.text-center { text-align: center !important; }
.shadcn-table td.font-mono { text-align: center !important; }
.shadcn-btn:focus-visible, .shadcn-input:focus-visible, .shadcn-select:focus-visible { outline: 2px solid #9fe870; outline-offset: 2px; }
@media (min-width: 769px) { .md-hidden { display: none !important; } }

#mobileNav { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid rgba(14,15,12,0.12); justify-content: space-around; align-items: center; }
.mobile-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px 4px; border-radius: 6px; border: none; background: transparent; color: #868685; font-size: 0.6rem; font-weight: 500; cursor: pointer; transition: all 0.15s; text-decoration: none; flex: 1 1 0; min-width: 0; max-width: 76px; min-height: 40px; }
.mobile-nav-item i { width: 20px; height: 20px; }
.mobile-nav-item:hover { color: #0e0f0c; background: #e8ebe6; }
.mobile-nav-item.active { color: #163300; background: #e2f6d5; font-weight: 600; border-radius: 6px; margin: 0; }
.mobile-nav-logout { max-width: 44px; }
.mobile-nav-logout span { font-size: 0.5rem; }

.mobile-more-panel { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; justify-content: flex-end; }
.mobile-more-panel.hidden { display: none; }
.mobile-more-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.3); }
.mobile-more-sheet { position: relative; background: #fff; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 4px; }
.mobile-more-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: none; background: transparent; border-radius: 10px; font-size: 0.875rem; font-weight: 500; color: #0e0f0c; cursor: pointer; width: 100%; text-align: left; font-family: inherit; }
.mobile-more-item:hover { background: #e8ebe6; }
.mobile-more-item i { width: 20px; height: 20px; color: #868685; flex-shrink: 0; }
.mobile-more-cancel { margin-top: 8px; justify-content: center; color: #868685; font-weight: 600; }

.dash-chart { height: 200px; }

@media (max-width: 768px) {
    #sidebar { display: none; }
    .sidebar-overlay { display: none !important; }
    .sidebar-hamburger { display: none !important; }
    #mobileNav { display: flex; }
    #mainContent { margin-left: 0; padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
    #contentArea { padding: 16px; }
    #topBar { padding: calc(12px + env(safe-area-inset-top)) 16px 12px; min-height: 52px; }
    #pageTitle { font-size: 1rem; }

    .dash-chart { height: 140px !important; }
    #expensesContainer .shadcn-table { min-width: 600px; }

    .stats-row { grid-template-columns: 1fr; }
    .shadcn-card-body { padding: 14px 16px; }
    #actualPaymentsCard .shadcn-card-body { padding: 10px 16px; }
    .shadcn-card-header { padding: 12px 16px; }
    .metric-value { font-size: 1.25rem; }
    .shadcn-table { min-width: 600px; }
    .overflow-x-auto { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    #tab-employees .flex.items-center.gap-3 { flex-direction: column; align-items: stretch; gap: 6px; }
    #tab-employees .flex.items-center.gap-3 > span { font-size: 0.65rem; }
    #tab-employees .shadcn-select { font-size: 0.7rem !important; height: 30px !important; padding: 0 6px; }
    #tab-employees #empCount { font-size: 0.6rem; margin-left: 0; width: 100%; text-align: left; }
    #tab-employees .overflow-x-auto { margin: 0 -16px; }

    #tab-groups .shadcn-card-header { flex-direction: column; align-items: stretch; gap: 10px; }
    #tab-groups .shadcn-card-header .flex.items-center.gap-4 { flex-direction: column; align-items: stretch; gap: 8px; }
    #tab-groups .shadcn-card-header .flex.items-center.gap-2 { flex-direction: row; width: 100%; }
    #tab-groups #empSearchInput { width: 100% !important; }

    #tab-groups .shadcn-card-header .flex.items-center.gap-4 { flex-direction: column; align-items: stretch; gap: 8px; }
    #tab-groups .shadcn-card-header .flex.items-center.gap-2 { flex-direction: row; }
    #tab-groups #empSearchInput { width: 100% !important; }
    #tab-groups #groupPanel { position: fixed; inset: 0; z-index: 45; width: 100%; background: #fff; border: none; padding: 16px; overflow-y: auto; }
    #tab-groups #groupPanel:not(.hidden) { display: block !important; }
    #tab-groups #groupPanel .flex.items-center.justify-between { position: sticky; top: 0; background: #fff; padding-bottom: 8px; z-index: 1; }
    #tab-groups .flex.gap-4 { flex-direction: column; }
}

@media print {
    #sidebar, #mobileNav, #topBar, .toast, #updateBanner { display: none !important; }
    #app, #mainContent, #contentArea { overflow: visible !important; height: auto !important; }
    body { font-size: 10pt; color: #000; background: #fff; }
    .shadcn-card { border: 1px solid #ccc; box-shadow: none; }
    .shadcn-btn { display: none !important; }
}
