/* ===========================================================
   Job Tracker — design system (warm, friendly, kid-aware)
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

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

:root {
    /* Warm friendly palette */
    --color-bg: #fbf7ef;            /* warm cream */
    --color-surface: #ffffff;
    --color-surface-2: #fff9ec;     /* very subtle warmth */
    --color-text: #1a1a2e;
    --color-text-muted: #6b6c8a;
    --color-border: #ecdfcb;
    --color-border-strong: #d8c9b0;

    --color-accent: #5046e5;         /* deep indigo */
    --color-accent-2: #6d63f0;       /* brighter indigo for highlights */
    --color-accent-hover: #3b32c2;
    --color-accent-soft: #ece9ff;    /* indigo wash */

    --color-warm: #f97316;           /* coral accent for highlights */
    --color-yellow: #fde68a;

    /* Status — more saturated for joy */
    --color-pending:    #9ca3af;
    --color-submitted:  #f59e0b;
    --color-approved:   #16a34a;
    --color-rejected:   #dc2626;
    --color-missed:     #ef4444;

    --status-pending-bg:   #f3f4f6;
    --status-submitted-bg: #fff7ed;
    --status-approved-bg:  #ecfdf5;
    --status-rejected-bg:  #fef2f2;
    --status-missed-bg:    #fef2f2;

    --radius:    14px;
    --radius-sm: 8px;
    --radius-lg: 22px;

    --shadow-xs: 0 1px 2px rgba(20, 14, 60, 0.04);
    --shadow-sm: 0 2px 6px rgba(20, 14, 60, 0.06);
    --shadow-md: 0 4px 14px rgba(20, 14, 60, 0.08);
    --shadow-lg: 0 12px 30px rgba(20, 14, 60, 0.10);

    --font-display: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --font-body:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --tap: 44px;

    --tx-page: 220ms cubic-bezier(.2,.8,.2,1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #11121d;
        --color-surface: #1c1d2e;
        --color-surface-2: #232539;
        --color-text: #f1f5f9;
        --color-text-muted: #9aa1c0;
        --color-border: #2c2e44;
        --color-border-strong: #3c3f5a;

        --color-accent: #8b80ff;
        --color-accent-2: #a59cff;
        --color-accent-hover: #b3aaff;
        --color-accent-soft: #2a2748;

        --status-pending-bg:   #1f2230;
        --status-submitted-bg: #2a200c;
        --status-approved-bg:  #0f2a1f;
        --status-rejected-bg:  #2a0f10;
        --status-missed-bg:    #2a0f10;

        --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
        --shadow-sm: 0 2px 6px rgba(0,0,0,0.35);
        --shadow-md: 0 4px 14px rgba(0,0,0,0.40);
        --shadow-lg: 0 12px 30px rgba(0,0,0,0.50);
    }
}

html, body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
    font-feature-settings: "ss01", "cv11";
}

body {
    padding-bottom: env(safe-area-inset-bottom);
}
body.role-child, body.role-parent {
    /* room for bottom nav on mobile */
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
@media (min-width: 768px) {
    body.role-parent { padding-bottom: env(safe-area-inset-bottom); }
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    line-height: 1.15;
    margin: 0 0 0.5rem;
    letter-spacing: -0.015em;
}
h1 { font-size: 1.875rem; font-weight: 800; }
h2 { font-size: 1.375rem; font-weight: 700; margin-top: 1.5rem; }
h3 { font-size: 1.05rem; font-weight: 700; }
@media (max-width: 600px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.2rem; }
}

p, ul, ol { margin: 0 0 0.75rem; }
ul { list-style: none; }

img { max-width: 100%; height: auto; display: block; }

/* tabular numbers globally (currency, dates, badges) */
.amount, .num, .badge, table, .day-ring, .cal-day-num,
.wallet-big, .wallet-amount, .wallet-mini strong, .stat-num {
    font-variant-numeric: tabular-nums;
}

input, select, textarea, button { font: inherit; color: inherit; }

input[type="text"], input[type="email"], input[type="number"], input[type="date"],
input[type="color"], select, textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    min-height: var(--tap);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}
input[type="color"] { padding: 4px; height: 44px; cursor: pointer; }
textarea { min-height: 80px; resize: vertical; }

/* ===== Layout ===== */
.main-content {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.25rem 1rem;
    animation: page-fade var(--tx-page);
}
@keyframes page-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (min-width: 1024px) {
    body.role-parent .main-content {
        margin-left: 240px;
        max-width: calc(1080px + 240px);
    }
}

