/* chstaff — mobile-first stylesheet */
*, *::before, *::after { box-sizing: border-box; }

/* Cricket-Hockey brand: green #8DE635, dark navy #081024, red #D90244 */
:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --ink: #081024;
    --muted: #5c6675;
    --line: #dde2e8;
    --brand: #081024;
    --brand-2: #8DE635;
    --brand-2-ink: #081024;
    --accent: #D90244;
    --danger: #D90244;
    --radius: 10px;
}

html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.45;
}

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

/* ── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--brand);
    color: #fff;
    padding: 10px 14px;
}
.brand { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.mainnav a {
    color: rgba(255,255,255,.85);
    padding: 7px 11px;
    border-radius: 7px;
    font-weight: 500;
    white-space: nowrap;
}
.mainnav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.mainnav a.active { background: rgba(255,255,255,.2); color: #fff; }
.badge {
    background: var(--brand-2);
    color: var(--brand-2-ink);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    margin-left: 4px;
    vertical-align: 1px;
}
/* Attention badge for pending approvals */
.badge-alert { background: var(--accent); color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.username { opacity: .85; }
.logout { color: #fff; opacity: .7; }
.logout:hover { opacity: 1; }

/* Hamburger — hidden on desktop, shown on narrow screens */
.navtoggle {
    display: none;
    margin-left: auto;
    background: rgba(255, 255, 255, .12);
    border: 0;
    color: #fff;
    width: 42px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.navtoggle:hover { background: rgba(255, 255, 255, .2); }
.navtoggle { position: relative; }
.navtoggle.has-alert::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--brand);
}

@media (max-width: 760px) {
    .navtoggle { display: inline-flex; }
    .mainnav, .userbox {
        display: none;
        flex-basis: 100%;
        width: 100%;
    }
    .topbar.nav-open .mainnav {
        display: flex;
        flex-direction: column;
        gap: 2px;
        order: 3;
        margin-top: 8px;
    }
    .topbar.nav-open .userbox {
        display: flex;
        order: 4;
        margin-top: 8px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, .15);
        justify-content: space-between;
    }
    .mainnav a { padding: 11px 12px; width: 100%; font-size: 16px; }
}

/* ── Page & cards ────────────────────────────────────────────────────── */
.page { padding: 16px; max-width: 1400px; margin: 0 auto; }
.page-wide { max-width: none; }
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

