/* Бригадо — терракота + бетон.
   Правила: области нажатия ≥ 48px (главные ≥ 64px), высокий контраст для солнца,
   статус = цвет + значок + слово. */
:root {
  --bg: #F1EFEC;          /* бетон светлый */
  --surface: #FFFFFF;
  --surface-2: #F7F5F2;
  --line: #E0DCD7;
  --line-2: #D3CEC8;
  --text: #1F1D1B;
  --text-2: #4A4642;
  --muted: #6E6862;
  --concrete: #8D8780;

  --accent: #B4532A;      /* терракота: белый текст ≈ 4.9:1 */
  --accent-press: #9A4422;
  --accent-ink: #7A3417;
  --accent-soft: #F6E4DA;
  --accent-soft-2: #FBF1EB;
  --on-accent: #FFFFFF;

  --ok: #2E7D4F;   --ok-bg: #E2F1E7;
  --bad: #B3261E;  --bad-bg: #FBE4E2;
  --warn: #9A5B00; --warn-bg: #FCEFD6;
  --none: #5F5A55; --none-bg: #ECE9E5;

  --hero-1: #B4532A;
  --hero-2: #D9824F;
  --hero-3: #EDB58C;

  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161412; --surface: #211E1B; --surface-2: #1B1917;
  --line: #312C28; --line-2: #3B3631;
  --text: #F2EEEA; --text-2: #CFC8C1; --muted: #A39B93; --concrete: #8A827A;
  --accent: #D06A3E; --accent-press: #B85A31; --accent-ink: #F6C3A6;
  --accent-soft: #3A2419; --accent-soft-2: #2A1C15;
  --ok: #7FD3A0; --ok-bg: #173323; --bad: #FF9C93; --bad-bg: #3C1715;
  --warn: #F4C06A; --warn-bg: #3A2A0F; --none: #BDB5AD; --none-bg: #2C2825;
  --hero-1: #8E3D1C; --hero-2: #A85328; --hero-3: #6E3A22;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea { font-size: 17px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.view { padding: calc(var(--safe-top) + 16px) 18px calc(var(--safe-bottom) + 112px);
  display: flex; flex-direction: column; gap: 16px; max-width: 560px; margin: 0 auto; min-height: 100vh; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
.head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.3px; }
.head .sub { font-size: 14px; color: var(--muted); }
.label { font-size: 14px; color: var(--muted); }
.section-t { font-size: 18px; font-weight: 700; margin: 6px 2px -4px; display: flex; justify-content: space-between; align-items: baseline; }
.section-t small { font-size: 14px; font-weight: 500; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }

.icon-btn { width: 48px; height: 48px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; flex: none; position: relative; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn .badge { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }

/* buttons */
.btn { height: 56px; border-radius: 18px; border: none; font-size: 17px; font-weight: 700; padding: 0 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--line-2); }
.btn-ghost { background: transparent; color: var(--accent); height: 48px; }
.btn:disabled { opacity: .5; }

/* status chips: цвет + значок + слово */
.st { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px 0 9px; border-radius: 999px;
  font-size: 14px; font-weight: 700; white-space: nowrap; }
.st svg { width: 16px; height: 16px; }
.st.ok { background: var(--ok-bg); color: var(--ok); }
.st.bad { background: var(--bad-bg); color: var(--bad); }
.st.warn { background: var(--warn-bg); color: var(--warn); }
.st.none { background: var(--none-bg); color: var(--none); }

