/* =============================================================================
   Cafe Luna — Global Stylesheet
   Mobile-first, bold, streamlined. Colors come from CSS variables injected
   per-page from the active palette (see palettes.php).
   ========================================================================== */

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

:root {
    --radius: 16px;
    --radius-sm: 10px;
    --maxw: 620px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; }

/* ---------- Top bar ------------------------------------------------------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    max-width: var(--maxw);
    margin: 0 auto;
    width: 100%;
}
.topbar-name { font-weight: 700; letter-spacing: 0.02em; font-size: 1.05rem; }
.topbar-name.center { margin: 0 auto; }
.topbar .spacer { flex: 1; }
.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}
.nav-link:hover { color: var(--text); }

/* ---------- Page container ------------------------------------------------ */
.page {
    flex: 1;
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 24px 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---------- Logo ---------------------------------------------------------- */
.logo-block { text-align: center; padding: 16px 0 6px; }
.logo-block img {
    display: block;
    max-width: 100%;       /* never exceed the tile column width */
    width: auto;
    height: auto;
    max-height: 96px;      /* keep a sensible cap on mobile */
    margin: 0 auto;
}
.logo-mark { font-size: 3rem; line-height: 1; color: var(--primary); }
.logo-text { margin-top: 6px; font-size: 1.5rem; font-weight: 700; letter-spacing: 0.03em; }

/* ---------- Tiles (unified vertical stack) -------------------------------- */
.tile {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    border-radius: var(--radius);
    transition: transform 0.12s ease, filter 0.12s ease;
    width: 100%;
}
.tile:active { transform: scale(0.99); }

/* Hero "Calculator" — same full width as the rest, but taller and bolder. */
.tile-hero {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 6px;
    background: var(--primary);
    color: var(--on-primary);
    min-height: 150px;
    padding: 30px 22px;
}
.tile-hero:hover { filter: brightness(1.05); }
.tile-hero-icon { font-size: 2.4rem; line-height: 1; }
.tile-hero-label { font-size: 1.9rem; font-weight: 800; letter-spacing: 0.01em; }
.tile-hero-sub { font-size: 0.92rem; opacity: 0.85; }

/* Wide tiles (archive, admin) */
.tile-wide {
    justify-content: space-between;
    background: var(--accent);
    color: var(--on-accent);
    padding: 20px 22px;
    font-weight: 600;
}
.tile-wide:hover { filter: brightness(1.06); }
.tile-wide-label { font-size: 1.05rem; }
.tile-wide-icon { font-size: 1.3rem; opacity: 0.75; }
.tile-muted {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.tile-muted:hover { color: var(--text); }

/* ---------- Panel (cards, report lists) ----------------------------------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 18px 8px;
}
.panel.pad { padding: 20px; }
.panel-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 700;
}

/* ---------- Report rows (splash + archive) -------------------------------- */
.report-list { display: flex; flex-direction: column; }
.report-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 4px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.report-row:last-child { border-bottom: none; }
.report-main { flex: 1; min-width: 0; }
.report-label { font-size: 0.98rem; font-weight: 600; }
.report-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.report-meta .num { color: var(--text); font-weight: 600; }
.report-arrow { color: var(--primary); font-size: 1.4rem; line-height: 1; flex: none; }
.report-row:not(.report-row--disabled):hover .report-label { color: var(--primary); }
.report-row--disabled { color: var(--text-muted); cursor: default; }
.report-row--disabled .report-label { color: var(--text-muted); }
.report-pending {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 10px;
    flex: none;
}

/* ---------- Payout table (report.php) — bold & readable ------------------- */
.payout-head {
    text-align: center;
    padding: 8px 0 20px;
}
.payout-head .week {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}
.payout-head .total {
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--primary);
    margin-top: 4px;
    line-height: 1.1;
}
.payout-head .total-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 8px;
    text-align: center;
}
.stat .v { font-size: 1.15rem; font-weight: 700; }
.stat .k {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Big, scannable payout list */
.payouts { display: flex; flex-direction: column; gap: 8px; }
.payout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
}
.payout-name { font-size: 1.1rem; font-weight: 700; }
.payout-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.payout-cash {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}
/* multi-role: stacked role lines */
.payout-roles { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.payout-role-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.payout-role-line .rc { color: var(--text); font-weight: 600; }

/* ---------- Buttons ------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.12s ease, transform 0.12s ease;
    width: 100%;
}
.btn:active { transform: scale(0.99); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover { filter: brightness(1.06); }
.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); }
.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }

/* ---------- Forms (admin) ------------------------------------------------- */
.field-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}
.field, select.field {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font);
}
.field:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.weight-row {
    display: grid;
    grid-template-columns: 1fr 110px;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.weight-row:last-child { border-bottom: none; }
.weight-row .role { font-weight: 600; }
.weight-row input {
    text-align: right;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    width: 100%;
}
.weight-row input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.palette-choices { display: flex; flex-direction: column; gap: 10px; }
.palette-choice {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg);
}
.palette-choice input { accent-color: var(--primary); width: 18px; height: 18px; }
.palette-choice.selected { border-color: var(--primary); border-width: 2px; }
.swatches { display: flex; gap: 6px; margin-left: auto; }
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.15); }
.palette-name { font-weight: 600; }

.notice {
    background: var(--accent);
    color: var(--on-accent);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

/* ---------- Empty state --------------------------------------------------- */
.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.95rem;
}

