* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f0f4f0; color: #222; }

/* Auth overlay */
#auth-overlay {
    position: fixed; inset: 0; background: linear-gradient(135deg, #2d5a27 0%, #1a3a15 100%);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
#auth-overlay.hidden { display: none; }
.auth-box { background: #fff; border-radius: 12px; padding: 32px; width: 340px; box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.auth-box h1 { text-align: center; color: #2d5a27; margin-bottom: 8px; font-size: 1.5em; }
.auth-box p { text-align: center; color: #666; margin-bottom: 20px; font-size: 0.9em; }
.auth-box input { width: 100%; padding: 10px; margin-bottom: 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 1em; }
.auth-box button { width: 100%; padding: 10px; background: #2d5a27; color: #fff; border: none; border-radius: 6px; font-size: 1em; cursor: pointer; }
.auth-box button:hover { background: #3d7a37; }
.auth-box .toggle { text-align: center; margin-top: 12px; font-size: 0.85em; color: #666; cursor: pointer; }
.auth-box .toggle:hover { color: #2d5a27; }
.auth-box .error { color: #c00; font-size: 0.85em; text-align: center; margin-bottom: 8px; }

/* Nav */
nav { background: #2d5a27; padding: 8px 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
nav .brand { color: #fff; font-weight: bold; font-size: 1.2em; margin-right: auto; }
nav button { background: rgba(255,255,255,0.15); color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 0.9em; }
nav button:hover, nav button.active { background: rgba(255,255,255,0.3); }
nav .logout { background: rgba(200,0,0,0.3); }

/* Content */
.container { max-width: 900px; margin: 16px auto; padding: 0 16px; }
.tab { display: none; }
.tab.active { display: block; }
.card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.card h2 { color: #2d5a27; margin-bottom: 12px; font-size: 1.2em; }

/* Forms */
.form-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.form-row input, .form-row select { flex: 1; min-width: 120px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.form-row textarea { flex: 1; min-width: 200px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; resize: vertical; }
.btn { padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer; font-size: 0.9em; }
.btn-green { background: #2d5a27; color: #fff; }
.btn-green:hover { background: #3d7a37; }
.btn-red { background: #c00; color: #fff; }
.btn-blue { background: #2563eb; color: #fff; }
.btn-gray { background: #666; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 0.8em; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th { background: #2d5a27; color: #fff; padding: 8px; text-align: left; font-size: 0.85em; }
td { padding: 8px; border-bottom: 1px solid #eee; font-size: 0.9em; }
tr:hover { background: #f9f9f9; }

/* Dashboard stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: #fff; border-radius: 8px; padding: 16px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.stat-card .number { font-size: 1.8em; font-weight: bold; color: #2d5a27; }
.stat-card .label { font-size: 0.8em; color: #666; }
.number-loss { color: #c00 !important; }

/* Status badges */
.badge { padding: 2px 8px; border-radius: 10px; font-size: 0.75em; font-weight: bold; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-unpaid { background: #fee2e2; color: #991b1b; }
.badge-done { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef3c7; color: #92400e; }

/* Calendar */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-header h2 { margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day-label { text-align: center; font-size: 0.75em; font-weight: bold; color: #666; padding: 4px; }
.cal-cell {
    min-height: 80px; background: #fff; border: 1px solid #e5e7eb; border-radius: 4px;
    padding: 4px; font-size: 0.8em; cursor: pointer; position: relative;
}
.cal-cell:hover { background: #f0fdf0; }
.cal-cell.today { border-color: #2d5a27; border-width: 2px; }
.cal-cell.other-month { background: #f9fafb; color: #aaa; }
.cal-cell .day-num { font-weight: bold; font-size: 0.85em; margin-bottom: 2px; }
.cal-job { background: #dcfce7; color: #166534; padding: 1px 4px; border-radius: 3px; margin-bottom: 2px; font-size: 0.75em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-job.completed { background: #e5e7eb; color: #666; text-decoration: line-through; }

/* Mobile header */
#mobile-header {
    display: none; background: #2d5a27; padding: 8px 16px;
    align-items: center; justify-content: space-between;
}
#mobile-header #mob-brand { color: #fff; font-weight: bold; font-size: 1.1em; }
#mobile-header #mob-logout {
    background: rgba(200,0,0,0.3); color: #fff; border: none;
    padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 0.85em;
}
/* Bottom tab bar */
#bottom-nav {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #2d5a27; z-index: 500; border-top: 2px solid #1a3a15; height: 56px;
}
#bottom-nav button {
    flex: 1; background: none; color: rgba(255,255,255,0.7); border: none;
    padding: 6px 4px 4px; font-size: 0.65em; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 1px; height: 100%;
}
#bottom-nav button.active, #bottom-nav button:hover { background: rgba(255,255,255,0.15); color: #fff; }
#bottom-nav button .icon { font-size: 1.3em; line-height: 1; }
/* More tray */
#more-tray {
    display: none; position: fixed; bottom: 56px; left: 0; right: 0;
    background: #1a3a15; z-index: 499; padding: 8px; flex-direction: column; gap: 4px;
}
#more-tray.open { display: flex; }
#more-tray button {
    background: rgba(255,255,255,0.1); color: #fff; border: none;
    padding: 12px 16px; border-radius: 6px; cursor: pointer; font-size: 0.9em; text-align: left;
}
#more-tray button:hover { background: rgba(255,255,255,0.2); }
/* Dark mode mobile */
body.dark #bottom-nav { background: #0f3460; border-top-color: #0a2848; }
body.dark #more-tray { background: #061a36; }
body.dark #mobile-header { background: #0f3460; }
@media (max-width: 600px) {
    #main-nav { display: none !important; }
    #mobile-header { display: flex; }
    #bottom-nav { display: flex; }
    .container { padding-bottom: 68px; }
    #toast-container { top: auto; bottom: 72px; right: 8px; left: 8px; align-items: center; }
    .cal-cell { min-height: 50px; }
    nav { padding: 8px; }
    nav button { padding: 6px 10px; font-size: 0.8em; }
    .form-row { flex-direction: column; }
}

/* Dark mode */
body.dark { background: #1a1a2e; color: #e0e0e0; }
body.dark .card { background: #16213e; box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
body.dark .card h2 { color: #4ade80; }
body.dark nav { background: #0f3460; }
body.dark input, body.dark select, body.dark textarea { background: #1a1a2e; color: #e0e0e0; border-color: #333; }
body.dark th { background: #0f3460; }
body.dark td { border-color: #333; }
body.dark tr:hover { background: #1a1a2e; }
body.dark .stat-card { background: #16213e; }
body.dark .stat-card .number { color: #4ade80; }
body.dark .cal-cell { background: #16213e; border-color: #333; }
body.dark .cal-cell:hover { background: #1a2a4e; }
body.dark .cal-cell.other-month { background: #111; color: #555; }
body.dark .cal-cell.today { border-color: #4ade80; }
body.dark .auth-box { background: #16213e; }
body.dark .auth-box h1 { color: #4ade80; }
body.dark .auth-box input { background: #1a1a2e; color: #e0e0e0; border-color: #333; }
body.dark .auth-box button { background: #0f3460; }
body.dark .auth-box .toggle { color: #999; }

/* Toast notifications */
#toast-container {
    position: fixed; top: 16px; right: 16px; z-index: 9999;
    display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
    padding: 12px 20px; border-radius: 8px; color: #fff; font-size: 0.9em;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2); opacity: 1;
    transition: opacity 0.4s; max-width: 320px; pointer-events: auto;
}
.toast-success { background: #2d5a27; }
.toast-error { background: #c00; }
.toast-info { background: #2563eb; }
.toast.fade-out { opacity: 0; }

/* Dashboard month nav */
.dashboard-month-nav {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    padding: 10px 0 6px; font-size: 1.1em; font-weight: bold; color: #2d5a27;
}
.month-nav-btn {
    background: none; border: 1px solid #2d5a27; border-radius: 50%;
    width: 32px; height: 32px; font-size: 1.2em; color: #2d5a27;
    cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.month-nav-btn:hover:not(:disabled) { background: #dcfce7; }
.month-nav-btn:disabled { opacity: 0.35; cursor: default; }
body.dark .dashboard-month-nav { color: #4ade80; }
body.dark .month-nav-btn { border-color: #4ade80; color: #4ade80; }
body.dark .month-nav-btn:hover:not(:disabled) { background: #14532d; }

/* Bulk done bar */
#bulk-done-bar {
    display: none;
    position: fixed; bottom: 64px; left: 0; right: 0;
    background: #2d5a27; color: #fff; padding: 12px 20px;
    align-items: center; justify-content: space-between;
    z-index: 200; box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
}
#bulk-done-bar #bulk-done-count { font-weight: bold; font-size: 1em; }