h1.pagetitle { font-size: 20px; margin: 4px 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ── Document / policy body ──────────────────────────────────────────── */
.doc-body { max-width: 820px; line-height: 1.6; }
.doc-body h3 { font-size: 17px; margin: 22px 0 8px; color: var(--brand); }
.doc-body h3:first-child { margin-top: 0; }
.doc-body ul, .doc-body ol { padding-left: 22px; margin: 8px 0; }
.doc-body li { margin-bottom: 5px; }
.doc-body p { margin: 8px 0; }

/* ── Flash messages ──────────────────────────────────────────────────── */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: #e5f4e7; color: #1d5e28; border: 1px solid #bfe4c4; }
.flash-err { background: #fbe9e7; color: #a23527; border: 1px solid #f3c4bd; }

/* ── Forms ───────────────────────────────────────────────────────────── */
/* A <select> must never sit inside a <label> (Chrome reopens it on click and
   you can't pick an option) — selects use a div.fld wrapper instead, so these
   rules target .fld generally, not label.fld. */
.fld { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.fld input, .fld select, .fld textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 9px 10px;
    font-size: 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}
.btn {
    display: inline-block;
    background: var(--brand-2);
    color: var(--brand-2-ink);
    border: 0;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn-secondary { background: #eef0f3; color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.inline-form { display: inline; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td {
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
    text-align: left;
    white-space: nowrap;
}
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
table.data tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; }
.neg { color: var(--danger); font-weight: 700; }
.warnnum { color: #b26a00; font-weight: 700; }

/* ── Rota grid ───────────────────────────────────────────────────────── */
.rotawrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.rota { border-collapse: collapse; font-size: 12px; width: 100%; }
table.rota th, table.rota td { border: 1px solid var(--line); padding: 0; text-align: center; }
table.rota th { background: #f0f2f5; font-weight: 600; padding: 4px 3px; }
table.rota th.weekend { background: #e2e6eb; }
/* Bank holiday — amber-tinted column header + a small BH tag (weekends and
   today still win their own header colour). */
table.rota th.bankhol { background: #fff4e0; }
.bh-tag { display: inline-block; font-size: 9px; font-weight: 700; line-height: 1;
    padding: 1px 3px; border-radius: 3px; background: #e69500; color: #fff; }
table.rota td { min-width: 34px; height: 34px; }
/* Today's column — red header + a red frame down the column */
table.rota th.todaycol { background: var(--accent); color: #fff; }
table.rota td.todaycol { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }
/* Day columns share the leftover width evenly; the name column keeps its
   natural (nowrap) width and doesn't stretch. */
table.rota th:not(.staffname) { width: 2.6%; }
table.rota .staffname {
    position: sticky;
    left: 0;
    background: #fff;
    text-align: left;
    padding: 4px 10px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 2;
    border-right: 2px solid var(--line);
}
table.rota th.staffname { background: #f0f2f5; z-index: 3; }
table.rota td.totalcol { background: #f7f9fb; font-weight: 700; font-size: 11px; padding: 2px 6px; min-width: 52px; }
.cellbtn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    width: 100%;
    height: 100%;
    min-height: 34px;
    border: 0;
    background: transparent;
    font: inherit;
    cursor: default;
    color: inherit;
    padding: 2px;
}
.ot-badge {
    font-size: 10px;
    font-weight: 700;
    color: #6e5200;
    background: #ffd54a;
    border-radius: 4px;
    padding: 0 4px;
    line-height: 1.4;
}
td.has-ot { background: #fff7db; }
/* Attendance discrepancy — red corner triangle on the rota cell */
table.rota td.att-issue { position: relative; }
table.rota td.att-issue::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    border-width: 0 10px 10px 0;
    border-style: solid;
    border-color: transparent var(--danger) transparent transparent;
}
/* Shift confirmed — clocked in AND out cleanly: dark green corner triangle */
table.rota td.clocked-ok { position: relative; }
table.rota td.clocked-ok::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    border-width: 0 10px 10px 0;
    border-style: solid;
    border-color: transparent #1b7a2f transparent transparent;
}
/* Clocked in/out but 15+ min off the shift time: orange corner triangle */
table.rota td.att-warn { position: relative; }
table.rota td.att-warn::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    border-width: 0 10px 10px 0;
    border-style: solid;
    border-color: transparent #e69500 transparent transparent;
}
.manager .cellbtn { cursor: pointer; }
.manager .cellbtn:hover { outline: 2px solid var(--accent); outline-offset: -2px; }

.cell-in      { background: #eefadc; color: #3c6e0a; }
.cell-holiday { background: #8DE635; color: #081024; font-weight: 700; }
.cell-lieu    { background: #b39ddb; color: #2d1b52; font-weight: 700; }
.cell-sick    { background: #f8c4d0; color: #8e0230; font-weight: 700; }
.cell-off     { background: #f0f2f5; color: #8a939d; }
.cell-wfh     { background: #ffe9a8; color: #6e5200; font-weight: 600; }
.cell-custom  { background: #aed6f1; color: #1a4d6d; font-weight: 600; }
.cell-worked  { background: #d3f5a4; color: #2f5a06; font-weight: 700; }
.cell-planned { background: repeating-linear-gradient(135deg, #eef4fb, #eef4fb 5px, #dbe8f5 5px, #dbe8f5 10px); color: #34567a; font-weight: 600; font-style: italic; }
/* Planned casual shift, confirmed once they clock in — solid green + tick */
.cell-planned.confirmed { background: #8DE635; color: #081024; font-weight: 700; font-style: normal; }
.cell-closed  { background: #081024; color: #9aa5b5; font-size: 10px; }
.cell-none    { color: #c3c9d0; }
td.haspending { box-shadow: inset 0 0 0 2px var(--accent); }

/* Rota note row + headcount/cover row */
table.rota tr.noterow td.daynote {
    font-size: 10px; color: #6e5200; background: #fffbe9; padding: 2px 3px;
    line-height: 1.2; vertical-align: middle; word-break: break-word;
}
table.rota tr.noterow th.staffname { background: #f0f2f5; font-size: 11px; }
.daynote.editable { cursor: pointer; }
.daynote.editable:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.daynote .addnote { color: #c3c9d0; font-weight: 700; }
table.rota tfoot .countrow td { font-weight: 700; font-size: 12px; background: #f7f9fb; }
table.rota tfoot .countrow th.staffname { background: #f0f2f5; }
table.rota tfoot .countrow td.undercover { background: #fdeef2; color: var(--danger); }
.countrow .warn { color: var(--danger); font-weight: 800; margin-left: 1px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; font-size: 12px; }
.legend span { padding: 3px 9px; border-radius: 5px; }

.monthnav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.monthnav h1 { margin: 0; font-size: 19px; }

/* ── Leave calendar ──────────────────────────────────────────────────── */
.calwrap { overflow-x: auto; }
table.leavecal { border-collapse: collapse; width: 100%; table-layout: fixed; min-width: 640px; }
table.leavecal th {
    background: #f0f2f5; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
    color: var(--muted); padding: 6px 4px; border: 1px solid var(--line); text-align: left;
}
table.leavecal td {
    border: 1px solid var(--line); vertical-align: top; padding: 4px; height: 78px; width: 14.28%;
}
table.leavecal td.othermonth { background: #fafbfc; }
table.leavecal td.othermonth .daynum { color: #c3c9d0; }
table.leavecal td.today { outline: 2px solid var(--brand-2); outline-offset: -2px; }
.leavecal .daynum { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.leavechip {
    display: block; font-size: 11px; font-weight: 600; border-radius: 4px;
    padding: 1px 6px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.leavechip.hol  { background: #8DE635; color: #081024; }
.leavechip.lieu { background: #b39ddb; color: #2d1b52; }
.legend .leavechip { display: inline-block; }

/* ── Status chips ────────────────────────────────────────────────────── */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip-pending  { background: #fff3cd; color: #7a5c00; }
.chip-approved { background: #e5f4e7; color: #1d5e28; }
.chip-declined { background: #fbe9e7; color: #a23527; }
.chip-cancelled{ background: #eef0f3; color: #66727f; }

/* ── Clock in/out card ───────────────────────────────────────────────── */
.clockcard { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.clockcard .clockstate { font-size: 15px; }
.clockcard .duein { font-size: 17px; font-weight: 700; color: var(--brand); margin-bottom: 3px; }
.clockcard .btn { min-width: 130px; text-align: center; font-size: 16px; padding: 12px 20px; }

/* ── Balance tiles ───────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .big { font-size: 24px; font-weight: 700; }
.tile .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(20,26,32,.55);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 12px;
    z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 18px;
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    overflow-y: auto;
}
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal .actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.notelist { list-style: none; margin: 0; padding: 0; }
.notelist li {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.notelist li:last-child { border-bottom: none; }
.notelist li.muted { color: var(--muted); }

/* ── Login page ──────────────────────────────────────────────────────── */
.loginwrap { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.loginwrap .card { padding: 22px; }
.loginlogo { text-align: center; font-size: 22px; font-weight: 800; color: var(--brand); margin-bottom: 18px; }
.tabbtns { display: flex; gap: 6px; margin-bottom: 16px; }
.tabbtns button {
    flex: 1; padding: 9px; border: 1px solid var(--line); background: #eef0f3;
    border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 14px;
}
.tabbtns button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* PIN keypad */
.pindots {
    height: 34px; text-align: center; font-size: 24px; letter-spacing: 6px;
    color: var(--brand); margin-bottom: 12px; min-height: 34px;
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad .key {
    font-size: 22px; font-weight: 600; padding: 16px 0; border: 1px solid var(--line);
    background: #fff; color: var(--ink); border-radius: 10px; cursor: pointer;
    -webkit-user-select: none; user-select: none;
}
.keypad .key:active { background: #eef0f3; }
.keypad .key-clear { color: var(--muted); }
.keypad .key-enter { background: var(--brand-2); color: var(--brand-2-ink); border-color: var(--brand-2); font-weight: 700; }

/* ── Wall display ────────────────────────────────────────────────────── */
.wallboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.wallcard { border-radius: 12px; padding: 16px; font-size: 20px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.wallcard .st { font-size: 14px; font-weight: 700; padding: 3px 10px; border-radius: 6px; }

/* Standalone full-screen (warehouse TV) */
body.wall { background: #081024; color: #e8ecf0; }
.wall .page { max-width: 1100px; }
.wall h1 { color: #fff; }
.wall .wall-head-in  { color: #8DE635; }
.wall .wall-head-out { color: #D90244; }
.wall .wallcard.in   { background: #122036; }
.wall .wallcard.out  { background: #20101d; }

/* In-app embedded (below the nav) */
.wall-embed .wall-head-in  { color: #3c6e0a; }
.wall-embed .wall-head-out { color: #D90244; }
.wall-embed .wallcard { border: 1px solid var(--line); color: var(--ink); }
.wall-embed .wallcard.in  { background: #eefadc; }
.wall-embed .wallcard.out { background: #fdeef2; }
