:root {
    --bg-1: #FFF5E1;
    --bg-2: #E8F5FF;
    --text: #2A3D52;
    --text-soft: #5C7A99;
    --accent: #FFB84D;
    --accent-2: #FF8FA3;
    --green: #6FCF97;
    --red: #EB6E6E;
    --shadow: 0 6px 16px rgba(40, 60, 90, 0.12);
    --shadow-lg: 0 12px 28px rgba(40, 60, 90, 0.18);
    --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro", system-ui, sans-serif;
    color: var(--text);
    background: #6495ED;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

button {
    font-family: inherit;
    color: inherit;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* ------- Top bar / date selector ------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 24px 32px 12px;
}

.date-arrow {
    background: white;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    font-size: 64px;
    font-weight: 600;
    line-height: 1;
    box-shadow: var(--shadow);
    color: var(--text);
    transition: transform 0.1s ease;
}
.date-arrow:active { transform: scale(0.92); }

.date-block {
    text-align: center;
    min-width: 380px;
}

.date-label {
    font-size: 56px;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.5px;
}

.date-sub {
    font-size: 22px;
    color: var(--text-soft);
    margin-top: 4px;
    min-height: 28px;
}

.today-btn {
    margin-top: 10px;
    background: var(--accent);
    color: white;
    font-size: 22px;
    font-weight: 700;
    padding: 10px 28px;
    border-radius: 999px;
    box-shadow: var(--shadow);
    display: none;
}
.today-btn.show { display: inline-block; }
.today-btn:active { transform: scale(0.95); }

/* ------- Board / kid columns ------- */

.board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 22px;
    padding: 18px 28px 100px;
    align-items: start;
}