/* ---------- Footer -------------------------------------------------------- */
.foot {
    text-align: center;
    padding: 18px;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ---------- Login page ---------------------------------------------------- */
.login-body { justify-content: center; }
.login-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 16px;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
    width: 100%;
    max-width: 380px;
}
.brand { text-align: center; margin-bottom: 20px; }
.brand-mark { font-size: 2.6rem; color: var(--primary); line-height: 1; }
.brand-name { font-size: 1.4rem; font-weight: 700; margin-top: 6px; letter-spacing: 0.03em; }
.login-hint { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 18px; }
.alert {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.88rem;
    margin-bottom: 16px;
    text-align: center;
}
.login-foot { font-size: 0.75rem; color: var(--text-muted); }

/* ---------- Print (report.php) -------------------------------------------- */
@media print {
    .topbar, .foot, .btn-row, .no-print { display: none !important; }
    body { background: #fff; color: #000; }
    .page { max-width: 100%; padding: 0; }
    .payout, .stat { border: 1px solid #ccc; break-inside: avoid; }
    .payout-cash, .payout-head .total { color: #000; }
}

/* ---------- Desktop refinements ------------------------------------------- */
@media (min-width: 720px) {
    .page { padding: 36px 24px 56px; gap: 18px; }
    .tile-hero { min-height: 190px; }
    .tile-hero-label { font-size: 2.1rem; }
    .logo-mark { font-size: 3.4rem; }
    .logo-block img { max-height: 120px; }
    .stat .v { font-size: 1.3rem; }
}

/* ---------- Admin: job title mapping rows --------------------------------- */
.map-row {
    display: grid;
    grid-template-columns: 1fr auto 1.3fr;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.map-row:last-of-type { border-bottom: none; }
.csvjob-label {
    font-weight: 600;
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 0.9rem;
    word-break: break-word;
}
.map-arrow { color: var(--text-muted); font-size: 1.1rem; }
.map-row select.field { padding: 9px 12px; }

/* ---------- Login brand logo --------------------------------------------- */
.brand-logo {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 70px;
    margin: 0 auto;
}

/* ---------- Login: password + Enter on one row --------------------------- */
.login-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}
.login-row .field {
    flex: 1;
    min-width: 0;      /* let it shrink so the button always fits */
    margin-bottom: 0;  /* override any stacked-field spacing */
}
.login-enter {
    flex: none;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--on-primary);
    font-size: 1rem;
    font-weight: 700;
    padding: 0 22px;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.12s ease, transform 0.12s ease;
}
.login-enter:hover { filter: brightness(1.06); }
.login-enter:active { transform: scale(0.98); }

/* ---------- Splash "Recent reports" title: match tile-label styling ------- */
.panel-title--plain {
    text-transform: none;      /* sentence case, not UPPERCASE */
    letter-spacing: normal;
    font-size: 1.05rem;        /* match .tile-wide-label */
    color: var(--text);        /* full color, not muted grey */
    font-weight: 600;
}

/* ---------- Admin: notifications ----------------------------------------- */
.recip-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.recip {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 14px;
}
.recip-main { flex: 1; min-width: 0; }
.recip-name { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recip-label {
    font-size: 0.65rem; text-transform: uppercase; letter-spacing: .04em;
    background: var(--accent); color: var(--on-accent); padding: 2px 7px; border-radius: 4px; font-weight: 700;
}
.recip-email { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; word-break: break-all; }
.recip-flags { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.btn-remove {
    flex: none; width: 32px; height: 32px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
    font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.btn-remove:hover { border-color: #e5484d; color: #e5484d; }
.recip-add { border-top: 1px solid var(--border); padding-top: 16px; }
.recip-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.recip-add-grid .field { width: 100%; }
.recip-check {
    display: flex; align-items: center; gap: 8px; margin-top: 12px;
    font-size: 0.88rem; color: var(--text); cursor: pointer;
}
.recip-check input { width: 18px; height: 18px; accent-color: var(--primary); }
.test-row { display: flex; gap: 10px; margin-bottom: 16px; }
.test-row .field { flex: 1; }
.test-btn { width: auto; flex: none; white-space: nowrap; }
.log-list { display: flex; flex-direction: column; gap: 6px; }
.log-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    font-size: 0.8rem; padding: 8px 10px; background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px;
}
.log-status {
    font-size: 0.68rem; text-transform: uppercase; font-weight: 700;
    padding: 2px 8px; border-radius: 4px; flex: none;
}
.log-ok, .log-test { background: rgba(13,92,74,0.15); color: #4ade80; }
.log-fail { background: rgba(229,72,77,0.15); color: #e5484d; }
.log-to { font-weight: 600; }
.log-time { color: var(--text-muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.log-err { flex-basis: 100%; color: #e5484d; font-size: 0.75rem; }

@media (max-width: 560px) {
    .recip-add-grid { grid-template-columns: 1fr; }
}

/* ---------- Admin: collapsible panels (weights, mapping) ------------------ */
.collapse { padding: 0; overflow: hidden; }
.collapse-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    cursor: pointer;
    list-style: none;                 /* hide default marker (Firefox/others) */
    user-select: none;
    transition: background 0.15s ease;
}
.collapse-head::-webkit-details-marker { display: none; }  /* hide Safari/Chrome marker */
.collapse-head:hover { background: var(--surface-alt); }
.collapse-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}
.collapse-chevron {
    font-size: 1.4rem;
    line-height: 1;
    color: var(--text-muted);
    transition: transform 0.22s ease;
    flex: none;
}
.collapse[open] .collapse-chevron { transform: rotate(90deg); color: var(--primary); }
.collapse-body {
    padding: 4px 18px 18px;
    border-top: 1px solid var(--border);
}
/* subtle open-state emphasis */
.collapse[open] .collapse-head { background: var(--surface-alt); }