/* sync line */
.sync { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.sync i { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.sync.wait i { background: var(--warn); }
.sync.off i { background: var(--bad); }

/* ---------- worker: today ---------- */
.site-card { display: flex; flex-direction: column; gap: 14px; }
.site-top { display: flex; gap: 14px; align-items: flex-start; }
.site-ic { width: 52px; height: 52px; border-radius: 16px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: none; }
.site-name { font-size: 20px; font-weight: 700; line-height: 1.2; }
.site-addr { font-size: 15px; color: var(--text-2); margin-top: 3px; }
.site-time { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 15px; color: var(--text-2); font-weight: 600; }
.tag svg { width: 17px; height: 17px; color: var(--concrete); }
.site-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.site-actions .btn { height: 52px; font-size: 16px; }

.shift-btn { width: 100%; min-height: 96px; border: none; border-radius: 26px; background: var(--accent); color: #fff;
  display: flex; align-items: center; gap: 16px; padding: 18px 22px; text-align: left;
  box-shadow: 0 10px 24px rgba(180,83,42,.28); }
.shift-btn:active { background: var(--accent-press); transform: scale(.99); }
.shift-btn .big { font-size: 23px; font-weight: 800; letter-spacing: -0.2px; }
.shift-btn .small { font-size: 15px; opacity: .92; margin-top: 2px; }
.shift-btn .circ { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; flex: none; }
.shift-btn.stop { background: var(--text); box-shadow: 0 10px 24px rgba(0,0,0,.2); }
:root[data-theme="dark"] .shift-btn.stop { background: #3A3531; }
.shift-btn.busy { opacity: .85; pointer-events: none; }

.shift-state { display: flex; flex-direction: column; gap: 12px; }
.timer { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.marks { display: flex; flex-direction: column; }
.mark { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.mark:last-child { border-bottom: none; }
.mark .t { font-weight: 700; width: 54px; flex: none; }
.mark .w { flex: 1; min-width: 0; font-size: 15px; color: var(--text-2); }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.q { border: 1px solid var(--line); background: var(--surface); border-radius: 20px; min-height: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 600; padding: 10px 6px; text-align: center; }
.q .qi { width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.q:active { background: var(--surface-2); }
.q .soon { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ---------- foreman: hero ---------- */
.hero { border-radius: 28px; padding: 20px; color: #fff;
  background: linear-gradient(155deg, var(--hero-1) 0%, var(--hero-2) 58%, var(--hero-3) 100%);
  display: flex; flex-direction: column; gap: 16px; box-shadow: 0 12px 28px rgba(180,83,42,.25); }
.hero .h-top { display: flex; justify-content: space-between; align-items: center; }
.hero .h-date { font-size: 15px; font-weight: 600; opacity: .95; }
.hero .h-big { font-size: 46px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.hero .h-cap { font-size: 16px; font-weight: 600; opacity: .95; margin-top: 4px; }
.hero .h-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hero .h-cell { background: rgba(255,255,255,.94); color: var(--text); border-radius: 18px; padding: 12px; border: none; text-align: left; }
.hero .h-cell b { display: block; font-size: 24px; font-weight: 800; }
.hero .h-cell span { font-size: 12.5px; white-space: nowrap; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 5px; }
.hero .h-cell i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
:root[data-theme="dark"] .hero .h-cell { background: rgba(20,17,15,.55); color: #fff; }
:root[data-theme="dark"] .hero .h-cell span { color: #EADFD6; }

.seg { display: flex; background: var(--line); border-radius: 16px; padding: 4px; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1; height: 42px; border: none; border-radius: 12px; background: transparent; font-size: 15px; font-weight: 600; color: var(--text-2); white-space: nowrap; padding: 0 12px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 72px;
  border: none; border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; }
.item:last-child { border-bottom: none; }
.item:active { background: var(--surface-2); }
.ava { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; flex: none; }
.item .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .n { font-weight: 700; font-size: 16px; }
.item .s { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--concrete); flex: none; }

.obj { display: flex; flex-direction: column; gap: 12px; }
.obj-top { display: flex; gap: 12px; align-items: center; }
.obj-people { display: flex; align-items: center; }
.obj-people .ava { width: 34px; height: 34px; font-size: 13px; border: 2px solid var(--surface); margin-left: -8px; }
.obj-people .ava:first-child { margin-left: 0; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; display: flex; }
.bar > div { height: 100%; }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; font-size: 15px; }

/* tabbar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 8px 6px calc(var(--safe-bottom) + 8px); }
.tab { border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); padding: 2px 0; min-height: 56px; }
.tab .pb { width: 60px; height: 34px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.tab.on { color: var(--text); }
.tab.on .pb { background: var(--accent-soft); color: var(--accent); }
.tab.on svg { stroke-width: 2.4; }

/* sheet */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(25,20,16,.42); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet .panel { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(var(--safe-bottom) + 24px); display: flex; flex-direction: column; gap: 16px; animation: up .2s ease-out; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); align-self: center; }
.panel h2 { margin: 4px 0 0; font-size: 21px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea { min-height: 52px; border-radius: 16px; border: 1.5px solid var(--line-2); padding: 0 14px;
  background: var(--surface); color: var(--text); outline: none; width: 100%; font-weight: 500; }
.field textarea { padding: 14px; min-height: 96px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { min-height: 56px; border-radius: 16px; border: 1.5px solid var(--line-2); background: var(--surface); text-align: left; padding: 12px 16px; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 12px; }
.opt.on { border-color: var(--accent); background: var(--accent-soft-2); }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* toast */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 100px); z-index: 60; max-width: 528px; margin: 0 auto;
  background: #2A2522; color: #fff; border-radius: 16px; padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  font-size: 15px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: up .2s ease-out; }
.toast svg { flex: none; color: #9FE0B8; }

/* demo switch */
.demo { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.demo button { height: 36px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 10px; font-size: 13px; font-weight: 600; }
.demo button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
