:root {
    --brand: #cc3300;
    --brand-dark: #a32900;
    --bg: #f4f4f5;
    --card: #ffffff;
    --text: #18181b;
    --muted: #6b6b73;
    --border: #e4e4e7;
    --danger: #b91c1c;
    --radius: 10px;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h1:focus { outline: none; }
.muted { color: var(--muted); }

/* ---- App shell ---- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1rem .75rem; }
.brand { display: flex; gap: .6rem; align-items: center; color: var(--text); padding: .25rem .5rem 1rem; }
.brand:hover { text-decoration: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { color: var(--text); padding: .5rem .75rem; border-radius: 8px; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--bg); font-weight: 600; }
.user { display: grid; grid-template-columns: auto 1fr; gap: .25rem .6rem; align-items: center; border-top: 1px solid var(--border); padding: .75rem .5rem 0; }
.user .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-weight: 600; }
.user .who { display: flex; flex-direction: column; min-width: 0; }
.user .who small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.user form { grid-column: 1 / -1; }
button.link, a.link { display: inline-flex; align-items: center; gap: .3rem; background: none; border: 0; padding: .15rem .1rem; color: var(--brand); cursor: pointer; font: inherit; font-weight: 500; }
button.link:hover, a.link:hover { color: #a32900; text-decoration: underline; }
button.link.danger, a.link.danger { color: var(--danger); }
button.link.danger:hover { color: #7f1d1d; }
button.link:disabled { color: var(--muted); cursor: not-allowed; text-decoration: none; opacity: .6; }
svg.icon { flex-shrink: 0; vertical-align: -.2em; }
.content { padding: 2rem 2.5rem; min-width: 0; }

/* ---- Dashboard tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .25rem; }
.tile span { font-size: 1.6rem; font-weight: 700; }
.tile small { color: var(--muted); }

/* ---- Sign-in ---- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-card img { margin-bottom: 1rem; }
.auth-card h1 { font-size: 1.35rem; }
.form { display: flex; flex-direction: column; gap: 1rem; text-align: left; margin-top: 1.5rem; }
.form label { display: flex; flex-direction: column; gap: .4rem; font-size: .9rem; font-weight: 500; }
.form label.check { flex-direction: row; align-items: center; font-weight: 400; }
.form input[type=email], .form input[type=password], .form input[type=text] {
    border: 1px solid var(--border); border-radius: 8px; padding: .65rem .75rem; font: inherit; background: var(--card);
}
.form input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
button.primary { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: .7rem 1rem; font: inherit; font-weight: 600; cursor: pointer; }
button.primary:hover { background: var(--brand-dark); }
.alert { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; border-radius: 8px; padding: .6rem .75rem; margin: 0; }
.validation-message { color: var(--danger); font-size: .82rem; font-weight: 400; }

/* ---- Blazor error bar ---- */
#blazor-error-ui { background: #fffbe6; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ---- Phones: top bar + slide-out menu ---- */
.nav-open, .topbar, .nav-backdrop, .menu-close { display: none; }
@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }   /* top bar, then the page (the drawer is out of the flow) */
    .content { padding: 1rem .9rem 2rem; }
    .topbar { display: flex; align-items: center; gap: .5rem; position: sticky; top: 0; z-index: 30; height: 52px; padding: 0 .6rem;
              background: var(--card); border-bottom: 1px solid var(--border); }
    .topbar .brand { padding: 0; gap: .45rem; font-size: .98rem; }
    .menu-btn, .menu-close { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; cursor: pointer; color: var(--text); }
    .menu-btn:active, .menu-close:active { background: var(--bg); }
    .menu-close { position: absolute; top: .55rem; right: .5rem; }
    .sidebar { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(85vw, 300px); overflow-y: auto; overscroll-behavior: contain;
               border-right: 1px solid var(--border); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.18); }
    .nav-open:checked ~ .shell .sidebar { transform: none; }
    .nav-open:checked ~ .shell .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15, 15, 20, .35); }
    body:has(.nav-open:checked) { overflow: hidden; }
    .nav a, .nav .section { padding-top: .6rem; padding-bottom: .6rem; }   /* bigger touch targets */

    /* Tables: tighter on small screens; wide ones scroll inside their box. */
    table.data { font-size: .84rem; }
    table.data th, table.data td { padding: .45rem .55rem; white-space: nowrap; }   /* rows stay one line; the box scrolls */
    table.data input.input { width: 6.8rem !important; }
    .page-head h1, h1 { font-size: 1.35rem; }
}


