:root {
    --bg: #14161b;
    --panel: #1d2027;
    --panel-2: #252932;
    --border: #333845;
    --text: #e6e3da;
    --muted: #8c909b;
    --gold: #e8b64c;
    --done: #3fae62;
    --danger: #d9534f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

h1 { margin: 0; font-size: 22px; color: var(--gold); letter-spacing: .5px; }
h2 { margin: 0 0 12px; font-size: 17px; color: var(--gold); }

main { padding: 20px 24px; }

button, input, select {
    font: inherit;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
}
button { cursor: pointer; }
button:hover { border-color: var(--gold); }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; }
button.link:hover { color: var(--text); }
button.danger:hover { border-color: var(--danger); color: var(--danger); }

nav { display: flex; gap: 6px; }
#logout { margin-left: auto; }
body.signed-out nav, body.signed-out #logout { display: none; }

.login { display: flex; flex-direction: column; gap: 10px; width: 280px; margin: 80px auto; padding: 20px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.login h2 { margin: 0; }
.login-error { color: var(--danger); font-size: 13px; }
nav button.active { border-color: var(--gold); color: var(--gold); }

.muted { color: var(--muted); font-size: 13px; }

/* Week view */
.week-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.week-label { font-size: 18px; font-weight: 600; }
.badge-current { color: var(--done); font-size: 12px; margin-left: 8px; }

/* Separate borders so they travel with the sticky header/footer cells. */
table.grid { border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.grid th, .grid td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 10px; }
.grid tr > :last-child { border-right: none; }
.grid thead th { position: sticky; top: 0; z-index: 1; background: var(--panel-2); font-weight: 600; min-width: 90px; max-width: 150px; vertical-align: bottom; }
.grid thead th[title] { cursor: help; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.grid thead th:first-child { border-top-left-radius: 8px; }
.grid thead th:last-child { border-top-right-radius: 8px; }
.grid th .lvl { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.grid thead th .lvl .req:first-child { margin-left: 0; }
.grid tbody th { text-align: left; font-weight: 500; white-space: nowrap; }
.grid tfoot td { position: sticky; bottom: 0; z-index: 1; background: var(--panel-2); border-bottom: none; }
.grid tfoot td, .grid .row-total { color: var(--muted); font-size: 13px; text-align: center; }
.grid tfoot td.all-done, .grid .row-total.all-done { color: var(--done); }

.req { font-size: 11px; padding: 1px 6px; border-radius: 10px; margin-left: 6px; border: 1px solid var(--border); color: var(--muted); }
.req-90 { border-color: var(--gold); color: var(--gold); }

td.cell { text-align: center; padding: 0; }
td.cell button {
    width: 100%;
    min-height: 38px;
    border: none;
    border-radius: 0;
    background: none;
    font-size: 20px;
    color: var(--border);
}
td.cell button:hover { background: var(--panel-2); color: var(--muted); }
td.cell.done button { color: var(--done); background: rgba(63, 174, 98, .12); }
td.cell.done button.check { min-height: 26px; padding-bottom: 0; }
td.cell button.gold-edit {
    min-height: 0;
    padding: 0 4px 4px;
    font-size: 12px;
    color: var(--muted);
    background: rgba(63, 174, 98, .12);
}
td.cell button.gold-edit:hover { color: var(--text); text-decoration: underline; }
td.cell button.gold-edit.custom { color: var(--gold); font-weight: 600; }
.gold-input { width: 70px; margin: 2px 4px 4px; padding: 2px 4px; font-size: 12px; text-align: center; }
.gold { display: block; color: var(--gold); font-size: 12px; }
.gold-inline { color: var(--gold); font-size: 13px; margin-left: 6px; }

td.cell.na { background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255,255,255,.03) 6px 12px); color: var(--muted); font-size: 12px; }

.empty { padding: 24px; background: var(--panel); border-radius: 8px; color: var(--muted); }

/* History */
.history-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
}
.history-row:hover { border-color: var(--gold); }
.history-row .when { width: 190px; font-weight: 600; }
.history-row .total { width: 70px; text-align: right; }
.bar { flex: 0 0 160px; height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; background: var(--done); }
.history-row .week-gold { width: 90px; text-align: right; color: var(--gold); }
.summary { display: flex; gap: 32px; margin-bottom: 16px; }
.summary > div { display: flex; flex-direction: column; }
.summary b { font-size: 20px; color: var(--gold); }
.history-row .chars { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }

/* Manage */
.manage { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.panel form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.panel form input[name=name] { flex: 1 1 140px; }
.panel form input[name=notes] { flex: 1 1 100%; }
.panel form input[name=level] { width: 70px; }
.panel form input[name=gold] { width: 90px; }
.sync { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sync-error { color: var(--danger); font-size: 13px; }
.sync-warn { color: var(--danger); cursor: help; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.list li .grow { flex: 1; }
.list li button { padding: 2px 8px; font-size: 13px; }