.kid-col {
    background: #4A7BD9;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

/* per-kid pastel headers, cycled by index */
.kid-col[data-i="0"] .kid-head { background: #FFD9C0; }
.kid-col[data-i="1"] .kid-head { background: #C8F2D7; }
.kid-col[data-i="2"] .kid-head { background: #C8E6FF; }
.kid-col[data-i="3"] .kid-head { background: #E0D3F5; }
.kid-col[data-i="4"] .kid-head { background: #FFF4B0; }
.kid-col[data-i="5"] .kid-head { background: #FFD3E1; }

.kid-head {
    border-radius: 14px;
    padding: 16px 14px;
    text-align: center;
}

.kid-name {
    font-size: 40px;
    font-weight: 800;
    line-height: 1.1;
}

.kid-balance {
    margin-top: 6px;
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
}

.kid-balance .dollars {
    font-size: 18px;
    color: var(--text-soft);
    margin-left: 6px;
    font-weight: 600;
}

.kid-progress {
    margin-top: 8px;
    font-size: 16px;
    color: var(--text-soft);
}

/* Shared column */
.shared-col {
    background: #3F8F6A;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.shared-head {
    background: #B6E8C8;
    border-radius: 14px;
    padding: 16px 14px;
    text-align: center;
}

.shared-title {
    font-size: 40px;
    font-weight: 800;
    line-height: 1.1;
}

.shared-sub {
    margin-top: 6px;
    font-size: 16px;
    color: var(--text-soft);
    font-weight: 600;
}

.shared-progress {
    margin-top: 8px;
    font-size: 16px;
    color: var(--text-soft);
}

.sections {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chore-section {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    padding: 10px 10px 12px;
}

.section-morning { background: rgba(255, 220, 160, 0.32); }
.section-daytime { background: rgba(200, 235, 255, 0.32); }
.section-shared  { background: rgba(180, 235, 200, 0.40); }
.section-evening { background: rgba(190, 175, 230, 0.36); }

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px 10px;
    color: white;
    font-weight: 800;
    text-shadow: 0 1px 2px rgba(0,0,0,0.18);
}

.section-title {
    font-size: 22px;
    letter-spacing: 0.3px;
}

.section-count {
    font-size: 16px;
    background: rgba(255,255,255,0.85);
    color: var(--text);
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 700;
    text-shadow: none;
}

.empty-msg.small {
    font-size: 14px;
    padding: 10px 8px;
    color: rgba(255,255,255,0.85);
}

.chore-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chore-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #F5F8FC;
    border-radius: 14px;
    padding: 16px 16px;
    min-height: 76px;
    text-align: left;
    box-shadow: 0 2px 6px rgba(40, 60, 90, 0.06);
    transition: transform 0.08s ease, background 0.15s ease;
    width: 100%;
}

.chore-btn:active { transform: scale(0.97); }

.chore-btn.done {
    background: linear-gradient(135deg, #B6F5C8, #8EE6A8);
    text-decoration: line-through;
    text-decoration-thickness: 3px;
    text-decoration-color: rgba(40, 60, 90, 0.4);
}

.chore-btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.chore-emoji {
    font-size: 38px;
    flex-shrink: 0;
    line-height: 1;
    width: 48px;
    text-align: center;
}

.chore-text {
    flex: 1;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
    min-width: 0;
}

.chore-stars {
    flex-shrink: 0;
    background: var(--accent);
    color: white;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 20px;
    font-weight: 800;
    white-space: nowrap;
}

.chore-btn.done .chore-stars {
    background: var(--green);
}

.empty-msg {
    text-align: center;
    color: var(--text-soft);
    font-size: 18px;
    padding: 24px 12px;
}

.future-note, .past-note {
    text-align: center;
    font-size: 18px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--text-soft);
    background: rgba(255,255,255,0.6);
}

/* ------- Admin FAB & modals ------- */

.admin-fab {
    position: fixed;
    bottom: 18px;
    right: 18px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: white;
    font-size: 30px;
    box-shadow: var(--shadow-lg);
    opacity: 0.7;
    z-index: 5;
}
.admin-fab:active { opacity: 1; transform: scale(0.92); }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 45, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}
.modal.hidden { display: none; }

.modal-card {
    background: white;
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    max-width: 100%;
    max-height: 92vh;
    overflow: auto;
    padding: 24px;
}

.keypad-card {
    width: 380px;
    text-align: center;
}

.keypad-card h2 {
    margin: 0 0 16px;
    font-size: 28px;
}

#keypad-display {
    width: 100%;
    text-align: center;
    font-size: 40px;
    letter-spacing: 14px;
    padding: 12px 8px;
    border: 2px solid #E1E7EE;
    border-radius: 12px;
    margin-bottom: 14px;
    background: #F8FAFD;
    color: var(--text);
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.kp {
    font-size: 32px;
    font-weight: 700;
    background: #F5F8FC;
    border-radius: 14px;
    padding: 18px 0;
    color: var(--text);
}
.kp:active { transform: scale(0.94); background: #E8EEF7; }
.kp-clear { background: #FFE2E0; color: #B5403F; }
.kp-enter { background: var(--green); color: white; }

.cancel-btn {
    margin-top: 14px;
    background: #EEF2F7;
    color: var(--text);
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 18px;
    width: 100%;
    font-weight: 600;
}

.error {
    margin-top: 12px;
    color: var(--red);
    font-size: 16px;
}

.error.hidden, .hidden { display: none; }

/* Admin panel */

.admin-card {
    width: 920px;
    max-width: 96vw;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #EEF2F7;
}
.admin-header h2 { margin: 0; font-size: 26px; }

.close-btn {
    background: #F5F8FC;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 22px;
    color: var(--text);
}
.close-btn:active { transform: scale(0.92); }

.admin-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    border-bottom: 1px solid #EEF2F7;
    background: #FAFCFE;
}
.tab {
    background: transparent;
    color: var(--text-soft);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
}
.tab.active { background: var(--accent); color: white; }

.admin-body {
    padding: 18px 24px;
    overflow: auto;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Tables and forms inside admin */
.row-list { display: flex; flex-direction: column; gap: 10px; }

.row-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    background: #F8FAFD;
    border-radius: 12px;
    padding: 12px 14px;
}
.row-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-title { font-size: 18px; font-weight: 700; }
.row-sub { font-size: 14px; color: var(--text-soft); }

.row-actions { display: flex; gap: 6px; }

.btn {
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    background: #E8EEF7;
    color: var(--text);
}
.btn-primary { background: var(--accent); color: white; }
.btn-danger { background: #FFD7D5; color: #9B2A2A; }
.btn-success { background: var(--green); color: white; }
.btn:active { transform: scale(0.96); }

.form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    background: #FAFCFE;
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 14px;
}

.form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    color: var(--text-soft);
    font-weight: 600;
}
.form input[type="text"],
.form input[type="number"],
.form input[type="date"],
.form select,
.form textarea {
    padding: 10px;
    border: 1px solid #DCE3EC;
    border-radius: 8px;
    font-size: 16px;
    color: var(--text);
    background: white;
    font-family: inherit;
}

.form .full { grid-column: 1 / -1; }

.days-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.day-chip {
    padding: 8px 12px;
    border-radius: 999px;
    background: #EEF2F7;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-soft);
}
.day-chip.on { background: var(--accent); color: white; }

.form-row-actions {
    display: flex;
    gap: 10px;
    grid-column: 1 / -1;
}

/* History list */
.tx-list { display: flex; flex-direction: column; gap: 6px; }
.tx-row {
    display: grid;
    grid-template-columns: 100px 1fr auto;
    gap: 10px;
    padding: 10px 12px;
    background: #F8FAFD;
    border-radius: 10px;
    align-items: center;
    font-size: 15px;
}
.tx-type {
    text-transform: capitalize;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 13px;
    text-align: center;
}
.tx-type.chore { background: #D1F2DD; color: #1F6B3A; }
.tx-type.unchore { background: #FFE9D6; color: #8A4A1A; }
.tx-type.adjust { background: #DAE8FF; color: #2C4A8A; }
.tx-type.payout { background: #FFD9E5; color: #8A2A4A; }

.tx-delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.tx-delta.pos { color: #1F6B3A; }
.tx-delta.neg { color: #8A2A4A; }

.tx-meta { color: var(--text-soft); font-size: 13px; }

/* Toast */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 14px 22px;
    border-radius: 999px;
    font-size: 18px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    pointer-events: none;
}
.toast.hidden { display: none; }

/* Responsive: narrow screens (admin laptop preview) */
@media (max-width: 900px) {
    .board {
        grid-auto-flow: row;
        grid-auto-columns: auto;
    }
    .date-label { font-size: 36px; }
    .date-arrow { width: 64px; height: 64px; font-size: 44px; }
    .date-block { min-width: 0; }
}
