:root {
  --blue: #778FFF; --blue-d: #5d76ec; --blue-l: #EEF1FF;
  --navy: #18254E; --navy-2: #3a4670;
  --peach: #FFEEE5; --peach-d: #f3c9b2;
  --bg: #F5F6FB; --card: #fff; --line: #E3E6F0; --muted: #6b7290;
  --ok: #1f9d6b; --ok-l: #E3F6EE; --warn: #b9770e; --warn-l: #FFF4DC; --danger: #d64545; --danger-l: #FDECEC;
  --r: 14px; --r-s: 10px;
  --tab-h: 64px;
  --text: #18254E; --surface: #fff; --surface-2: #fcfcff; --surface-3: #eef0f5; --seg-on: #fff; --tag-bg: #18254E;
  --warn-text: #7a4f06; --peach-text: #8a4a2a; --blue-text: #4459c9;
  color-scheme: light;
}
/* ---------- тёмная тема ---------- */
html[data-theme="dark"] {
  --bg: #0f1424; --card: #181f35; --surface: #181f35; --surface-2: #1d2540; --surface-3: #232c4a;
  --seg-on: #3a4775; --line: #2c3657; --muted: #93a0c4; --text: #e7ebf7; --navy-2: #b8c2e0; --tag-bg: #3a4775;
  --blue-l: #26305a; --blue-d: #9fb0ff; --blue-text: #b4c1ff;
  --peach: #3d2a24; --peach-d: #6b4535; --peach-text: #ffcfb8;
  --ok: #2fb67f; --ok-l: #143a2d; --warn: #f0b440; --warn-l: #3a2f12; --warn-text: #ffd98a; --danger: #ff6b6b; --danger-l: #3d1c22;
  color-scheme: dark;
}
html[data-theme="dark"] .topbar { background: #0b1020; border-bottom: 1px solid var(--line); }
html[data-theme="dark"] .tabbar { background: #121a2e; }
html[data-theme="dark"] .card, html[data-theme="dark"] .order-card, html[data-theme="dark"] .list-item, html[data-theme="dark"] .trip, html[data-theme="dark"] .ds { box-shadow: 0 0 0 1px var(--line); }
html[data-theme="dark"] .st-cancelled, html[data-theme="dark"] .chip { background: #2a3352; color: #b8c2e0; }
html[data-theme="dark"] .st-planned { background: #26305a; }
html[data-theme="dark"] .btn-danger { background: var(--danger-l); color: #ff9a9a; }
html[data-theme="dark"] .modal-wrap { background: rgba(0, 0, 0, .6); }
html[data-theme="dark"] .center-page { background: #0b1020; }
html[data-theme="dark"] .toast { background: #3a4775; }
html[data-theme="dark"] .error-box { color: #ff9a9a; }
html[data-theme="dark"] .form-error { color: #ff8a8a; }
html[data-theme="dark"] .free-line { color: #6fe0b0; }
html[data-theme="dark"] .tg-col.today, html[data-theme="dark"] .cal-cell.today { background: rgba(119, 143, 255, .10); }
html[data-theme="dark"] .tg-col:has(.tg-offday) { background: repeating-linear-gradient(135deg, rgba(255,160,120,.10) 0 8px, rgba(255,160,120,.03) 8px 16px); }
html[data-theme="dark"] .tg-off { background: repeating-linear-gradient(135deg, #3d2a24 0 6px, #2a1f1c 6px 12px); }
html[data-theme="dark"] .tg-cancelled { background: #4a5372; }
html[data-theme="dark"] .ev-dot { background: #7f9cff; }
html[data-theme="dark"] .st-ev-done .ev-dot { background: var(--ok); }
html[data-theme="dark"] .st-ev-in_progress .ev-dot { background: var(--warn); }
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: #6f7ba0; }
html[data-theme="dark"] .trip-big { box-shadow: 0 0 0 1px var(--peach-d); }
html[data-theme="dark"] .radio-card input { accent-color: var(--blue); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--blue-d); text-decoration: none; }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.2; }
h3 { font-size: 1.02rem; margin: 0; }
p { margin: 0; }
ul, ol { margin: .3rem 0; padding-left: 1.2rem; }
.ico { display: inline-flex; width: 20px; height: 20px; flex: none; }
.ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- каркас ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand img { width: 34px; height: 34px; }
.sidenav { display: none; }
.user-btn { margin-left: auto; display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.1); color: #fff;
  border: 0; border-radius: 999px; padding: 7px 12px; font: inherit; font-size: .9rem; cursor: pointer; max-width: 55vw; }
.user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view { padding: 16px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .72rem; font-weight: 500; }
.tab .ico { width: 24px; height: 24px; }
.tab.active { color: var(--blue-d); }
.tab.active .ico { color: var(--blue); }
@media (min-width: 900px) {
  .tabbar { display: none; }
  .sidenav { display: flex; gap: 4px; margin-left: 24px; }
  .sidenav-link { display: flex; align-items: center; gap: 8px; color: #c9d0ec; padding: 8px 14px; border-radius: 10px; font-weight: 500; }
  .sidenav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
  .sidenav-link.active { background: var(--blue); color: #fff; }
  .view { padding: 24px 32px 48px; }
}
.page { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page.narrow { max-width: 680px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px;
  border-radius: var(--r-s); border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-align: center;
  transition: background .15s, border-color .15s; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--blue); }
.btn-danger { background: var(--danger-l); color: var(--danger); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-sm { min-height: 38px; padding: 7px 12px; font-size: .9rem; }
.btn-lg { min-height: 56px; font-size: 1.05rem; border-radius: var(--r); }
.btn-block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--r-s);
  background: var(--surface); border: 1px solid var(--line); color: var(--text); cursor: pointer; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--blue-d); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 500; align-self: flex-start; padding: 6px 0; }
.back-btn { align-self: flex-start; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.status-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.big-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- карточки ---------- */
.card { background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: 0 1px 2px rgba(24,37,78,.05), 0 0 0 1px var(--line); }
.subcard { border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px; background: var(--surface-2); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.big-time { font-size: 1.1rem; font-weight: 600; margin: 8px 0 6px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.kv-k { color: var(--muted); font-size: .9rem; }
.kv-v { word-break: break-word; }
@media (max-width: 420px) { .kv { grid-template-columns: 1fr; gap: 2px; } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline { display: flex; gap: 8px; align-items: flex-end; }
.inline .field { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.pad-s { padding: 6px 2px; }
.prewrap { white-space: pre-wrap; }
.warn-text { color: var(--warn); font-weight: 600; }
.dim { opacity: .6; }
.empty { color: var(--muted); padding: 14px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-s); }
.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }

/* ---------- чипы и статусы ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600;
  background: var(--surface-3); color: var(--navy-2); white-space: nowrap; }
.chip-soft { background: var(--blue-l); color: var(--blue-d); }
.st-planned { background: var(--blue-l); color: var(--blue-text); }
.st-in_progress { background: var(--warn-l); color: var(--warn); }
.st-done { background: var(--ok-l); color: var(--ok); }
.st-cancelled { background: var(--surface-3); color: #7a8099; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .88rem; cursor: pointer; color: var(--text); }
.chip-btn:hover { border-color: var(--blue); }
.chip-x { border: 0; background: none; font-size: 1.1rem; line-height: 1; cursor: pointer; color: inherit; padding: 0 0 0 4px; }

/* ---------- расписание ---------- */
.toolbar { display: flex; flex-direction: column; gap: 12px; }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-s); padding: 3px; }
.seg a, .seg button { padding: 8px 14px; border-radius: 8px; color: var(--navy-2); font-weight: 600; font-size: .9rem; border: 0; background: none; font-family: inherit; cursor: pointer; }
.seg .on { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 3px rgba(24,37,78,.12); }
.seg-full { display: flex; } .seg-full > * { flex: 1; }
.date-nav { display: inline-flex; align-items: center; gap: 4px; }
.date-label { min-width: 120px; text-align: center; font-weight: 600; }
select, input, textarea { font: inherit; color: var(--text); }
.select-sm { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); max-width: 100%; }
@media (max-width: 600px) { .toolbar-row .select-sm { flex: 1 1 100%; } .date-nav { flex: 1; justify-content: space-between; } }

.day-items { display: flex; flex-direction: column; gap: 8px; }
.order-card { display: flex; gap: 12px; background: var(--surface); border-radius: var(--r-s); padding: 12px; color: var(--text);
  box-shadow: 0 0 0 1px var(--line); border-left: 4px solid var(--blue); }
.order-card:hover { box-shadow: 0 0 0 1px var(--blue); }
.st-row-in_progress { border-left-color: #f0b440; }
.st-row-done { border-left-color: var(--ok); }
.st-row-cancelled { border-left-color: #c3c7d4; opacity: .62; }
.st-row-cancelled .oc-title span:first-child, .st-row-cancelled .trip-work { text-decoration: line-through; }
.oc-time { font-weight: 700; white-space: nowrap; min-width: 92px; font-size: .95rem; }
.oc-date { font-weight: 500; color: var(--muted); font-size: .8rem; }
.oc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.oc-title { display: flex; gap: 8px; justify-content: space-between; align-items: flex-start; font-weight: 600; }
.oc-line { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; }
.emp-tag { display: inline-block; background: var(--tag-bg); color: #fff; border-radius: 6px; padding: 1px 7px; font-size: .78rem; font-weight: 600; }
.emp-tag.warn { background: var(--warn-l); color: var(--warn); }
.order-card.compact { flex-direction: column; gap: 4px; padding: 9px 10px; }
.order-card.compact .oc-time { min-width: 0; font-size: .85rem; }
.order-card.compact .oc-title { font-size: .88rem; flex-wrap: wrap; }
.off-badge { background: var(--peach); border: 1px solid var(--peach-d); border-radius: var(--r-s); padding: 8px 10px; font-size: .88rem; }
.free-line { font-size: .86rem; color: var(--ok); background: var(--ok-l); border-radius: var(--r-s); padding: 8px 10px; }
.week { display: flex; flex-direction: column; gap: 14px; }
.week-day { background: var(--surface-3); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.week-day.today { background: var(--blue-l); box-shadow: inset 0 0 0 2px var(--blue); }
.week-day-head { font-weight: 700; color: var(--text); padding: 2px 2px 0; }
@media (min-width: 900px) {
  .week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
  .week-day { min-height: 220px; }
}

/* ---------- формы ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: .86rem; font-weight: 600; color: var(--navy-2); }
.field-hint { font-size: .8rem; color: var(--muted); }
.field input, .field select, .field textarea, .search-wrap input, .stack > input[type=search] {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface);
  font-size: 16px; /* без автозума на iPhone */
}
.field textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.form-error { color: var(--danger); font-weight: 600; min-height: 0; }
.form-error:empty { display: none; }
.alert { background: var(--warn-l); color: var(--warn-text); border-radius: var(--r-s); padding: 10px 12px; font-size: .9rem; }
.check { display: flex; gap: 10px; align-items: center; }
.check input { width: 22px; height: 22px; }
.search-wrap { position: relative; }
.search-wrap .ico { position: absolute; left: 12px; top: 13px; color: var(--muted); }
.search-wrap input { padding-left: 40px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pick { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; font: inherit; color: var(--text); cursor: pointer; }
.pick:hover { border-color: var(--blue); }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--blue-l); border-radius: var(--r-s); padding: 10px 12px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; cursor: pointer; background: var(--surface); }
.radio-card.on { border-color: var(--blue); background: var(--blue-l); }
.radio-card input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--blue); }

/* ---------- списки ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--r-s); padding: 12px 14px; color: var(--text);
  box-shadow: 0 0 0 1px var(--line); border: 0; font: inherit; text-align: left; cursor: pointer; width: 100%; }
.list-item:hover { box-shadow: 0 0 0 1px var(--blue); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.li-main .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-side { color: var(--muted); white-space: nowrap; }
.off-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }

/* ---------- мои выезды ---------- */
.trip { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border-radius: var(--r); padding: 14px; color: var(--text);
  box-shadow: 0 0 0 1px var(--line); border-left: 5px solid var(--blue); }
.trip-big { background: var(--peach); box-shadow: 0 0 0 1px var(--peach-d); padding: 18px; }
.trip-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.trip-time { font-size: 1.15rem; font-weight: 700; }
.trip-big .trip-time { font-size: 1.5rem; }
.trip-day { font-weight: 600; color: var(--navy-2); }
.trip-work { font-weight: 600; }
.trip-addr { display: flex; gap: 6px; align-items: flex-start; }
.trip-addr .ico { width: 18px; height: 18px; margin-top: 2px; color: var(--blue-d); }
.group-head { font-weight: 700; color: var(--navy-2); font-size: .92rem; margin-top: 4px; }
.link-center { text-align: center; padding: 8px; }
.day-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.ds { border-radius: var(--r-s); padding: 6px 2px; text-align: center; background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.ds-wd { font-size: .72rem; color: var(--muted); }
.ds-d { font-weight: 700; font-size: 1.05rem; }
.ds-s { font-size: .64rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds.free { background: var(--ok-l); box-shadow: none; } .ds.free .ds-s { color: var(--ok); }
.ds.busy { background: var(--blue-l); box-shadow: none; } .ds.busy .ds-s { color: var(--blue-text); }
.ds.off { background: var(--peach); box-shadow: 0 0 0 1px var(--peach-d); } .ds.off .ds-s { color: var(--peach-text); }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-left: 6px; }
.lg.free { background: var(--ok-l); border: 1px solid var(--ok); } .lg.busy { background: var(--blue-l); border: 1px solid var(--blue); } .lg.off { background: var(--peach); border: 1px solid var(--peach-d); }
section.stack { gap: 10px; }

/* ---------- служебное ---------- */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 16px; color: var(--muted); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--blue-l); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: var(--danger-l); color: var(--danger); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 20px); opacity: 0;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 100; transition: .25s; max-width: calc(100vw - 32px); font-weight: 500; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-err { background: var(--danger); }
.modal-wrap { position: fixed; inset: 0; background: rgba(24,37,78,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.modal-title { font-size: 1.15rem; margin: 0; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
@media (max-width: 520px) { .modal-actions .btn { flex: 1 1 100%; } .modal-actions { flex-direction: column-reverse; } }
@media (min-width: 600px) { .modal-wrap { align-items: center; } .modal { border-radius: 18px; padding: 22px; } }
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--navy); }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.login-brand { display: flex; gap: 14px; align-items: center; }
.login-brand img { width: 64px; height: 64px; }

/* ---------- услуги ---------- */
.code-tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; font-weight: 700; background: var(--tag-bg); color: #fff; border-radius: 6px; padding: 1px 7px; }
.svc-name { font-size: .92rem; margin-top: 3px; line-height: 1.3; }
.list-item.svc .li-main .svc-name { white-space: normal; }
.li-side.price { text-align: right; font-weight: 700; color: var(--text); }
details.lang > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.lang > summary::-webkit-details-marker { display: none; }
details.lang > summary::after { content: '▾'; color: var(--muted); }
details.lang[open] > summary::after { content: '▴'; }
details.lang[open] > summary { margin-bottom: 12px; }
@media (max-width: 380px) { .tab { font-size: .64rem; } }
.pick-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 3px; }
.svc-line { border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; }
.svc-line-top { display: flex; justify-content: space-between; align-items: center; }
.svc-line-calc { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.svc-line-calc input.qty { width: 84px; min-height: 40px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.svc-total { text-align: right; font-size: 1.05rem; padding-top: 4px; }
.svc-row { display: flex; flex-direction: column; gap: 2px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.nowrap { white-space: nowrap; }
.seg-full button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 40px; }
.seg-full .ico { width: 16px; height: 16px; }

/* ---------- календарь (как в Roapp) ---------- */
.cal-bar .date-label { flex: 1; text-align: center; font-size: 1.15rem; font-weight: 700; min-width: 0; }
.cal-bar .date-nav { gap: 6px; }
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { text-align: center; font-size: .8rem; color: var(--muted); padding: 6px 0; background: var(--surface-3); border-bottom: 1px solid var(--line); }
.cal-cell { min-height: 118px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; display: flex; flex-direction: column; gap: 3px; background: var(--surface-2); min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-week .cal-cell { min-height: 420px; }
.cal-cell.other { background: var(--surface-3); }
.cal-cell.other .cal-num { color: #aab0c2; }
.cal-cell.today { background: var(--blue-l); }
.cal-cell.today .cal-num { color: #fff; background: var(--blue); border-radius: 999px; padding: 0 8px; }
.cal-num { align-self: flex-end; font-weight: 700; color: var(--text); font-size: .95rem; padding: 0 4px; line-height: 1.6; }
.ev { display: flex; align-items: center; gap: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font-size: .82rem; color: var(--text); min-width: 0; }
.ev:hover { border-color: var(--blue); }
.ev-dot { width: 7px; height: 7px; border-radius: 50%; background: #3b6fe0; flex: none; }
.ev-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-time { color: var(--muted); font-size: .78rem; flex: none; }
.st-ev-in_progress .ev-dot { background: #f0b440; }
.st-ev-done .ev-dot { background: var(--ok); }
.st-ev-cancelled { opacity: .55; } .st-ev-cancelled .ev-name { text-decoration: line-through; }
.st-ev-cancelled .ev-dot { background: #b9bfcc; }
.cal-off { font-size: .74rem; background: var(--peach); border: 1px solid var(--peach-d); border-radius: 6px; padding: 1px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--peach-text); }
.cal-more { font-size: .76rem; color: var(--blue-d); padding-left: 4px; }
@media (max-width: 700px) {
  .cal-bar .date-label { order: -1; flex: 1 1 100%; text-align: left; }
  .cal-cell { min-height: 74px; padding: 2px; }
  .cal-week .cal-cell { min-height: 160px; }
  .ev { padding: 1px 3px; font-size: .68rem; gap: 2px; }
  .ev-time { display: none; }
  .ev-dot { width: 5px; height: 5px; }
  .cal-off { font-size: .62rem; padding: 0 2px; }
  .cal-num { font-size: .8rem; }
}

/* ---------- сетка по времени (день / неделя) ---------- */
.tg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.tg-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tg-inner { min-width: calc(56px + var(--days) * 120px); }
.tg-wide .tg-inner { min-width: 0; }
.tg-head { display: grid; grid-template-columns: 56px repeat(var(--days), minmax(0, 1fr)); background: var(--surface-3); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 3; }
.tg-day { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; color: var(--text); border-left: 1px solid var(--line); line-height: 1.25; }
.tg-day .tg-wd { font-size: .78rem; color: var(--muted); }
.tg-day.today b { color: #fff; background: var(--blue); border-radius: 999px; padding: 0 8px; }
.tg-body { display: grid; grid-template-columns: 56px 1fr; }
.tg-hours { position: relative; }
.tg-hour { position: absolute; right: 6px; transform: translateY(-50%); font-size: .74rem; color: var(--muted); }
.tg-hour:first-child { transform: none; }
.tg-cols { display: grid; grid-template-columns: repeat(var(--days), minmax(0, 1fr));
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px); }
.tg-col { position: relative; border-left: 1px solid var(--line); }
.tg-col.today { background: rgba(119, 143, 255, .06); }
.tg-ev { position: absolute; border-radius: 6px; padding: 3px 6px; color: #fff; background: #3b6fe0; overflow: hidden; font-size: .78rem; line-height: 1.25;
  box-shadow: 0 1px 2px rgba(0,0,0,.15); display: flex; flex-direction: column; gap: 1px; z-index: 2; }
.tg-ev:hover { filter: brightness(1.07); z-index: 4; }
.tg-in_progress { background: #e09a1a; }
.tg-done { background: #1f9d6b; }
.tg-cancelled { background: #b9bfcc; } .tg-cancelled .tg-client { text-decoration: line-through; }
.tg-top { display: flex; justify-content: space-between; gap: 4px; font-size: .7rem; font-weight: 700; white-space: nowrap; }
.tg-st { opacity: .9; overflow: hidden; text-overflow: ellipsis; }
.tg-client { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-emp { font-size: .72rem; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-work, .tg-addr { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.tg-addr { opacity: .9; font-size: .74rem; }
.tg-offday { position: absolute; left: 2px; right: 2px; height: 20px; font-size: .7rem; background: var(--peach); border: 1px solid var(--peach-d); color: var(--peach-text);
  border-radius: 5px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 3; }
.tg-col:has(.tg-offday) { background: repeating-linear-gradient(135deg, rgba(255,238,229,.55) 0 8px, rgba(255,238,229,.15) 8px 16px); }
.tg-off { position: absolute; left: 2px; right: 2px; font-size: .7rem; color: var(--peach-text); border-radius: 5px; padding: 1px 5px; overflow: hidden;
  background: repeating-linear-gradient(135deg, #ffe2d3 0 6px, #fff1e9 6px 12px); border: 1px dashed var(--peach-d); z-index: 1; }
.tg-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 5; }
.tg-now::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

/* ---------- счёт (инвойс): всегда белая бумага ---------- */
.inv-page { max-width: 900px; }
.inv-toolbar { display: flex; flex-direction: column; gap: 8px; }
.inv-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 6px; }
.inv-paper { background: #fff; color: #111; width: 794px; min-height: 1000px; margin: 0 auto; padding: 36px 40px; font-size: 12px; line-height: 1.4;
  font-family: Arial, "Helvetica Neue", "Noto Sans Georgian", "BPG Arial", sans-serif; box-shadow: 0 2px 12px rgba(0,0,0,.25); }
.inv-paper * { color: #111; }
.inv-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.inv-company { font-size: 12.5px; line-height: 1.35; }
.inv-logo { width: 118px; height: auto; margin-right: 30px; }
.inv-co-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; color: #18254E !important; }
.inv-title { text-align: center; font-weight: 700; font-size: 17px; line-height: 1.3; margin: 18px 0 6px; }
.inv-date { font-weight: 400; font-size: 12px; margin-top: 2px; }
.inv-title-langs { font-weight: 700; font-size: 15px; color: #18254E !important; }
.inv-title-langs div { color: #18254E !important; }
.inv-no { font-size: 20px; font-weight: 700; margin-top: 6px; }
.inv-party { margin: 16px 0 12px; } .inv-party p { margin: 0 0 6px; }
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table th, .inv-table td { border: 1px solid #b9bfcc; padding: 6px 8px; vertical-align: top; }
.inv-table th { background: #eef1ff; font-size: 10.5px; font-weight: 700; text-align: left; }
.inv-table .n { width: 28px; text-align: center; }
.inv-table .num { text-align: right; white-space: nowrap; width: 92px; }
.inv-table td div + div { color: #444; font-size: 11px; }
.inv-table .tot-l { text-align: right; font-weight: 700; }
.inv-table .tot { font-weight: 700; }
.inv-table .due { font-size: 14px; background: #fff4dc; }
.inv-pay { margin-top: 18px; border-top: 1px solid #ccc; padding-top: 10px; }
.inv-pay p { margin: 0 0 6px; }
.inv-pay-h { font-weight: 700; margin-bottom: 6px; }
.inv-sign { margin-top: 36px; display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inv-line { display: inline-block; width: 200px; border-bottom: 1px solid #111; height: 18px; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff !important; }
  .topbar, .tabbar, .no-print, .toast { display: none !important; }
  .view { padding: 0 !important; }
  .inv-wrap { overflow: visible; }
  .inv-paper { box-shadow: none; width: auto; min-height: 0; padding: 0; zoom: 1 !important; }
}
.disc-type { min-height: 40px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 16px; }
.svc-line-calc s { text-decoration: line-through; }
.disc-panel > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.disc-panel > summary::after { content: '▾'; color: var(--muted); }
.disc-panel[open] > summary { margin-bottom: 10px; }
.disc-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }
.disc-name { flex: 1 1 260px; min-width: 0; font-size: .9rem; }
.inv-pct { color: #666 !important; font-size: 10px; }
.svc-line-calc input.qty { background: var(--surface); color: var(--text); }
.tax-check { gap: 10px; align-items: flex-start; } .tax-check input { margin-top: 2px; flex: none; }
.tax-wrap { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface-2); }
.tax-wrap.off .tax-check { opacity: .55; }
.tax-wrap .link-btn { font-size: inherit; padding: 0; }

/* логотип-пропеллер медленно вращается */
.spin-logo { animation: prop-spin 14s linear infinite; transform-origin: 50% 50%; }
@keyframes prop-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin-logo { animation: none; } }
.loading-soft { opacity: .8; }
.tg-col, .cal-cell { cursor: pointer; }
.tg-ghost { display: none; position: absolute; left: 2px; right: 2px; height: 28px; border: 1px dashed var(--blue); border-radius: 6px; background: rgba(119,143,255,.12);
  color: var(--blue-d); font-size: .75rem; font-weight: 700; padding: 2px 6px; pointer-events: none; z-index: 1; }
@media (hover: none) { .tg-ghost { display: none !important; } }
.cal-cell:hover { outline: 1px dashed var(--blue); outline-offset: -2px; }

/* ---------- защита от горизонтальной прокрутки ---------- */
html, body { max-width: 100%; overflow-x: hidden; }
.app, .view { max-width: 100vw; overflow-x: clip; }
.page, .stack, .card, .list-item, .li-main, .toolbar-row, .page-head { min-width: 0; }
.page-head h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head .btn { flex: none; }
.day-strip { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.ds { min-width: 0; overflow: hidden; }
.ds-s { font-size: .6rem; }
.inline { flex-wrap: wrap; }
.inline .field { min-width: 0; flex: 1 1 160px; }
.user-btn { min-width: 0; flex: 0 1 auto; }
.brand { flex: none; }
.spin-logo { will-change: transform; }
.brand, .login-brand { overflow: visible; }