/* ---- Page building blocks ---- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { display: flex; align-items: center; gap: .6rem; margin: 0; }
.page-head p { margin: .25rem 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.crumbs a { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.narrow { max-width: 900px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.card > h2, .card > header h2 { font-size: 1rem; margin: 0 0 .75rem; }
.card > header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.card > header h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.metric { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; }
.metric small { display: block; color: var(--muted); font-size: .78rem; margin-bottom: .3rem; }
.metric span { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.metric.strong span { font-size: 1.3rem; font-weight: 700; }

.btn { display: inline-flex; align-items: center; gap: .35rem; background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 8px;
       padding: .5rem .9rem; font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.outline { background: var(--card); color: var(--text); border-color: var(--border); }
.btn.outline:hover { background: var(--bg); }
.btn.danger { background: #fef2f2; color: var(--danger); border-color: #f87171; }
.btn.danger:hover:not(:disabled) { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small:has(> svg.icon:only-child) { padding: .35rem; min-width: 1.9rem; justify-content: center; }
.btn.small { padding: .3rem .6rem; font-size: .82rem; }
.btn[disabled] { opacity: .55; cursor: default; pointer-events: none; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card .table-wrap { border: 0; border-radius: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-weight: 600; background: #fafafa; padding: .55rem .8rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: .5rem .8rem; border-top: 1px solid var(--border); vertical-align: top; }
table.data tbody tr:first-child td { border-top: 0; }
table.data tr:hover td { background: #fcfcfc; }
table.data .num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
table.data .empty { text-align: center; color: var(--muted); padding: 2rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
.nowrap { white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; padding: .1rem .55rem; font-size: .72rem; font-weight: 600; background: #f4f4f5; color: #3f3f46; letter-spacing: .02em; }
.pill.draft { background: #fef3c7; color: #92400e; }
.pill.processing { background: #e0e7ff; color: #3730a3; }
.pill.calculated { background: #dbeafe; color: #1e40af; }
.pill.approved { background: #dcfce7; color: #166534; }
.pill.paid { background: #d1fae5; color: #065f46; }
.pill.closed { background: #e4e4e7; color: #3f3f46; }
.pill.failed, .pill.inactive { background: #fee2e2; color: #991b1b; }
.pill.active { background: #dcfce7; color: #166534; }
.pill.outline { background: none; border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.spinner { width: .75em; height: .75em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { border-radius: 8px; padding: .7rem 1rem; font-size: .9rem; border: 1px solid; }
.banner.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.banner.info { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; display: flex; gap: .5rem; align-items: center; }
.banner.warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.flash { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-radius: 8px; padding: .65rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.flash.success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.flash.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.field { display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; font-weight: 500; }
.field small { font-weight: 400; color: var(--muted); }
.field .validation-message, .field .error { color: var(--danger); font-weight: 400; font-size: .82rem; }
.input, .field input:not([type=checkbox]):not([type=file]), .field select, .field textarea, input.input, select.input {
    border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; font: inherit; font-weight: 400; background: var(--card); color: var(--text); min-width: 0; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.check { display: flex; align-items: center; gap: .45rem; font-size: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.search { display: flex; gap: .5rem; }
.search .input { width: 240px; }

dl.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .78rem; }
dl.facts dd { margin: .15rem 0 0; font-size: .92rem; }
.net { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.net strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }

.pager { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: .75rem; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; }
.modal { position: fixed; z-index: 51; top: 10vh; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 32px)); max-height: 80vh; overflow-y: auto;
         background: var(--card); border-radius: 12px; padding: 1.25rem 1.4rem; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal header { display: flex; justify-content: space-between; align-items: center; }
.modal h2 { font-size: 1.1rem; margin: 0; }
.modal > p { margin: .4rem 0 1rem; font-size: .9rem; }

.nav a.top { display: flex; align-items: center; gap: .6rem; font-weight: 500; }
.nav .section { display: flex; align-items: center; gap: .6rem; width: 100%; margin-top: .35rem; padding: .5rem .75rem; border: 0; border-radius: 8px; background: none; cursor: pointer; font: inherit; font-size: .95rem; font-weight: 600; color: var(--text); text-align: left; }
.nav .section:hover { background: var(--bg); }
.nav .section:focus-visible { outline: 2px solid var(--accent, #c2410c); outline-offset: 1px; }
.nav .section .label { flex: 1; }
.nav .nav-icon { flex-shrink: 0; color: var(--muted); }
.nav .section:hover .nav-icon, .nav a.top.active .nav-icon { color: var(--text); }
.nav .section .chevron { display: flex; transition: transform .15s ease; }
.nav .section.open .chevron { transform: rotate(90deg); }
.nav .children { display: flex; flex-direction: column; gap: 1px; margin: .1rem 0 .3rem 1.45rem; padding-left: .55rem; border-left: 1px solid var(--border); }
.nav .children a { font-size: .9rem; padding: .4rem .7rem; }
.pill.earning { background: #dcfce7; color: #166534; }
.pill.deduction { background: #fef3c7; color: #92400e; }
.pill.statutory { background: #dbeafe; color: #1e40af; }
button.pill { border: 0; cursor: pointer; }
.grid-2.grades { grid-template-columns: repeat(auto-fill, minmax(min(100%, 540px), 1fr)); }
.grid-2.grades .card { overflow-x: auto; }
.grid-2.grades table.data th { padding: .45rem .5rem; }
.grid-2.grades table.data td { vertical-align: middle; padding: .35rem .5rem; }
.metric.strong span { font-size: 1.2rem; }
.chip { border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: .25rem .75rem; font: inherit; font-size: .8rem; cursor: pointer; }
.chip:hover { background: var(--bg); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.menu { position: relative; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; width: 16rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px;
              box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: .5rem; display: flex; flex-direction: column; gap: .15rem; }
.menu-panel > small { padding: .3rem .5rem; }
.menu-panel a, .menu-panel button.link { display: block; text-align: left; padding: .45rem .5rem; border-radius: 6px; color: var(--text); font-size: .9rem; }
.menu-panel a:hover, .menu-panel button.link:hover { background: var(--bg); text-decoration: none; }
.banner.success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

/* ---- Employee profile ---- */
.profile-head { display: flex; align-items: center; gap: 1rem; }
.photo-box { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.photo-box img, .photo-empty { width: 84px; height: 108px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); background: var(--bg); }
.photo-empty { display: grid; place-items: center; font-size: 1.6rem; font-weight: 700; color: var(--muted); }
.photo-actions { display: flex; gap: .6rem; font-size: .78rem; }
.photo-actions .link { cursor: pointer; }
.photo-box .error { color: var(--danger); font-size: .75rem; max-width: 12rem; text-align: center; }
.kin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.kin { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; font-size: .9rem; }
.kin-lines { margin-top: .5rem; display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; }
.kin-actions { margin-top: .6rem; padding-top: .45rem; border-top: 1px solid var(--border); display: flex; gap: .9rem; font-size: .82rem; }
.audit-list { display: flex; flex-direction: column; gap: .6rem; }
.audit-entry { border-left: 3px solid var(--border); padding: .2rem .75rem; font-size: .88rem; }
.audit-head { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.audit-changes { margin-top: .3rem; font-size: .8rem; border-collapse: collapse; }
.audit-changes td { padding: .1rem .5rem .1rem 0; vertical-align: top; overflow-wrap: anywhere; }
.audit-changes td:first-child { color: var(--muted); }
.audit-changes .old { color: var(--muted); text-decoration: line-through; }
textarea { font: inherit; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--border); margin-top: 1rem; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: .55rem .8rem; font: inherit; font-size: .9rem; font-weight: 500; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--text); border-bottom-color: var(--brand); }
.tabs button small { margin-left: .3rem; color: var(--muted); }
.metric .big { font-size: 1.5rem; font-weight: 700; }
.big.green { color: #15803d; } .big.blue { color: #1d4ed8; } .big.amber { color: #b45309; }
.progress { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; margin-top: .5rem; }
.progress > div { height: 100%; background: var(--brand); transition: width .3s; }

/* Report links (run page, employee profile) */
.report-links { display: flex; flex-wrap: wrap; gap: .5rem; }
.report-link { display: inline-flex; align-items: center; gap: .25rem; }
.report-link a.excel { font-size: .75rem; color: #047857; text-decoration: none; padding: .25rem .4rem; border-radius: 4px; }
.report-link a.excel:hover { background: #ecfdf5; }
.report-link button.icon { display: inline-flex; align-items: center; background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0 .2rem; }
.report-link button.icon:hover { color: inherit; }
.text-danger { color: #dc2626; }
.small { font-size: .8rem; }

/* Staff portal */
.avatar-photo { width: 56px; height: 72px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--bg); display: grid; place-items: center; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.avatar-photo img { width: 100%; height: 100%; object-fit: cover; }
.request-item { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; font-size: .88rem; }
.request-item + .request-item { margin-top: .6rem; }
.request-item .values { color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.banner.info ul { margin: .25rem 0 0 1.2rem; padding: 0; }
.field-error { color: var(--danger); font-size: .78rem; margin-top: .2rem; }
.notice { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; border-radius: 8px; padding: .6rem .75rem; margin: 0; font-size: .9rem; }
.auth-links { margin-top: 1rem; font-size: .85rem; }
.tabs a { border-bottom: 2px solid transparent; margin-bottom: -1px; padding: .55rem .8rem; font-size: .9rem; font-weight: 500; color: var(--muted); text-decoration: none; }
.tabs a.active { color: var(--fg, inherit); border-bottom-color: currentColor; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.perm-group { border: 1px solid var(--border); border-radius: 8px; padding: .7rem .9rem; }
.perm-group h3 { font-size: .9rem; margin: 0 0 .4rem; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .75rem; }
a.tile { color: inherit; text-decoration: none; } a.tile:hover { border-color: var(--accent, #c2410c); }

/* Upload type choice (month-only vs standing) */
.mode-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .6rem; }
.mode-choice label { display: flex; gap: .6rem; align-items: flex-start; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--card); }
.mode-choice label.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); background: #fff7f4; }
.mode-choice input { margin-top: .2rem; accent-color: var(--brand); }
.mode-choice span { display: flex; flex-direction: column; gap: .2rem; }
.mode-choice small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.metric .big { font-size: 1.5rem; font-weight: 700; }
.metric .big.ok { color: #15803d; } .metric .big.bad { color: var(--danger); } .metric .big.warn { color: #b45309; } .metric .big.muted { color: var(--muted); }

/* A soft shadow at the edge of a table box that scrolls sideways, so it's clear there is more. */
.table-wrap, .grid-2.grades .card {
    background:
        linear-gradient(to right, var(--card) 30%, rgba(255,255,255,0)) left center / 40px 100% no-repeat local,
        linear-gradient(to left, var(--card) 30%, rgba(255,255,255,0)) right center / 40px 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.16), rgba(0,0,0,0)) left center / 12px 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.16), rgba(0,0,0,0)) right center / 12px 100% no-repeat scroll,
        var(--card);
}
