:root {
    --bg: #0D1117;
    --card: #161B26;
    --line: #2A3344;
    --text: #F8FAFC;
    --muted: #8B9BB4;
    --accent: #58A6FF;
    --ok: #22C55E;
    --err: #f87171;
    --ts-work: #1E3A2B;
    --ts-vac: #D29922;
    --ts-sick: #1E2D4A;
}

* { 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;
    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%); max-height: 90vh; overflow-y: auto; }
#btn-save-password, #btn-new-badge { margin-top: 12px; }
.ts-page { background: #10141E; margin: -16px; padding: 16px 16px 24px; min-height: 100%; }
.ts-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.ts-head h2 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: 0.01em; }
.ts-nav {
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #161B26;
    color: var(--text);
    font-size: 22px;
}
.ts-stats {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
    white-space: normal;
}
.ts-range-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 12px;
}
.ts-range-hint { flex: 1; margin: 0; color: var(--muted); font-size: 12px; }
.ts-range-button {
    flex: none;
    border: 1px solid var(--accent);
    border-radius: 999px;
    padding: 7px 10px;
    background: #0c4a6e;
    color: #e0f2fe;
    font-size: 12px;
}
.ts-cal { display: flex; flex-direction: column; gap: 8px; }
.ts-weekdays,
.ts-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}
.ts-weekdays {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    font-weight: 600;
}
.ts-weekdays .wknd { color: #6E7C91; }
.ts-cell {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 100%;
    height: 64px;
    min-height: 60px;
    margin: 0;
    border: 0;
    border-radius: 8px;
    background: #161B26;
    color: var(--text);
    padding: 4px 5px 6px;
    display: grid !important;
    grid-template-rows: 16px 1fr;
    grid-template-columns: 1fr;
    align-items: stretch;
    justify-items: stretch;
    gap: 0;
    font: inherit;
    white-space: normal;
    overflow: hidden;
}
.ts-cell .ts-num,
.ts-cell .ts-val,
.ts-cell .ts-badge,
.ts-cell .ts-mini {
    display: block !important;
    float: none !important;
    white-space: nowrap;
}
.ts-cell .ts-num {
    grid-row: 1;
    grid-column: 1;
    justify-self: start;
    align-self: start;
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    color: #C9D1D9;
    text-align: left;
}
.ts-cell .ts-mini {
    position: absolute;
    top: 4px;
    left: 16px;
    font-size: 9px;
    font-weight: 700;
    color: #93C5FD;
    line-height: 12px;
}
.ts-cell .ts-val {
    grid-row: 2;
    grid-column: 1;
    align-self: end;
    justify-self: center;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.1;
    text-align: center;
    color: #FFFFFF;
}
.ts-cell .ts-badge {
    grid-row: 2;
    grid-column: 1;
    align-self: end;
    justify-self: center;
    width: auto;
    font-size: 11px;
    font-weight: 800;
    background: #1E3A2B;
    color: #FFFFFF;
    border-radius: 999px;
    padding: 2px 7px;
    line-height: 1.2;
}
.ts-cell.empty {
    background: transparent;
    min-height: 60px;
    height: 64px;
    pointer-events: none;
}
.ts-cell.outside {
    background: #12161F;
    color: #4B5563;
}
.ts-cell.outside .ts-num { color: #4B5563; }
.ts-cell.work { background: #1E3A2B; box-shadow: inset 0 0 0 1px #3FB950; }
.ts-cell.work .ts-num { color: #9EE6B0; }
.ts-cell.work .ts-val { color: #FFFFFF; font-size: 16px; }
.ts-cell.vac { background: #D29922; }
.ts-cell.vac .ts-num,
.ts-cell.vac .ts-val { color: #1C1500; }
.ts-cell.sick { background: #1E2D4A; }
.ts-cell.sick .ts-val { color: #DBEAFE; }
.ts-cell.trip { background: #2A3344; }
.ts-cell.absence { background: #3F1515; }
.ts-cell.absence .ts-val { color: #FECACA; }
.ts-cell.weekend:not(.work):not(.vac):not(.sick):not(.trip):not(.absence):not(.outside) {
    background: #121826;
}
.ts-cell.selected { outline: 2px solid #58A6FF; outline-offset: 1px; }
.ts-cell.in-range { box-shadow: inset 0 0 0 2px #58A6FF; }
.ts-sheet {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.72);
    display: flex;
    align-items: flex-end;
    z-index: 30;
}
.ts-sheet-card {
    width: 100%;
    background: #161B26;
    border-top: 1px solid var(--line);
    border-radius: 24px 24px 0 0;
    padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
}
.ts-sheet-handle {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: #4B5563;
    margin: 4px auto 12px;
}
.ts-sheet-card h3 { margin: 0 0 4px; font-size: 18px; }
.ts-sheet-scope { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.ts-status-row, .ts-hours-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 12px 0;
}
.ts-status, .ts-hour {
    min-height: 64px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #0D1117;
    color: var(--text);
    font-size: 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 4px;
}
.ts-status-cap { line-height: 1.15; text-align: center; }
.ts-ico { font-size: 16px; line-height: 1; }
.ts-status.work { border-color: #22c55e; color: #86efac; }
.ts-status.vac { border-color: #D29922; color: #FDE68A; }
.ts-status.sick { border-color: #60A5FA; color: #93C5FD; }
.ts-status.trip { border-color: #94a3b8; color: #CBD5E1; }
.ts-status.work.active { background: #1E3A2B; }
.ts-status.vac.active { background: #3A321E; }
.ts-status.sick.active { background: #1E2D4A; }
.ts-status.trip.active { background: #2A3344; }
.ts-hour.active { border-color: var(--accent); background: #0c4a6e; }
#ts-hours-other { margin: 0; font-size: 13px; padding: 8px; }
.ts-fill {
    margin-top: 4px;
    background: #0D1117;
    border: 1px solid #7C3AED;
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.35);
}
.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: #0D1117;
    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; }
.cabinet-app {
    min-height: 100vh;
    min-height: 100dvh;
    background: #0f172a;
}
.cabinet-app .content {
    padding: 16px 16px 20px;
}
#cabinet-header, #cabinet-nav { flex-shrink: 0; }
.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%; }
.area-map {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 13px;
}
.area-map ul { margin: 8px 0 0; padding-left: 18px; }
.area-map li { margin: 4px 0; }
.period-btn { width: auto; background: transparent; border: 1px solid var(--line); color: var(--text); }
.period-btn.active { border-color: var(--accent); background: rgba(37, 99, 235, 0.15); }
.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; }
}
