/* Dark theme matching the desktop Admin panel. */
:root {
    --bg: #1e1e24;
    --panel: #26262e;
    --panel-2: #2d2e31;
    --line: #3c4043;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --green: #00e676;
    --red: #ff5c86;
    --amber: #ffb300;
    --blue: #29b6f6;
    --grey: #7a7f87;
    --danger: #ff2e63;
    --radius: 8px;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

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

h1 { font-size: 1.45rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 10px 20px;
    background: #17171c;
    border-bottom: 1px solid var(--line);
}
.brand { color: var(--green); font-weight: 700; font-size: 1.05rem; }
.topbar nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topbar nav a, .topbar nav .link {
    color: var(--muted);
    padding: 6px 10px;
    border-radius: 6px;
}
.topbar nav a[aria-current="page"] { color: var(--text); background: var(--panel-2); }
.topbar nav a:hover { color: var(--text); text-decoration: none; }

main { padding: 18px 20px 8px; max-width: 1500px; margin: 0 auto; }
footer { color: var(--grey); font-size: 0.8rem; font-style: italic; text-align: center; padding: 14px 20px 24px; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .grid.two { grid-template-columns: minmax(0, 1fr); } }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    min-width: 0;
}
.card.narrow { max-width: 420px; margin: 40px auto; }
.card-danger { border-color: #5a2633; }
.card-danger h2 { color: var(--danger); }
.error-card h2 { color: var(--red); }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 12px;
}
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.subtle { color: var(--muted); font-weight: 400; font-size: 0.85rem; margin-left: 6px; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.empty { padding: 30px 0; text-align: center; }
.crumbs { margin: 0 0 4px; color: var(--muted); font-size: 0.85rem; }
.ok-text { color: var(--green); }
.error-text { color: var(--red); }

.banner, .flash {
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 14px;
    font-weight: 600;
}
.banner-warn { background: var(--amber); color: #1e1e24; }
.banner-muted { background: var(--panel-2); color: var(--muted); }
.flash-ok { background: #123d2b; color: var(--green); border: 1px solid #1d6b48; }
.flash-error { background: #4a1724; color: #ffb3c6; border: 1px solid #7a2a3e; }

/* Forms */
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 14px;
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.button:hover, button:hover { filter: brightness(1.08); text-decoration: none; }
button.secondary { background: #5f6368; }
button.danger { background: var(--danger); }
button.link {
    background: none;
    color: var(--blue);
    padding: 0;
    min-height: 0;
    font-weight: 400;
}
.topbar nav button.link { color: var(--muted); padding: 6px 10px; }
button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 9px;
    font: inherit;
    min-height: 34px;
    max-width: 100%;
}
input[type=search] { width: 240px; }

form.inline { display: inline; margin: 0; }
.inline-form, .range-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin: 0;
}
.range-form label, .inline-form label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.custom-fields { display: inline-flex; flex-wrap: wrap; gap: 8px 12px; }
.custom-fields[hidden] { display: none; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 0.9rem; }
.stack button { align-self: flex-start; }

.filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-bottom: 12px;
}
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented label { padding: 6px 12px; cursor: pointer; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.segmented label:has(input:checked) { background: var(--panel-2); color: var(--text); }

/* Tables */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.table-wrap.tall { max-height: 520px; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th, table.data td {
    padding: 8px 10px;
    border-bottom: 1px solid #33343a;
    text-align: left;
    white-space: nowrap;
}
table.data thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #3c4043;
    color: #fff;
    font-weight: 600;
}
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: #303139; }
.row-actions { text-align: right; }

tr.tag-done td { color: var(--green); }
tr.tag-idle td { color: var(--red); }
tr.tag-stale td { color: var(--amber); }
tr.tag-quiet td { color: var(--muted); }
tr.tag-done td a, tr.tag-idle td a, tr.tag-stale td a { color: inherit; }
tr.is-dormant td, tr.is-removed td { color: var(--grey); }
tr.is-selected { background: #233548 !important; }

/* Rows that are hidden until their checkbox is ticked */
#leaderboard:not(.show-dormant) tr.is-dormant,
#clients:not(.show-removed) tr.is-removed { display: none; }
tr[hidden] { display: none; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid #33343a; }

/* Charts */
.chart-box { position: relative; height: 360px; margin-top: 10px; }
@media (max-width: 600px) { .chart-box { height: 280px; } }

/* History grid */
.history-wrap { max-height: 70vh; }
table.history th.sticky {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--panel);
    text-align: left;
}
table.history thead th.sticky { z-index: 3; background: #3c4043; }
table.history thead tr.totals th { top: 37px; background: #2a2b31; color: var(--text); }
table.history thead tr.totals th.sticky { background: #2a2b31; }
table.history th small { display: block; color: var(--muted); font-weight: 400; font-size: 0.75rem; }
table.history th.weekend { color: var(--muted); }
table.history th.is-hidden-staff { color: var(--muted); font-style: italic; }
table.history td a { display: block; color: inherit; }
table.history td.has-done { color: var(--green); font-weight: 600; }
table.history td.has-rows { color: var(--amber); }
table.history td.zero { color: var(--red); }
table.history td.no-report { color: var(--grey); }
table.history td.day-total { color: var(--text); font-weight: 600; }
table.history.metric-done .m-rows,
table.history.metric-rows .m-done { display: none; }
