:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --green: #16a34a;
    --red: #dc2626;
    --amber: #d97706;
    --nav-height: 64px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.4;
}

.hidden { display: none !important; }
.flex-1 { flex: 1; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.p-0 { padding: 0 !important; }
.text-green { color: var(--green); font-weight: 600; }
.text-red { color: var(--red); font-weight: 600; }

/* LOGIN */
.screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    background: var(--card);
    width: 100%;
    max-width: 380px;
    padding: 28px 22px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.login-card h2 { margin-bottom: 4px; font-size: 22px; }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-hint {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

/* HEADER & LAYOUT */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--card);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 { font-size: 18px; font-weight: 700; }
.user-badge { font-size: 12px; color: var(--muted); }

.app-content {
    padding: 12px 12px calc(var(--nav-height) + 24px);
    max-width: 680px;
    margin: 0 auto;
}

/* CARDS & FORMS */
.card {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
    overflow: hidden;
}

.card-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 14px; }

.form-group { margin-bottom: 12px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 4px;
}

.form-row { display: flex; gap: 10px; }

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
    color: var(--text);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-danger { background: var(--red); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.error-msg { color: var(--red); font-size: 13px; margin-bottom: 10px; }

/* FILTER BAR */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}
.filter-item label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 3px;
}

.alert-banner {
    background: #fef3c7;
    color: #92400e;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 10px;
}

/* CALENDAR */
.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    padding: 8px 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-cell {
    min-height: 76px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    background: #fff;
}

.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.empty { background: #f8fafc; cursor: default; }
.cal-cell.readonly { background: #fafafa; }

.cal-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cal-day-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.cal-add-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #eff6ff;
    color: var(--primary);
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
}

.cal-tags {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
}

.tag {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 3px;
    border-radius: 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tag-leave { background: #fee2e2; color: #b91c1c; }
.tag-visit { background: #dbeafe; color: #1e40af; }
.tag-help { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.tag-ot { background: #dcfce7; color: #15803d; }
.tag-adv { background: #fef3c7; color: #b45309; }

/* TABLE (SETUP) */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.data-table th, .data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.data-table th { background: #f8fafc; font-weight: 600; color: var(--muted); }
.badge-active { background: #dcfce7; color: #15803d; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-inactive { background: #fee2e2; color: #b91c1c; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }

/* REPORT */
.report-card { padding: 12px 14px; }
.rep-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}
.rep-row.main-row { font-size: 15px; border-bottom: 1px solid #f1f5f9; padding-bottom: 7px; margin-bottom: 4px; }
.rep-row.sub-row { font-size: 13px; color: var(--muted); }
.rep-section-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.rep-notes { font-size: 12px; color: var(--amber); margin-top: 2px; }
.divider { border: none; border-top: 1px dashed var(--border); margin: 8px 0; }

.repay-input-group {
    display: flex;
    gap: 6px;
    width: 165px;
}
.repay-input-group input { padding: 6px 8px; font-size: 14px; }

.summary-highlight {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.final-row {
    border-top: 1px solid #bfdbfe;
    margin-top: 6px;
    padding-top: 8px;
    font-size: 17px;
    color: var(--primary-dark);
}

/* BOTTOM NAV */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 30;
}

.nav-btn {
    flex: 1;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    cursor: pointer;
    gap: 2px;
}

.nav-btn.active {
    color: var(--primary);
    font-weight: 700;
}

.nav-icon { font-size: 20px; }
.nav-label { font-size: 11px; }

/* BOTTOM SHEET MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.bottom-sheet {
    background: var(--card);
    width: 100%;
    max-width: 540px;
    border-radius: 18px 18px 0 0;
    padding: 18px 16px 24px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.close-btn {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}

.switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 10px;
}

.switch-row small { display: block; color: var(--muted); font-size: 12px; }

.disabled-section {
    opacity: 0.4;
    pointer-events: none;
}

/* TOGGLE SWITCH */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #cbd5e1;
    transition: .2s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(22px); }

.sheet-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* TOAST */
.toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #fff;
    padding: 10px 18px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 600;
    z-index: 100;
}

/* MULTI-VISIT CHECKBOX GRID */
.visit-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 4px;
}

.visit-chk-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}

.visit-chk-item input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    margin: 0;
}