:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #1b1f27;
    --muted: #5d6675;
    --border: #d5d9e0;
    --accent: #1f5fbf;
    --accent-text: #ffffff;
    --danger: #b3261e;
    --ok-bg: #e5f4ea;
    --ok-text: #14532d;
    --warn-bg: #fff4d6;
    --warn-text: #6b4a00;
    --err-bg: #fdecea;
    --err-text: #7a1710;
    --info-bg: #e8f0fc;
    --info-text: #17407f;
    --radius: 10px;
    --tap: 44px;
}

* { box-sizing: border-box; }

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

h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.2; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
a { color: var(--accent); }
p { margin: 0 0 .75rem; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.strong { font-weight: 600; }

/* ---- Shell ---------------------------------------------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem 1rem;
    padding: .5rem 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }

.nav { display: flex; gap: .25rem; flex: 1 1 auto; overflow-x: auto; }
.nav a {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    padding: 0 .75rem;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}
.nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }

.user { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.user-name { color: var(--muted); font-size: .875rem; }

.page { max-width: 880px; margin: 0 auto; padding: 16px 16px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.head-status { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.crumb { margin-bottom: .5rem; }

/* ---- Controls ------------------------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 .75rem; font-size: .9rem; }
.btn.icon { min-width: var(--tap); padding: 0; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

input[type="text"], input[type="search"], input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    min-height: var(--tap);
    padding: .4rem .65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
textarea { resize: vertical; }

.label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .35rem 0 0; }
.field { display: block; }
.field-group { margin-bottom: 1rem; }

/* ---- Cards, banners, badges ----------------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 1rem;
}

.banner { padding: .75rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; }
.banner p { margin: .25rem 0 0; }
.banner-error { background: var(--err-bg); color: var(--err-text); }
.banner-ok { background: var(--ok-bg); color: var(--ok-text); }
.banner-info { background: var(--info-bg); color: var(--info-text); }
.banner .muted { color: inherit; opacity: .8; }

.badge {
    display: inline-block;
    padding: .1rem .55rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
}
.badge-approved { background: var(--ok-bg); color: var(--ok-text); }
.badge-submitted { background: var(--warn-bg); color: var(--warn-text); }
.badge-rejected { background: var(--err-bg); color: var(--err-text); }
.badge-draft { background: var(--info-bg); color: var(--info-text); }

.tag {
    display: inline-block;
    margin-left: .4rem;
    padding: 0 .45rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .75rem;
    color: var(--muted);
}

/* ---- Lists ---------------------------------------------------------------------------------------------- */

.start-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.start-row label { flex: 1 1 180px; }
.start-row .btn { flex: 0 0 auto; }

.week-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.week-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding-right: .75rem;
}
.week-link {
    flex: 1 1 260px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .35rem .75rem;
    min-height: 56px;
    padding: .65rem .85rem;
    color: inherit;
    text-decoration: none;
}
.week-link:hover { background: var(--surface-2); border-radius: var(--radius); }
.week-date { display: flex; flex-direction: column; }
.week-meta { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; }
.hours { font-variant-numeric: tabular-nums; font-weight: 600; }
.admin-row .reassign { display: flex; gap: .5rem; padding: 0 .5rem .65rem; width: 100%; }
.filter { max-width: 240px; margin-bottom: 1rem; }

