@font-face { font-family: Inter; font-weight: 400 700; font-display: swap; src: url(/static/fonts/inter-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Inter; font-weight: 400 700; font-display: swap; src: url(/static/fonts/inter-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Inter; font-weight: 400 700; font-display: swap; src: url(/static/fonts/inter-cyr.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Inter; font-weight: 400 700; font-display: swap; src: url(/static/fonts/inter-cyr-ext.woff2) format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: Michroma; font-display: swap; src: url(/static/fonts/michroma.woff2) format("woff2"); }

:root {
  --bg: #0A0A0B; --surface: #121214; --surface-2: #1A1A1D; --surface-3: #222226;
  --line: #24242A; --line-2: #34343C;
  --text: #F4F4F5; --muted: #8B8B94; --faint: #5A5A63;
  --red: #E3122C; --red-hi: #FF2D46; --red-soft: rgba(227, 18, 44, .14);
  --silver: #C9CCD1; --amber: #F5A524; --amber-soft: rgba(245, 165, 36, .14);
  --green: #22C55E; --green-soft: rgba(34, 197, 94, .14);
  --weekend: rgba(255, 255, 255, .025); --holiday: rgba(227, 18, 44, .06);
  --shadow: 0 12px 40px rgba(0, 0, 0, .5);
  --r: 10px; --r-sm: 7px;
  --tab-h: 62px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F5F5F6; --surface: #FFFFFF; --surface-2: #F1F1F3; --surface-3: #E8E8EB;
  --line: #E4E4E8; --line-2: #D4D4DA;
  --text: #0B0B0C; --muted: #6B6B74; --faint: #A0A0A8;
  --red: #D10F27; --red-hi: #E3122C; --red-soft: rgba(209, 15, 39, .09);
  --silver: #5E6168; --amber: #C77800; --amber-soft: rgba(199, 120, 0, .1);
  --green: #16A34A; --green-soft: rgba(22, 163, 74, .1);
  --weekend: rgba(0, 0, 0, .025); --holiday: rgba(209, 15, 39, .05);
  --shadow: 0 12px 40px rgba(0, 0, 0, .14);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.45 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; height: 100dvh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 14px; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand img { width: 30px; height: 30px; }
.wordmark { font-family: Michroma, Inter, sans-serif; font-size: 13px; letter-spacing: .04em; line-height: 1; white-space: nowrap; }
.wordmark span { font-family: Inter; font-size: .52em; letter-spacing: .5em; margin-left: .9em; font-weight: 500; color: var(--silver); vertical-align: .18em; }
.wordmark small { display: block; font-family: Inter; font-size: 8.5px; letter-spacing: .28em; color: var(--muted); margin-top: 6px; font-weight: 500; }
.wordmark small i { font-style: normal; color: var(--red); margin: 0 .5em; }
.nav-btn { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; background: none; border-radius: var(--r-sm);
  color: var(--muted); cursor: pointer; text-align: left; font-weight: 500; }
.nav-btn svg { width: 19px; height: 19px; flex: none; }
.nav-btn:hover { color: var(--text); background: var(--surface-2); }
.nav-btn.on { color: var(--text); background: var(--surface-2); box-shadow: inset 2px 0 0 var(--red); }
.nav-btn .count { margin-left: auto; font-size: 11px; background: var(--red); color: #fff; border-radius: 10px; padding: 1px 7px; }
.side .spacer { flex: 1; }
.main { min-width: 0; display: flex; flex-direction: column; height: 100dvh; }
.topbar { display: none; }
.tabbar { display: none; }

.page-head { display: flex; align-items: center; gap: 10px; padding: 18px 24px 14px; flex-wrap: wrap; }
.page-title { font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-right: auto; }
.page-title strong { display: block; font-size: 20px; letter-spacing: 0; text-transform: none; color: var(--text); margin-top: 2px; }
.content { flex: 1; min-height: 0; overflow: auto; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface-2); cursor: pointer; font-weight: 500; white-space: nowrap; user-select: none; }
.btn:hover { border-color: var(--faint); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-hi); border-color: var(--red-hi); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { color: var(--red); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 44px; }
.icon-btn { width: 36px; padding: 0; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; }
.seg button { border: 0; background: none; padding: 0 12px; height: 30px; border-radius: 5px; color: var(--muted); cursor: pointer; font-weight: 500; font-size: 13px; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
.input, select.input, textarea.input { width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface-2); outline: none; }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
input[type=date].input { min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: none; border-radius: 99px; padding: 5px 12px; cursor: pointer; color: var(--muted); font-size: 13px; }
.chip.on { border-color: var(--red); color: var(--text); background: var(--red-soft); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap;
  background: var(--surface-3); color: var(--muted); }
.pill.planned { background: var(--surface-3); color: var(--silver); }
.pill.active { background: var(--red-soft); color: var(--red-hi); }
.pill.done { background: var(--amber-soft); color: var(--amber); }
.pill.invoiced { background: var(--surface-3); color: var(--text); }
.pill.paid { background: var(--green-soft); color: var(--green); }
.pill.overdue { background: var(--red); color: #fff; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---------- alerts ---------- */
.alerts { display: flex; flex-direction: column; gap: 8px; padding: 0 24px 12px; }
.alert { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; flex-wrap: wrap; }
.alert .mark { width: 3px; align-self: stretch; border-radius: 2px; background: var(--amber); flex: none; }
.alert.red .mark { background: var(--red); }
.alert .txt { flex: 1; min-width: 180px; }
.alert .txt b { cursor: pointer; }

/* ---------- plan / timeline ---------- */
.plan-tools { display: flex; align-items: center; gap: 8px; }
.tl-wrap { flex: 1; min-height: 0; overflow: auto; position: relative; border-top: 1px solid var(--line); overscroll-behavior: contain; }
.tl { position: relative; }
.tl-head { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; border-bottom: 1px solid var(--line); }
.tl.tight .tl-day b { font-size: 10.5px; letter-spacing: -.04em; }
.tl-corner { position: sticky; left: 0; z-index: 6; background: var(--bg); flex: none; border-right: 1px solid var(--line); }
.tl-months { position: relative; height: 24px; }
.tl-month span { position: sticky; left: var(--lw); }
.tl-month { position: absolute; top: 0; height: 24px; padding: 5px 8px; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
  font-weight: 600; border-left: 1px solid var(--line); white-space: nowrap; }
.tl-days { position: relative; height: 34px; }
.tl-day { position: absolute; top: 0; height: 34px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px;
  color: var(--muted); line-height: 1.15; border-left: 1px solid transparent; overflow: hidden; }
.tl-day b { font-size: 12px; letter-spacing: -.02em; color: var(--text); font-weight: 600; }
.tl-day.we b, .tl-day.hol b { color: var(--faint); }
.tl-day.hol::after { content: ""; position: absolute; top: 3px; right: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--red); }
.tl-day.today b { background: var(--red); color: #fff; border-radius: 5px; padding: 0 5px; }
.tl-day.monday { border-left-color: var(--line); }
.tl-body { position: relative; }
.tl-cols { position: absolute; inset: 0; pointer-events: none; }
.tl-col { position: absolute; top: 0; bottom: 0; }
.tl-col.we { background: var(--weekend); }
.tl-col.hol { background: var(--holiday); }
.tl-col.monday { border-left: 1px solid var(--line); }
.tl-today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); opacity: .8; pointer-events: none; z-index: 2; }
.tl-row { position: relative; display: flex; border-bottom: 1px solid var(--line); }
.tl-label { position: sticky; left: 0; z-index: 4; background: var(--bg); flex: none; border-right: 1px solid var(--line); display: flex; align-items: center;
  gap: 9px; padding: 0 12px; cursor: pointer; font-weight: 600; min-width: 0; }
.tl-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-label:hover { background: var(--surface); }
.tl-lane { position: relative; flex: none; cursor: cell; }
.tl-add-row { position: sticky; left: 0; display: inline-flex; margin: 10px 12px 24px; }
.absence { position: absolute; top: 3px; bottom: 3px; border-radius: 6px; z-index: 1;
  background: repeating-linear-gradient(135deg, var(--surface-3) 0 6px, transparent 6px 12px); border: 1px dashed var(--line-2);
  font-size: 11px; color: var(--muted); padding: 4px 7px; overflow: hidden; white-space: nowrap; pointer-events: none; }
.bar { position: absolute; height: 40px; border-radius: 7px; z-index: 3; padding: 4px 8px 4px 10px; overflow: hidden; cursor: pointer; user-select: none;
  background: var(--surface-2); border: 1px solid var(--line-2); display: flex; flex-direction: column; justify-content: center; touch-action: pan-x pan-y; -webkit-touch-callout: none; }
.bar::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--crew, var(--silver)); }
.bar .t { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .s { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar.active { background: linear-gradient(180deg, var(--red-hi), var(--red)); border-color: var(--red); color: #fff; }
.bar.active .s { color: rgba(255, 255, 255, .8); }
.bar.active::before { background: rgba(255, 255, 255, .5); }
.bar.done { background: var(--amber-soft); border-color: var(--amber); }
.bar.invoiced, .bar.paid { opacity: .55; }
.bar.conflict { outline: 2px dashed var(--red-hi); outline-offset: 1px; }
.bar.dragging { pointer-events: none; opacity: .85; box-shadow: var(--shadow); z-index: 10; cursor: grabbing; }
.bar .grip { position: absolute; right: 0; top: 0; bottom: 0; width: 9px; cursor: ew-resize; }
.bar .grip.l { left: 0; right: auto; }
.bar.narrow { padding: 4px 3px 4px 6px; }
.selbox { position: absolute; top: 4px; bottom: 4px; border-radius: 7px; background: var(--red-soft); border: 1px dashed var(--red); z-index: 2; pointer-events: none; }
.tl-hint { font-size: 12px; color: var(--faint); padding: 0 24px 8px; }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 12px; padding: 4px 24px 24px; align-items: start; }
.col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-height: 120px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.col-head .n { margin-left: auto; letter-spacing: 0; color: var(--text); }
.col-body { display: flex; flex-direction: column; gap: 8px; padding: 0 10px 12px; }
.card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.card:hover { border-color: var(--line-2); }
.card .top { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.card .top .num { font-variant-numeric: tabular-nums; }
.card .name { font-weight: 600; }
.card .addr { font-size: 12.5px; color: var(--muted); }
.card .foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
.card .foot .btn { margin-left: auto; }

/* ---------- lists (archive, customers) ---------- */
.toolbar { display: flex; gap: 8px; padding: 0 24px 12px; flex-wrap: wrap; align-items: center; }
.search { flex: 1; min-width: 220px; position: relative; }
.search svg { position: absolute; left: 11px; top: 11px; width: 18px; height: 18px; color: var(--muted); }
.search .input { padding-left: 36px; }
.toolbar select.input { width: auto; min-width: 120px; }
.totals { display: flex; gap: 28px; padding: 4px 24px 14px; flex-wrap: wrap; }
.totals div { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.totals b { text-transform: none; display: block; font-size: 20px; color: var(--text); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.list { padding: 0 24px 24px; }
.li { display: grid; grid-template-columns: 110px 1fr auto auto; gap: 14px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.li:hover { background: var(--surface); }
.li .d { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.li .m { min-width: 0; }
.li .m b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .m span { font-size: 12.5px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .amt { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.li.cust { grid-template-columns: 1fr auto auto; }

/* ---------- settings ---------- */
.settings { padding: 0 24px 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.panel h3 { margin: 0; font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.panel .kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.panel .kv:last-child { border: 0; }
.crew-edit { display: flex; gap: 8px; align-items: center; }
.crew-edit input[type=color] { width: 36px; height: 36px; border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 3px; background: var(--surface-2); cursor: pointer; }

/* ---------- sheet (job card) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 50; animation: fade .15s; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--line); z-index: 51;
  display: flex; flex-direction: column; box-shadow: var(--shadow); animation: slide .2s ease-out; }
.sheet.wide { width: min(780px, 100vw); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
a.btn { text-decoration: none; }
.sheet.small { top: 50%; left: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px)); border: 1px solid var(--line);
  border-radius: var(--r); animation: fade .15s; max-height: calc(100dvh - 40px); }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.sheet-head .ttl { flex: 1; min-width: 0; }
.sheet-head .ttl small { display: block; font-size: 11px; color: var(--muted); letter-spacing: .14em; font-variant-numeric: tabular-nums; }
.sheet-head .ttl b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { flex: 1; overflow: auto; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 18px; }
.sheet-foot { padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.saved { font-size: 12px; color: var(--muted); margin-right: auto; }
.next-step { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.next-step .txt { flex: 1; font-size: 13px; color: var(--muted); }
.next-step .txt b { color: var(--text); display: block; font-size: 14px; }
.crew-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.crew-pick button { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-2); background: var(--surface-2); border-radius: var(--r-sm);
  height: 36px; padding: 0 12px; cursor: pointer; color: var(--muted); font-weight: 500; }
.crew-pick button.on { color: var(--text); border-color: var(--text); }
.maplink { font-size: 13px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; text-decoration: none; }
.maplink:hover { color: var(--text); }
.maplink svg { width: 15px; height: 15px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--surface-3); cursor: pointer; border: 0; padding: 0; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .tag { position: absolute; left: 4px; bottom: 4px; font-size: 10px; font-weight: 700; background: rgba(0, 0, 0, .7); color: #fff; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: .06em; }
.photo-add { aspect-ratio: 1; border-radius: 6px; border: 1px dashed var(--line-2); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--muted); cursor: pointer; font-size: 12px; }
.photo-add svg { width: 22px; height: 22px; }
.photo-add:hover { color: var(--text); border-color: var(--faint); }
.section-t { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: -6px; display: flex; align-items: center; gap: 8px; }
.history { display: flex; flex-direction: column; font-size: 12.5px; }
.history div { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.history time { color: var(--muted); font-variant-numeric: tabular-nums; }
.history em { color: var(--faint); font-style: normal; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: 44px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); z-index: 5;
  max-height: 260px; overflow: auto; box-shadow: var(--shadow); }
.combo-list button { display: flex; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; cursor: pointer; gap: 8px; align-items: center; }
.combo-list button:hover, .combo-list button.hl { background: var(--surface-3); }
.combo-list .new { color: var(--red-hi); font-weight: 600; border-top: 1px solid var(--line); }

/* ---------- menu, lightbox, toast ---------- */
.menu { position: fixed; z-index: 60; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow); padding: 5px;
  min-width: 210px; animation: fade .1s; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--red-hi); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .lbl { padding: 6px 12px 4px; font-size: 11px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .94); display: flex; flex-direction: column; }
.lightbox img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.lightbox .bar2 { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); justify-content: center; flex-wrap: wrap; }
.lightbox .bar2 .btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .15); color: #fff; }
.lightbox .bar2 .btn.on { background: var(--red); border-color: var(--red); }
#toast-root { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: var(--bg); border-radius: 99px; padding: 9px 10px 9px 18px; display: flex; gap: 14px; align-items: center; font-weight: 500;
  box-shadow: var(--shadow); animation: up .2s ease-out; white-space: nowrap; }
.toast button { border: 0; background: none; color: var(--red); font-weight: 700; cursor: pointer; padding: 4px 8px; }
.offline { background: var(--amber); color: #000; text-align: center; font-size: 12.5px; font-weight: 600; padding: 5px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, rgba(227, 18, 44, .12), transparent 60%), var(--bg); }
.login form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.login img { width: 86px; align-self: center; margin-bottom: 4px; }
.login .wordmark { font-size: 30px; text-align: center; margin-bottom: 22px; }
.login .wordmark small { font-size: 10px; margin-top: 16px; letter-spacing: .3em; }
.login .wordmark span { display: block; margin: 12px 0 0 .5em; font-size: .4em; letter-spacing: .62em; }
.side .wordmark small { letter-spacing: .2em; }
.login .tag { text-align: center; color: var(--muted); font-size: 10px; letter-spacing: .36em; margin: 2px 0 18px; }
.login .err { color: var(--red-hi); font-size: 13px; text-align: center; min-height: 18px; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes up { from { transform: translateY(12px); opacity: 0; } }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  .shell { display: block; }
  .side { display: none; }
  .main { height: 100dvh; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
  .topbar img { width: 26px; height: 26px; }
  .topbar .wordmark { font-size: 13px; margin-right: auto; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .tabbar button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: .04em; cursor: pointer; position: relative; }
  .tabbar button svg { width: 22px; height: 22px; }
  .tabbar button.on { color: var(--text); }
  .tabbar button.on::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--red); border-radius: 2px; }
  .tabbar .count { position: absolute; top: 7px; left: calc(50% + 6px); font-size: 10px; background: var(--red); color: #fff; border-radius: 9px; padding: 0 5px; }
  .page-head { padding: 14px 16px 10px; }
  .page-title strong { font-size: 18px; }
  .alerts, .toolbar, .totals, .list, .settings { padding-left: 16px; padding-right: 16px; }
  .tl-hint { padding: 0 16px 6px; }
  .tl-label { padding: 0 8px; gap: 6px; font-size: 12px; line-height: 1.2; box-shadow: inset 3px 0 0 var(--crew-c); }
  .tl-label .dot { display: none; }
  .tl-label span:last-child { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .board { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 16px 16px; gap: 10px; }
  .board .col { flex: 0 0 84%; scroll-snap-align: center; }
  .li { grid-template-columns: 1fr auto; padding: 12px 4px; gap: 4px 12px; }
  .li .d { grid-column: 1; grid-row: 2; }
  .li .m { grid-column: 1; grid-row: 1; }
  .li .amt { grid-column: 2; grid-row: 1; }
  .li .pill { grid-column: 2; grid-row: 2; justify-self: end; }
  .li.cust { grid-template-columns: 1fr auto; }
  .sheet { width: 100vw; border-left: 0; animation: up .2s ease-out; }
  .sheet-head { padding-top: calc(12px + env(safe-area-inset-top)); }
  .settings { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 > :first-child { grid-column: 1 / -1; }
  #toast-root { bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); }
  .hide-phone { display: none !important; }
  .input, select.input { font-size: 16px; } /* iOS не зумит поля */
}
@media (min-width: 861px) { .hide-desk { display: none !important; } }

/* ---------- documents ---------- */
.note { white-space: pre-line; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; height: 36px; }
.seg button:disabled { cursor: default; }
.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; text-align: left; }
.doc-row:hover { border-color: var(--line-2); }
.doc-row .m { flex: 1; min-width: 0; }
.doc-row .m b { display: block; }
.doc-row .m span { font-size: 12px; color: var(--muted); }
.doc-row .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.doc-kind { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--surface-3); color: var(--silver); flex: none; }
.doc-kind.rechnung { background: var(--red-soft); color: var(--red-hi); }
.lines { display: flex; flex-direction: column; gap: 6px; }
.line { display: grid; grid-template-columns: 1fr 74px 78px 96px 92px 36px; gap: 6px; align-items: center; }
.line.text { grid-template-columns: 1fr 36px; }
.line .sum { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.line .input { height: 36px; padding: 0 9px; }
.line textarea.input { min-height: 36px; padding: 7px 9px; }
.doc-totals { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 13px; }
.doc-totals div { display: flex; gap: 16px; }
.doc-totals span { color: var(--muted); }
.doc-totals b { min-width: 100px; text-align: right; font-variant-numeric: tabular-nums; }
.doc-totals .g { font-size: 16px; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.doc-totals .g span { color: var(--text); }
.photo.pick { outline: 2px solid transparent; outline-offset: -2px; }
.photo.pick .check { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.55); color: transparent; display: grid; place-items: center; font-size: 13px; border: 1.5px solid #fff; }
.photo.pick.on { outline-color: var(--red); }
.photo.pick.on .check { background: var(--red); color: #fff; border-color: var(--red); }
.photo.pick:not(.on) img { opacity: .55; }
.cat-head, .cat-row { display: grid; grid-template-columns: 1fr 90px 110px 150px 80px; gap: 6px; align-items: center; }
.cat-row { margin-bottom: 6px; }
.cat-row.off { opacity: .45; }
.cat-row .input { height: 36px; }
@media (max-width: 860px) {
  .line { grid-template-columns: 1fr 1fr 1fr 36px; }
  .line .nm { grid-column: 1 / -1; }
  .line .sum { grid-column: 1 / -1; grid-row: 3; }
  .line .q { grid-column: 1; } .line .u { grid-column: 2; } .line .p { grid-column: 3; }
  .line > button { grid-row: 2; grid-column: 4; }
  .line { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .cat-head { display: none; }
  .cat-row { grid-template-columns: 1fr 1fr; }
  .cat-row > :first-child { grid-column: 1 / -1; }
}
.board { grid-template-columns: repeat(5, minmax(190px, 1fr)); }

/* ---------- календарь квадратами ---------- */
.cal-filter { padding: 0 24px 12px; }
.cal { padding: 0 24px 28px; }
.cal-row { display: grid; grid-template-columns: 64px repeat(5, minmax(0, 1fr)) repeat(2, minmax(0, .55fr)); gap: 6px; margin-bottom: 6px; }
.cal-head { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 4px 0; margin-bottom: 2px; }
.cal-head div { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding-left: 8px; }
.cal-head .we { color: var(--faint); }
.cal-kw { display: flex; flex-direction: column; justify-content: flex-start; padding-top: 8px; font-size: 11px; color: var(--muted); }
.cal-kw b { font-size: 12px; color: var(--text); letter-spacing: .04em; }
.cal-day { min-height: 112px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: cell; min-width: 0; }
.cal-day.we { background: transparent; border-style: dashed; }
.cal-day.hol { background: var(--holiday); }
.cal-day.past { opacity: .62; }
.cal-day.today { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); opacity: 1; }
.cal-day.drop { border-color: var(--text); background: var(--surface-2); }
.cal-num { display: flex; align-items: baseline; gap: 6px; font-size: 12px; min-width: 0; }
.cal-num b { font-size: 13px; }
.cal-day.today .cal-num b { background: var(--red); color: #fff; border-radius: 5px; padding: 0 5px; }
.cal-num span { color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: .12em; }
.cal-num em { font-style: normal; color: var(--red-hi); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip { position: relative; border-radius: 6px; padding: 4px 7px 4px 9px; background: var(--surface-3); border: 1px solid var(--line-2); cursor: pointer; user-select: none; min-width: 0;
  display: flex; flex-direction: column; -webkit-touch-callout: none; }
.cal-chip::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; border-radius: 6px 0 0 6px; background: var(--crew); }
.cal-chip .t { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip .s { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.active { background: linear-gradient(180deg, var(--red-hi), var(--red)); border-color: var(--red); color: #fff; }
.cal-chip.active .s { color: rgba(255, 255, 255, .82); }
.cal-chip.active::before { background: rgba(255, 255, 255, .55); }
.cal-chip.done { background: var(--amber-soft); border-color: var(--amber); }
.cal-chip.invoiced, .cal-chip.paid { opacity: .55; }
.cal-chip.offer { border-style: dashed; }
.cal-chip.conflict { outline: 2px dashed var(--red-hi); outline-offset: 1px; }
.cal-chip.mid, .cal-chip.last { opacity: .8; }
.cal-chip.lifted { opacity: .35; }
.cal-chip.ghost { position: fixed; z-index: 90; pointer-events: none; width: 170px; box-shadow: var(--shadow); opacity: .95; }
.cal-abs { font-size: 10.5px; color: var(--muted); padding: 3px 7px; border-radius: 6px; border: 1px dashed var(--line-2);
  background: repeating-linear-gradient(135deg, var(--surface-3) 0 5px, transparent 5px 10px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { border: 0; background: none; color: var(--muted); font-size: 11px; text-align: left; padding: 2px 4px; cursor: pointer; }
.cal-more:hover { color: var(--text); }
.cal-filter .chip { display: inline-flex; align-items: center; gap: 6px; }
/* телефон: список по неделям */
.agenda { padding: 0 16px 24px; }
.ag-week { margin-bottom: 18px; }
.ag-head { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 6px 0; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.ag-day { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ag-day.today .ag-date b { color: var(--red-hi); }
.ag-day.past { opacity: .6; }
.ag-date { font-size: 12.5px; color: var(--muted); }
.ag-date b { color: var(--text); display: block; font-size: 13px; }
.ag-date .hol { display: block; color: var(--red-hi); font-size: 10.5px; }
.ag-items { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
@media (max-width: 860px) { .cal-filter { padding: 0 16px 10px; flex-wrap: nowrap; overflow-x: auto; } }
