:root {
    --bg: #0f172a;
    --card: #1e293b;
    --line: #334155;
    --text: #f8fafc;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --ok: #16a34a;
    --err: #f87171;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, sans-serif;
}

.screen { min-height: 100vh; display: flex; }
.screen.column { flex-direction: column; }
.hidden { display: none !important; }
.card {
    width: min(420px, 100%);
    margin: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 24px;
}
h1, h2, h3 { margin-top: 0; }
.hint, .muted, .empty { color: var(--muted); }
input {
    width: 100%;
    margin: 12px 0;
    padding: 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #0b1220;
    color: var(--text);
    font-size: 18px;
}
.btn {
    width: 100%;
    border: 0;
    border-radius: 10px;
    padding: 14px;
    font-size: 18px;
    background: #334155;
    color: var(--text);
}
.btn.primary { background: #0284c7; }
.btn.ghost { width: auto; background: transparent; border: 1px solid var(--line); }
.error { margin-top: 12px; color: var(--err); }
#qr-scanner { width: 100%; min-height: 180px; background: #000; border-radius: 12px; }
.topbar, .tabs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}
.tabs { border-top: 1px solid var(--line); border-bottom: 0; }
.tab { flex: 1; background: transparent; color: var(--muted); border: 0; padding: 16px; font-size: 18px; }
.tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.content { flex: 1; padding: 16px; overflow: auto; }
.task {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.task button { width: auto; background: #2563eb; }
.task-card { flex-wrap: wrap; align-items: flex-start; }
.task-main { flex: 1; min-width: 0; cursor: pointer; }
.task-details {
    flex: 1 0 100%;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}
.task-op { margin-bottom: 8px; }
.mu-period-row {
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.mu-period-row select {
    width: auto;
    min-width: 140px;
    margin: 0;
    padding: 8px 10px;
    font-size: 16px;
}
.mu-summary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.mu-summary > div {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
}
.mu-summary strong { display: block; font-size: 22px; margin-top: 4px; }
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.mode-row {
    display: flex;
    gap: 16px;
    margin: 8px 0 4px;
}
.mode-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}
.field-label {
    display: block;
    margin: 10px 0 4px;
    color: var(--muted);
    font-size: 14px;
}
.finish-card { width: min(520px, 100%); }
.finish-selected {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #0b1220;
}
.finish-selected div { display: flex; flex-direction: column; gap: 2px; }
.finish-mode-cap { margin: 8px 0 0; }
.date-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.date-row input[type="date"] { flex: 1; margin: 0; }
.today-check {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.today-check input { width: auto; margin: 0; }
#earned-input { background: #111827; color: var(--muted); }
.row { display: flex; gap: 12px; margin-top: 12px; }
.row .btn { flex: 1; }
.btn.ok { background: var(--ok); }

#status-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    background: #020617;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.chip {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: #86efac;
}
.chip.offline { color: var(--err); }
.chip.muted { color: var(--muted); margin-left: auto; }
.brand { letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: #0b1220;
    border: 1px solid var(--line);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 12px;
    z-index: 50;
    max-width: 90vw;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
#idle-hint { font-size: 12px; max-width: 140px; text-align: right; }

.master-body .content { padding-top: 8px; }
.master-layout { max-width: 1100px; margin: 0 auto; width: 100%; }
.master-toolbar { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.master-toolbar .btn { width: auto; }
.add-person {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}
.add-person input {
    width: auto;
    min-width: 140px;
    margin: 0;
    padding: 10px 12px;
}
.add-person .btn { width: auto; }
.master-split { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 16px; }
.master-list { display: flex; flex-direction: column; gap: 8px; }
.person {
    text-align: left;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 12px;
    padding: 12px;
    width: 100%;
    cursor: pointer;
}
.person.selected { border-color: var(--accent); }
.master-detail.card-wide {
    width: auto;
    margin: 0;
}
.badge-preview {
    display: block;
    max-width: 280px;
    background: #fff;
    border-radius: 8px;
    margin: 12px 0;
}
.profile-layout {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 20px;
    align-items: start;
    margin: 12px 0 20px;
}
.profile-card {
    background: #fff;
    color: #111;
    border-radius: 16px;
    padding: 16px;
}
.profile-dl {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px 16px;
    margin: 0;
}
.profile-dl dt { color: var(--muted); }
.profile-dl dd { margin: 0; }
#worker-select {
    width: 100%;
    max-width: 420px;
    margin: 8px 0 16px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #0b1220;
    color: var(--text);
    font-size: 16px;
}
a.btn.ghost { display: inline-block; text-decoration: none; text-align: center; }
@media (max-width: 800px) {
    .master-split { grid-template-columns: 1fr; }
}