/* ===== Top bar ===== */
.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(150%) blur(8px);
    background: color-mix(in srgb, var(--color-surface) 85%, transparent);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-logo { width: 28px; height: 28px; flex-shrink: 0; }

.topnav {
    display: flex;
    gap: 0.15rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    flex: 1;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
    color: var(--color-text-muted);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    font-weight: 500;
    transition: background .12s, color .12s;
}
.topnav a:hover, .topnav a.active {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.nav-approvals { position: relative; }

.topbar-right { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }

/* ===== Desktop sidebar (parent only) ===== */
.sidebar { display: none; }
@media (min-width: 1024px) {
    body.role-parent .topbar { display: none; }
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 240px;
        background: var(--color-surface);
        border-right: 1px solid var(--color-border);
        display: flex;
        flex-direction: column;
        padding: 1.5rem 1rem;
        z-index: 50;
        box-shadow: var(--shadow-sm);
    }
    .sidebar .brand { font-size: 1.2rem; margin-bottom: 1.5rem; }
    .sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
    .sidebar-nav a {
        padding: 0.65rem 0.85rem;
        border-radius: var(--radius-sm);
        color: var(--color-text-muted);
        text-decoration: none;
        font-weight: 500;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        transition: background .12s, color .12s;
    }
    .sidebar-nav a:hover, .sidebar-nav a.active {
        background: var(--color-accent-soft);
        color: var(--color-accent);
    }
    .sidebar-nav a.active { font-weight: 700; }
    .sidebar-foot { display: flex; gap: 0.5rem; align-items: center; margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--color-border); }
}

/* ===== Avatar / user menu ===== */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
}
.avatar-fallback {
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    width: 36px; height: 36px; border-radius: 50%;
    border: 2px solid var(--color-border);
}
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu-panel {
    position: absolute;
    right: 0;
    top: 110%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    min-width: 240px;
    box-shadow: var(--shadow-lg);
    z-index: 60;
}
.user-menu-name { font-weight: 700; }
.user-menu-email { color: var(--color-text-muted); font-size: 0.85rem; margin-bottom: 0.75rem; }
.user-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.user-menu-actions .btn { width: 100%; justify-content: flex-start; }
.user-menu-actions form { width: 100%; }

@media (max-width: 600px) {
    .topnav { font-size: 0.85rem; }
    .topnav a { padding: 0.4rem 0.55rem; }
}

