:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --text: #1d2420;
  --muted: #6b746f;
  --line: #dfe3e0;
  --accent: #1f6f4a;
  --accent-soft: #e3f1ea;
  --danger: #b3261e;
  --weekend: #f1f2f0;
  --today: #fff8e1;
  --m-green: #d9ead3;
  --m-yellow: #fff2cc;
  --m-red: #f4cccc;
  --m-blue: #cfe2f3;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1c211e;
    --text: #e6ebe8;
    --muted: #97a19b;
    --line: #2e3631;
    --accent: #4cc38a;
    --accent-soft: #1d3a2b;
    --danger: #ff8a80;
    --weekend: #191d1b;
    --today: #3a3420;
    --m-green: #2f4a32;
    --m-yellow: #4d4422;
    --m-red: #4f2a2a;
    --m-blue: #233a52;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 22px; margin: 8px 0 14px; }
h3 { font-size: 16px; margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, monospace; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pad { padding: 16px; }
.center { max-width: 420px; margin: 20vh auto; padding: 0 16px; text-align: center; }
.center-text { text-align: center; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 10px; }
.error-box { margin: 16px; padding: 12px; border-radius: var(--radius); background: var(--m-red); }

.top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }

.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { padding: 7px 10px; }
.btn.big { width: 100%; padding: 16px; font-size: 18px; font-weight: 600; border-radius: 12px; margin-top: 18px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }
.link.danger { color: var(--danger); }

.input { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.input:focus, .cell-input:focus, .task-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.input.big { width: 100%; padding: 12px 14px; font-size: 17px; margin-bottom: 12px; }
.input.inline { width: 100%; max-width: 280px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.field .input { color: var(--text); font-size: 15px; }
.check { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; cursor: pointer; }

.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row > .input { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: 8px 14px; cursor: pointer; position: relative;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-left: 6px; vertical-align: middle; opacity: .7; }
.swatch::before, .swatch-box { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.15); }
.swatch-box { width: 22px; height: 22px; margin: 0; flex: none; }
.s-green::before, .swatch-box.s-green { background: var(--m-green); }
.s-yellow::before, .swatch-box.s-yellow { background: var(--m-yellow); }
.s-red::before, .swatch-box.s-red { background: var(--m-red); }
.s-blue::before, .swatch-box.s-blue { background: var(--m-blue); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1d2420; color: #fff; padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 50; max-width: calc(100% - 32px);
}
.toast.error { background: var(--danger); }

/* ---------- працівник ---------- */
.worker { max-width: 480px; margin: 0 auto; padding-bottom: 40px; }
.worker > *:not(.top) { margin-left: 16px; margin-right: 16px; }
.worker .top { justify-content: center; margin-bottom: 8px; }
.pick-list { display: grid; gap: 8px; }
.pick { text-align: left; padding: 16px; font-size: 17px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.pick:active { background: var(--accent-soft); }
.who { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 8px; }
.who-name { font-size: 19px; font-weight: 600; }
.label { font-weight: 600; margin: 20px 0 8px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.step { width: 64px; height: 64px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 30px; cursor: pointer; }
.hours-big { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hours-big .unit { font-size: 16px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.quick .chip { padding: 12px 0; font-size: 16px; }
.month { margin-top: 24px; }
.my-list { margin-top: 8px; }
.my-row { display: flex; justify-content: space-between; padding: 7px 0; border-top: 1px solid var(--line); }

/* ---------- адмін ---------- */
.admin-top { position: sticky; top: 0; z-index: 5; }
.tabs { display: flex; gap: 2px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 8px; position: sticky; top: 49px; z-index: 5; }
.tab { border: 0; background: none; padding: 10px 12px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; color: var(--muted); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.admin-body { padding: 14px 16px 40px; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-title { min-width: 130px; text-align: center; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
thead th { font-weight: 600; font-size: 13px; color: var(--muted); background: var(--surface); }
tr.inactive td, th.inactive { color: var(--muted); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: 4px; }
.list.small td, .list.small th { font-size: 13px; }
code.details { font-size: 12px; word-break: break-all; color: var(--muted); }

.grid th.name { position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 170px; max-width: 220px; border-right: 1px solid var(--line); font-weight: 500; color: var(--text); }
.grid thead th.name { z-index: 3; color: var(--muted); }
.tabel th.day { text-align: center; padding: 4px 0; min-width: 40px; }
.tabel th.day .wd { font-weight: 400; font-size: 11px; }
.tabel td.cell { padding: 0; border-left: 1px solid var(--line); min-width: 40px; }
.cell-input { width: 100%; min-width: 40px; height: 34px; border: 0; background: transparent; text-align: center; font-variant-numeric: tabular-nums; padding: 0; }
.cell-input[readonly] { cursor: pointer; }
.weekend { background: var(--weekend); }
th.today { box-shadow: inset 0 -3px 0 var(--accent); color: var(--text); }
td.today:not([class*="m-"]) { background-color: var(--today); }
td.m-green { background: var(--m-green); }
td.m-yellow { background: var(--m-yellow); }
td.m-red { background: var(--m-red); }
td.m-blue { background: var(--m-blue); }
.tabel td.cell { position: relative; }
.tabel td.cell[title]:not([title=""]) { background-image: linear-gradient(225deg, var(--accent) 5px, transparent 5px); }
.tabel tfoot td { border-bottom: 0; font-weight: 600; }
td.total { white-space: nowrap; text-align: right; }

.objects th, .objects td.task-cell { min-width: 240px; }
.objects th .link { font-weight: 400; display: block; margin-top: 2px; }
.task-cell { padding: 3px; border-left: 1px solid var(--line); position: relative; }
.task-cell.missing { background: var(--m-red); }
.task-input { width: 100%; border: 1px solid transparent; border-radius: 6px; background: transparent; padding: 6px; padding-right: 48px; min-height: 34px; }
.task-input:hover { border-color: var(--line); }
.hrs { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--muted); pointer-events: none; }

.sync-status { padding: 8px 10px; border-radius: 8px; background: var(--bg); font-size: 13px; margin: 6px 0 12px; }
.sync-status.ok { background: var(--accent-soft); }
.sync-status.bad { background: var(--m-red); }

.dialog { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: var(--surface); color: var(--text); width: min(420px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,.35); }
.dialog select { width: 100%; }

@media (max-width: 600px) {
  .admin-body { padding: 10px 8px 40px; }
  .grid th.name { min-width: 120px; max-width: 140px; font-size: 13px; }
  .month-title { min-width: 110px; }
}
.worker > .input.big, .worker > .btn.big { width: calc(100% - 32px); }