.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab {
    min-height: var(--tap);
    padding: 0 1rem;
    border: 0;
    border-bottom: 3px solid transparent;
    background: none;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.people { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: .5rem; }
.person {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .1rem;
    padding: .75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.person:hover { background: var(--surface-2); }
.person span { color: var(--muted); font-size: .9rem; }

/* ---- Days ----------------------------------------------------------------------------------------------- */

[hidden] { display: none !important; }

.head-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: flex-end; }

/* Day tabs sit across the top of the week; on a phone they scroll sideways if they must. */
.daytabs {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .25rem;
    margin-bottom: .75rem;
}
.daytab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-height: 64px;
    padding: .35rem .15rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
}
.daytab:hover { background: var(--surface-2); }
.daytab .dt-name { font-size: .8rem; color: var(--muted); }
.daytab .dt-date { font-weight: 700; font-size: 1.05rem; }
.daytab .dt-hours { font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.daytab.empty .dt-date { color: var(--muted); font-weight: 500; }
.daytab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.daytab.active .dt-name, .daytab.active .dt-hours, .daytab.active .dt-date { color: inherit; }
.daytab.invalid { border-color: var(--danger); }
.daytab.invalid .dt-hours { color: var(--danger); font-weight: 700; }
.daytab.invalid.active .dt-hours { color: inherit; }

.day-panel { margin-bottom: .75rem; }
.day-title { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .75rem; }
.day-title h2 { margin: 0; }
.day-total { font-variant-numeric: tabular-nums; }
.day-nav { display: flex; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.day-body { padding: 0; }

.period-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.period-row .to { color: var(--muted); }
.time-field { position: relative; display: inline-flex; align-items: center; flex: 1 1 0; min-width: 0; }
.time-text { text-align: center; font-variant-numeric: tabular-nums; }

/* The native picker is for touch screens: tapping the clock opens the phone's time picker. */
.time-native { display: none; }
@media (pointer: coarse) {
    .time-native {
        display: block;
        position: absolute;
        right: 2px;
        top: 2px;
        bottom: 2px;
        width: 36px;
        overflow: hidden;
        text-align: center;
        line-height: 40px;
        cursor: pointer;
    }
    .time-native input { position: absolute; inset: 0; width: 100%; min-height: 0; opacity: 0; padding: 0; }
    .time-text { padding-right: 38px; }
}

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (min-width: 560px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.leave-row { display: flex; gap: .5rem; margin-bottom: .5rem; align-items: center; }
.leave-row select { flex: 1 1 auto; }
.leave-row .leave-hours { flex: 0 0 90px; width: 90px; }

.save-state { min-height: 1.5rem; margin-top: .5rem; }
.saved { color: var(--ok-text); font-size: .875rem; }
.errors { margin: 0 0 .25rem; padding-left: 1.25rem; color: var(--err-text); }
.not-saved { color: var(--err-text); font-size: .875rem; margin: 0; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.pill { display: inline-block; margin: 0 .35rem .25rem 0; padding: .05rem .6rem; border-radius: 999px; background: var(--surface-2); font-variant-numeric: tabular-nums; }

/* ---- Summary and actions -------------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.summary-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.summary-table th, .summary-table td { padding: .4rem .5rem; border-bottom: 1px solid var(--border); text-align: left; font-weight: 400; }
.summary-table thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.summary-table tbody th { font-weight: 500; white-space: nowrap; }
.summary-table .num { text-align: right; }
.summary-table tr.zero { color: var(--muted); }
.summary-table tbody th, .summary-table tbody td { vertical-align: top; }
.day-label { display: block; }
.bands { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.leave-line { display: block; margin-top: .25rem; font-size: .85rem; font-weight: 400; }
.day-note { display: block; margin-top: .25rem; font-size: .85rem; font-weight: 400; color: var(--muted); font-style: italic; white-space: pre-wrap; overflow-wrap: anywhere; }
.bands .pill { margin: 0; font-size: .85rem; font-weight: 400; color: var(--text); }
.summary-table tfoot th, .summary-table tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--border); }

.warnings { margin-top: 1rem; padding: .75rem 1rem; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn-text); }
.warnings ul { margin: 0; padding-left: 1.25rem; }
.warnings .hint { color: inherit; opacity: .85; }

.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1rem; }
.confirm, .decision { width: 100%; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: grid; gap: .75rem; justify-items: start; }
.confirm p { margin: 0; }
.decision textarea { min-width: min(100%, 420px); }
.others ul { margin: 0; padding-left: 1.1rem; }

/* ---- Blazor chrome -------------------------------------------------------------------------------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    padding: .75rem 1.25rem;
    background: var(--warn-bg);
    color: var(--warn-text);
    box-shadow: 0 -1px 4px rgba(0, 0, 0, .25);
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.blazor-error-boundary { padding: 1rem; background: var(--err-bg); color: var(--err-text); border-radius: var(--radius); }
.blazor-error-boundary::after { content: "An error has occurred."; }

@media (max-width: 480px) {
    .user-name { display: none; }
}

.employee-filters { display: flex; flex-wrap: wrap; gap: .75rem 1rem; margin-bottom: 1rem; }
.employee-filters .field { flex: 1 1 200px; max-width: 280px; }

/* The padding sits on the row itself (a week row keeps it on the inner link). */
.employee-row { padding: .75rem .85rem; gap: .75rem 1.5rem; justify-content: space-between; }
.employee-info { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.employee-info .week-meta { margin-top: .25rem; }
.employee-dates { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: flex-end; margin-left: auto; }
.employee-dates .field { width: 11rem; }

.app-version { font-size: 0.75rem; opacity: 0.7; margin-right: 1rem; align-self: center; }
.version { font-size: 0.8rem; margin-top: 2rem; }