/* ===== Bottom nav ===== */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 14px rgba(20, 14, 60, 0.06);
}
@media (min-width: 1024px) {
    body.role-parent .bottom-nav { display: none; }
}
.bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0;
    text-decoration: none;
    color: var(--color-text-muted);
    min-height: 60px;
    justify-content: center;
    gap: 2px;
    position: relative;
    transition: color .12s;
}
.bn-item:hover { text-decoration: none; }
.bn-icon {
    font-size: 1.4rem;
    transition: transform .15s;
}
.bn-label { font-size: 0.7rem; font-weight: 600; }
.bn-item.active {
    color: var(--color-accent);
}
.bn-item.active .bn-icon { transform: translateY(-2px) scale(1.1); }
.bn-item.active::after {
    content: '';
    position: absolute;
    top: 4px; left: 50%;
    transform: translateX(-50%);
    width: 28px; height: 3px;
    border-radius: 999px;
    background: var(--color-accent);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.05rem;
    min-height: var(--tap);
    border: 1.5px solid var(--color-border);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    color: var(--color-text);
    transition: background .15s, transform .08s, border-color .15s, box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--color-surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.disabled { opacity: 0.5; cursor: not-allowed; }
.btn.is-loading { color: transparent; position: relative; pointer-events: none; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    /* Center the spinner regardless of button width/height. The 18px box +
       -9px margins is a portable alternative to translate(-50%,-50%) that
       doesn't clobber any other transforms the button might be running. */
    top: 50%;
    left: 50%;
    width: 18px; height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid currentColor;
    border-color: rgba(255,255,255,0.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
/* Ghost buttons + outline buttons read text-on-light, so a pure-white
   spinner disappears. Tint the ring with the brand color for visibility. */
.btn-ghost.is-loading::after,
.btn.is-loading:not(.btn-primary):not(.btn-success):not(.btn-danger):not(.photo-btn-hero)::after {
    border-color: rgba(80, 70, 229, 0.25);
    border-top-color: var(--color-primary, #5046e5);
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary {
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--color-accent) 35%, transparent);
}
.btn-primary:hover {
    filter: brightness(1.05);
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
    box-shadow: 0 4px 14px color-mix(in srgb, var(--color-accent) 45%, transparent);
}
.btn-success {
    background: var(--color-approved); color: white; border-color: transparent;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}
.btn-success:hover { filter: brightness(1.06); background: var(--color-approved); }
.btn-danger {
    background: var(--color-rejected); color: white; border-color: transparent;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}
.btn-danger:hover { filter: brightness(1.06); background: var(--color-rejected); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 0.35rem 0.7rem; min-height: 36px; font-size: 0.88rem; gap: 0.25rem; }
.btn-lg { padding: 0.95rem 1.6rem; min-height: 56px; font-size: 1.05rem; border-radius: var(--radius); }

/* ===== Forms ===== */
.form-stack { display: flex; flex-direction: column; gap: 1rem; max-width: 640px; }
.form-stack label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.92rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
.form-actions { display: flex; gap: 0.5rem; padding-top: 0.5rem; }
.form-fieldset { border: 1.5px solid var(--color-border); border-radius: var(--radius); padding: 1rem; background: var(--color-surface); }
.form-fieldset legend { padding: 0 0.5rem; font-weight: 700; }
.form-inline-row {
    display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
    background: var(--color-surface); padding: 0.85rem; border-radius: var(--radius);
    border: 1.5px solid var(--color-border);
    box-shadow: var(--shadow-xs);
}
.form-inline-row input { flex: 1; min-width: 140px; }
label.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }
label.checkbox input { width: auto; min-height: auto; }

.schedule-radios { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.radio-pill input { display: none; }
.radio-pill span {
    display: inline-block;
    padding: 0.5rem 1.1rem;
    border: 1.5px solid var(--color-border);
    border-radius: 999px;
    cursor: pointer;
    background: var(--color-surface);
    min-height: var(--tap);
    line-height: 28px;
    font-weight: 600;
    transition: all .15s;
}
.radio-pill input:checked + span {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
    transform: scale(1.02);
}
.weekday-toggle { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.wd-pill input { display: none; }
.wd-pill span {
    display: inline-block;
    width: var(--tap);
    height: var(--tap);
    line-height: var(--tap);
    text-align: center;
    border: 1.5px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    font-weight: 700;
    background: var(--color-surface);
    font-size: 0.85rem;
    transition: all .15s;
}
.wd-pill input:checked + span {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
    transform: scale(1.05);
}

/* ===== Flash messages ===== */
.flash-stack { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.flash {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--color-text-muted);
    background: var(--color-surface);
    box-shadow: var(--shadow-xs);
    font-weight: 500;
    animation: flash-in .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes flash-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.flash-success { border-color: var(--color-approved); background: var(--status-approved-bg); }
.flash-error   { border-color: var(--color-rejected); background: var(--status-rejected-bg); }
.flash-info    { border-color: var(--color-accent); background: var(--color-accent-soft); }
.flash-warning { border-color: var(--color-submitted); background: var(--status-submitted-bg); }

/* ===== Helpers ===== */
.muted { color: var(--color-text-muted); }
.small { font-size: 0.85rem; }
.t-right { text-align: right; }
.hidden { display: none !important; }
.gradient-text {
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.page-header {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}

.section-header {
    display: flex; justify-content: space-between; align-items: baseline;
    margin: 1.75rem 0 0.85rem;
}

.empty {
    text-align: center;
    padding: 2.5rem 1rem;
    background: var(--color-surface);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius);
    color: var(--color-text-muted);
}
.empty-art { display: block; margin: 0 auto 1rem; opacity: 0.85; }
.empty-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; color: var(--color-text); margin-bottom: 0.25rem; }
.empty-msg   { font-size: 0.95rem; }

.error-page { text-align: center; padding: 4rem 1rem; }
.error-page h1 { font-size: 4rem; font-weight: 800; }

.landing { max-width: 480px; margin: 4rem auto; text-align: center; padding: 1rem; }
.landing-hero {
    font-size: 3rem; font-weight: 800; margin-bottom: 0.5rem;
    font-family: var(--font-display);
    letter-spacing: -0.025em;
}
.landing-sub { color: var(--color-text-muted); margin-bottom: 2rem; font-size: 1.05rem; }
.landing-actions { display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }
.landing-note { margin-top: 2rem; font-size: 0.85rem; color: var(--color-text-muted); }

.dev-quick { padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.dev-quick li { list-style: none; }

.filters { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.filter-pill {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}
.filter-pill.active { background: var(--color-accent); color: white; border-color: var(--color-accent); }
