:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e3e5ea;
  --text: #16181d;
  --muted: #646a76;
  --primary: #1f6feb;
  --primary-ink: #ffffff;
  --danger: #d92d20;
  --open: #e5484d;
  --progress: #f5a524;
  --done: #30a46c;
  --rejected: #8b8d98;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 12px;
  --topbar: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #181b21; --surface-2: #20242c; --border: #2b303a;
    --text: #e8eaee; --muted: #9aa1ad; --primary: #4c8dff; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
[hidden] { display: none !important; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { width: 40px; padding: 0; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 18px; height: 18px; }

.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 400;
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
.row { display: flex; gap: 10px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }

/* ---------- Auth ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.brand img { width: 36px; height: 36px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin: 20px 0 16px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.hint { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--muted); }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar);
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-block { min-width: 0; flex: 1; }
.page { max-width: 1100px; margin: 0 auto; padding: 16px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--primary) 18%, var(--surface)); color: var(--primary); font-weight: 700; font-size: 13px;
}

/* ---------- Project cards ---------- */
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; display: grid; gap: 10px; transition: transform .1s, box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.card h3 { font-size: 16px; }
.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.bar span { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: 0; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.empty svg { width: 56px; height: 56px; opacity: .5; }

/* ---------- Project view ---------- */
.project-shell { display: flex; flex-direction: column; position: fixed; inset: 0; }
.subnav { display: flex; gap: 4px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.subnav button {
  border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.subnav button.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.project-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; scrollbar-width: none; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 6px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.chip.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--surface)); color: var(--primary); }
.chip .count { color: var(--muted); font-weight: 500; }

/* ---------- Plan viewer ---------- */
.viewer { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--surface-2); touch-action: none; cursor: grab; }
.viewer.dragging { cursor: grabbing; }
.viewer.adding { cursor: crosshair; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage img { display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; box-shadow: var(--shadow); background: #fff; }
.pin {
  position: absolute; width: 30px; height: 30px; margin: -30px 0 0 -15px; cursor: pointer;
  transform-origin: 50% 100%; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35));
}
.pin svg { width: 100%; height: 100%; display: block; }
.pin b { position: absolute; top: 5px; left: 0; width: 100%; text-align: center; font-size: 11px; color: #fff; font-weight: 800; }
.pin.selected { z-index: 2; }
.pin.selected svg path { stroke: var(--text); stroke-width: 2.5; }
.viewer-tools { position: absolute; right: 12px; top: 12px; display: grid; gap: 6px; }
.viewer-tools .btn { box-shadow: var(--shadow); }
.fab {
  position: absolute; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); height: 54px; padding: 0 20px;
  border-radius: 27px; border: 0; background: var(--primary); color: #fff; font-weight: 700; box-shadow: 0 6px 20px rgba(31,111,235,.4);
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 15px;
}
.fab svg { width: 22px; height: 22px; }
.fab.active { background: var(--text); color: var(--surface); }
.banner {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: var(--text); color: var(--surface);
  padding: 8px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); white-space: nowrap;
}

/* ---------- Issue list ---------- */
.list-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.list-tools .input { width: auto; min-height: 38px; }
.list-tools .search { flex: 1 1 220px; }
.issue-list { overflow-y: auto; flex: 1; padding: 8px 12px 90px; }
.issue-row {
  display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); margin-bottom: 8px; cursor: pointer;
}
.issue-row:hover { box-shadow: var(--shadow); }
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.thumb svg { width: 22px; height: 22px; opacity: .6; }
.issue-main { min-width: 0; flex: 1; display: grid; gap: 3px; }
.issue-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.issue-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.overdue { color: var(--danger); font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.open { background: color-mix(in srgb, var(--open) 14%, transparent); color: var(--open); }
.badge.in_progress { background: color-mix(in srgb, var(--progress) 18%, transparent); color: #b86e00; }
.badge.done { background: color-mix(in srgb, var(--done) 15%, transparent); color: var(--done); }
.badge.rejected { background: color-mix(in srgb, var(--rejected) 18%, transparent); color: var(--rejected); }
.prio { font-size: 12px; font-weight: 700; }
.prio.high { color: #c4320a; } .prio.critical { color: var(--danger); } .prio.low { color: var(--muted); }

/* ---------- Drawer / sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 16, .45); z-index: 40; animation: fade .15s; }
.drawer {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(480px, 100%);
  background: var(--surface); box-shadow: -8px 0 30px rgba(0,0,0,.18); display: flex; flex-direction: column; animation: slide .18s ease-out;
}
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 17px; flex: 1; min-width: 0; }
.drawer-body { overflow-y: auto; padding: 16px; display: grid; gap: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.modal {
  position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 20px; display: grid; gap: 14px; animation: pop .15s;
}
.modal h2 { font-size: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 640px) {
  .modal { top: auto; bottom: 0; transform: translateX(-50%); border-radius: 18px 18px 0 0; width: 100%; max-height: 92dvh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); animation: up .18s ease-out; }
  .grid2 { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes pop { from { transform: translate(-50%, -48%); opacity: 0; } }
@keyframes up { from { transform: translate(-50%, 30px); opacity: 0; } }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.segmented button { border: 0; background: transparent; border-radius: 8px; padding: 8px 4px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--muted); }
.segmented button.active.open { background: var(--open); color: #fff; }
.segmented button.active.in_progress { background: var(--progress); color: #fff; }
.segmented button.active.done { background: var(--done); color: #fff; }
.segmented button.active.rejected { background: var(--rejected); color: #fff; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.photo .del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 15px; line-height: 1; }
.add-photo { aspect-ratio: 1; border: 2px dashed var(--border); border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; }
.add-photo svg { width: 24px; height: 24px; display: block; margin: 0 auto 4px; }

.section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.timeline { display: grid; gap: 10px; }
.event { display: flex; gap: 10px; font-size: 14px; }
.event .when { font-size: 12px; color: var(--muted); }
.event.system { color: var(--muted); font-size: 13px; }
.comment-box { display: flex; gap: 8px; align-items: flex-end; }
.comment-box textarea { min-height: 42px; }

.mini-plan { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); cursor: pointer; background: var(--surface-2); }
.mini-plan img { width: 100%; display: block; }
.mini-plan .pin { width: 22px; height: 22px; margin: -22px 0 0 -11px; }
.mini-plan .pin b { font-size: 9px; top: 3px; }

.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.9); display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }

/* ---------- Team ---------- */
.member { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.role { font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---------- Stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; text-align: center; cursor: pointer; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
@media (max-width: 520px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Toasts & menu ---------- */
#toasts { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(420px, calc(100% - 24px)); }
.toast { background: var(--text); color: var(--surface); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; animation: up2 .2s; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes up2 { from { transform: translateY(10px); opacity: 0; } }
.menu { position: absolute; right: 8px; top: calc(var(--topbar) - 4px); z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; display: grid; }
.menu button { text-align: start; border: 0; background: transparent; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.menu button:hover { background: var(--surface-2); }
.menu .danger { color: var(--danger); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Shifts, piecework, pay ---------- */
.scroll { flex: 1; min-height: 0; overflow-y: auto; }
.work-page { padding-bottom: 90px; }
.work-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.work-card summary { cursor: pointer; }
.btn.big { min-height: 50px; font-size: 16px; padding: 0 22px; }
.linkbtn { border: 0; background: none; color: var(--primary); cursor: pointer; font-weight: 600; padding: 0 4px; font-size: inherit; }
.pending-row { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); flex-wrap: wrap; }
.pending-row .thumb { cursor: zoom-in; }
.pending-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.money { text-align: right; white-space: nowrap; }
.kv { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.selfie-preview { max-width: 100%; max-height: 260px; border-radius: 12px; justify-self: center; }
.badge.st-pending { background: color-mix(in srgb, var(--progress) 18%, transparent); color: #b86e00; }
.badge.st-progress { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.badge.st-done { background: color-mix(in srgb, var(--done) 15%, transparent); color: var(--done); }
.badge.st-rejected { background: color-mix(in srgb, var(--open) 14%, transparent); color: var(--open); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.pay-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pay-table th, .pay-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: end; white-space: nowrap; }
.pay-table th:first-child, .pay-table td:first-child, .pay-table th:nth-child(2), .pay-table td:nth-child(2) { text-align: start; }
.pay-table th { font-size: 12px; color: var(--muted); font-weight: 700; }
.pay-table tfoot td { font-weight: 800; border-bottom: 0; }
.pay-table .debt { color: var(--danger); font-weight: 800; }
.btn.small-btn { min-height: 32px; padding: 0 10px; font-size: 13px; }
.pending-row .issue-main { flex: 1 1 180px; }
@media (max-width: 640px) { .pending-actions { width: 100%; } .pending-actions .btn { flex: 1; } }

/* ---------- Project navigation: top tabs on wide screens, bottom bar on phones ---------- */
.subnav button { display: inline-flex; align-items: center; gap: 6px; }
.subnav .ico svg { width: 18px; height: 18px; }
.nav-count { font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.nav-count.alert { background: var(--progress); color: #fff; }
.pending-note { font-size: 13px; font-weight: 700; color: #b86e00; }
@media (max-width: 640px) {
  .subnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; order: 9; gap: 0; padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border); border-bottom: 0; box-shadow: 0 -2px 12px rgba(0,0,0,.06); overflow: visible;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  }
  .subnav button { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; position: relative; min-width: 0; }
  .subnav .ico svg { width: 22px; height: 22px; }
  .subnav .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .subnav .nav-count { position: absolute; top: 2px; left: calc(50% + 6px); }
  .subnav .nav-count:not(.alert) { display: none; }
  .project-body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

/* ---------- Сводка, Журнал, «Ещё» ---------- */
.more-btn { display: none !important; }
.more-menu { top: auto; bottom: calc(68px + env(safe-area-inset-bottom)); position: fixed; right: 8px; z-index: 45; }
.more-menu button { display: flex; align-items: center; gap: 8px; }
.more-menu .ico svg { width: 20px; height: 20px; }
@media (max-width: 640px) {
  .subnav .more-item { display: none !important; }
  .more-btn { display: flex !important; }
}
.attn-list { display: grid; gap: 8px; margin-bottom: 14px; }
.attn { text-align: start; border: 1px solid color-mix(in srgb, var(--progress) 45%, var(--border)); background: color-mix(in srgb, var(--progress) 10%, var(--surface));
  border-radius: 12px; padding: 12px 14px; font-weight: 700; cursor: pointer; font-size: 15px; color: var(--text); }
.attn.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); color: var(--danger); }
.attn.ok { border-color: color-mix(in srgb, var(--done) 40%, var(--border)); background: color-mix(in srgb, var(--done) 8%, var(--surface)); cursor: default; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: grid; gap: 2px; }
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { box-shadow: var(--shadow); }
.tile b { font-size: 24px; line-height: 1.15; }
.tile span { font-size: 13px; color: var(--muted); font-weight: 600; }
@media (max-width: 520px) { .tiles { grid-template-columns: 1fr 1fr; } .tile b { font-size: 20px; } }

/* ---------- График, Приёмка, Материалы ---------- */
.page.wide { max-width: 1400px; }
.pbar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.pbar span { display: block; height: 100%; }
.gantt { --glabel: 220px; position: relative; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 10px; max-height: 70vh; }
.g-row { display: flex; min-width: max-content; border-bottom: 1px solid var(--border); cursor: pointer; }
.g-row:hover .g-label { background: var(--surface-2); }
.g-label { position: sticky; left: 0; z-index: 2; width: var(--glabel); flex: none; padding: 6px 10px; background: var(--surface); border-right: 1px solid var(--border);
  font-size: 13px; display: grid; overflow: hidden; }
.g-label span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.g-label small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-stage { cursor: default; background: var(--surface-2); }
.g-stage .g-label { background: var(--surface-2); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.g-headrow { position: sticky; top: 0; z-index: 3; cursor: default; }
.g-headrow .g-label { font-weight: 700; color: var(--muted); font-size: 12px; z-index: 4; }
.g-head { display: flex; background: var(--surface); }
.g-day { width: 26px; flex: none; text-align: center; font-size: 10px; color: var(--muted); padding: 2px 0; border-left: 1px solid color-mix(in srgb, var(--border) 50%, transparent); position: relative; }
.g-day b { position: absolute; top: -1px; left: 2px; font-size: 9px; color: var(--text); white-space: nowrap; }
.g-day { padding-top: 12px; }
.g-day.we { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.g-day.today { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); font-weight: 800; }
.g-track { position: relative; height: 38px; flex: none; }
.g-stage .g-track { height: 26px; }
.g-bar { position: absolute; top: 8px; height: 22px; border-radius: 6px; background: color-mix(in srgb, var(--primary) 25%, var(--surface)); border: 1px solid var(--primary); overflow: hidden; margin-left: 2px; }
.g-bar.done { background: color-mix(in srgb, var(--done) 30%, var(--surface)); border-color: var(--done); }
.g-bar.late { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, var(--surface)); }
.g-fill { position: absolute; inset: 0 auto 0 0; background: var(--primary); opacity: .55; }
.g-bar.done .g-fill { background: var(--done); }
.g-bar.late .g-fill { background: var(--danger); }
.g-bar em { position: relative; font-style: normal; font-size: 11px; font-weight: 700; padding-left: 6px; line-height: 20px; color: var(--text); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--primary); opacity: .6; z-index: 1; pointer-events: none; }
@media (max-width: 640px) { .gantt { --glabel: 130px; } }
.check-item { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; }
.check-item.ok { border-color: color-mix(in srgb, var(--done) 50%, var(--border)); }
.check-item.fail { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); background: color-mix(in srgb, var(--danger) 5%, var(--surface)); }
.check-item.na { opacity: .7; }
.mark { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 10px; font-weight: 700; cursor: pointer; font-size: 13px; }
.mark.ok.active { background: var(--done); border-color: var(--done); color: #fff; }
.mark.fail.active { background: var(--danger); border-color: var(--danger); color: #fff; }
.mark.na.active { background: var(--rejected); border-color: var(--rejected); color: #fff; }
.mark:disabled { cursor: default; }
.check-photo { max-width: 160px; border-radius: 8px; cursor: zoom-in; }

/* ---------- Phones: no sideways scrolling, no zoom on input focus, RTL ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }
img, video { max-width: 100%; }
.stage img { max-width: none; }
input, select, textarea { min-width: 0; max-width: 100%; }
.issue-main, .title-block, .kv > span:first-child { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .input, select.input, textarea.input, .list-tools .input { font-size: 16px; }
  .page { padding: 12px; }
  .list-tools .input[type=date] { flex: 1 1 130px; }
}
.lang-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
[dir=rtl] .gantt, [dir=rtl] .viewer, [dir=rtl] .mini-plan { direction: ltr; }
[dir=rtl] .gantt .g-label { direction: rtl; }
[dir=rtl] .btn.icon[title] svg, [dir=rtl] .topbar > .btn.ghost.icon:first-child svg { transform: scaleX(-1); }

/* ---------- Documents before the first shift ---------- */
.doc-step { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.doc-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface-2); flex: none; }
.doc-step.done .doc-num { background: var(--done); color: #fff; }
.doc-step.done b { color: var(--done); }
.contract-text { white-space: pre-wrap; max-height: 45dvh; overflow-y: auto; background: var(--surface-2); border-radius: 10px; padding: 12px; font-size: 14px; }
.doc-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.doc-row:hover { background: var(--surface-2); }
@media (max-width: 640px) { .doc-btn { width: 100%; } }

/* ---------- Tools and invoices ---------- */
.inv-row { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; }
.inv-row .row { flex-wrap: wrap; }

.brand img { width: 56px; height: 56px; border-radius: 50%; }
.brand.big { justify-content: center; }
.brand.big img { width: 180px; height: 180px; }

/* ==========================================================================
   «Прораб» look: the logo's night-site navy and safety orange.
   Navy chrome (header, menus) frames a calm light work area; orange is kept for
   the one thing to press. Motion: dialogs fly out of their button (app.js),
   presses squash a little, content slides in on tab change.
   ========================================================================== */
:root {
  --navy: #0b1626; --navy-2: #14243b; --navy-3: #1d3150;
  --orange: #ff9a1f; --orange-ink: #1c1205; --orange-deep: #c96a00;
  --bg: #f2f4f8; --surface: #ffffff; --surface-2: #edf0f5; --border: #dfe4ec;
  --text: #0f1a2b; --muted: #5a6880;
  --primary: var(--orange); --primary-ink: var(--orange-ink); --link: #b75f00;
  --radius: 16px;
  --shadow: 0 1px 1px rgba(11, 22, 38, .04), 0 2px 6px rgba(11, 22, 38, .05), 0 10px 28px rgba(11, 22, 38, .06);
  --shadow-lift: 0 2px 4px rgba(11, 22, 38, .06), 0 14px 40px rgba(11, 22, 38, .14);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --topbar: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08111e; --surface: #101c2e; --surface-2: #172740; --border: #22344f;
    --text: #e9eef6; --muted: #93a3ba; --link: #ffb04f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .4), 0 18px 48px rgba(0, 0, 0, .45);
  }
}
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: 'tnum' 0;
}
h1, h2, h3 { letter-spacing: -0.01em; }
.money, .stat b, .tile b, .pay-table td, .kv b { font-variant-numeric: tabular-nums; }
a { color: var(--link); }
.scroll, .issue-list, .drawer-body, .modal, .gantt, .table-wrap { scroll-behavior: smooth; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
::selection { background: color-mix(in srgb, var(--orange) 35%, transparent); }

/* ---- Header ---- */
.topbar { background: var(--navy); color: #fff; border-bottom: 0; box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 6px 18px rgba(11, 22, 38, .18); view-transition-name: topbar; }
.topbar h1 { color: #fff; font-weight: 750; }
.topbar .sub { color: #94a7c3; }
.topbar .btn { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .1); color: #fff; }
.topbar .btn:hover { background: rgba(255, 255, 255, .13); }
.topbar .btn.ghost { background: transparent; border-color: transparent; }
.topbar .btn.primary { background: var(--orange); border-color: var(--orange); color: var(--orange-ink); }
.topbar .avatar { background: var(--orange); color: var(--orange-ink); }

/* ---- Tabs: navy strip on wide screens, navy bottom bar on phones ---- */
.subnav { background: var(--navy-2); border-bottom: 0; padding: 6px 10px; gap: 2px; view-transition-name: subnav; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav button { color: #a9b8cf; border-radius: 10px; transition: color .2s ease, background-color .2s ease, transform .16s var(--ease-out); }
.subnav button:hover { color: #fff; }
.subnav button.active { background: rgba(255, 154, 31, .14); color: var(--orange); }
.subnav .nav-count { background: rgba(255, 255, 255, .1); color: #cdd8e8; }
.subnav .nav-count.alert { background: var(--orange); color: var(--orange-ink); }
@media (max-width: 640px) {
  .subnav { background: rgba(11, 22, 38, .96); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-top: 1px solid rgba(255, 255, 255, .06); box-shadow: 0 -8px 24px rgba(11, 22, 38, .22); padding-top: 6px; }
  .subnav button.active { background: transparent; }
  .subnav button.active .ico { background: rgba(255, 154, 31, .16); border-radius: 12px; box-shadow: 0 0 0 6px rgba(255, 154, 31, .16); }
}

/* ---- Buttons: one strong action color, a squash on press ---- */
.btn { border-radius: 12px; font-weight: 650; transition: transform .16s var(--ease-out), background-color .2s ease, box-shadow .2s ease, border-color .2s ease; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: var(--orange-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, 0 6px 16px rgba(255, 154, 31, .28); }
.btn.primary:hover { filter: none; background: #ffa73a; }
.btn.danger { color: var(--danger); }
.btn:active:not(:disabled), .chip:active, .subnav button:active, .issue-row:active, .card:active, .tile.clickable:active,
.attn:active, .doc-row:active, .member:active, .add-photo:active, .mark:active, .stat:active, .fab:active, .linkbtn:active, .menu button:active {
  transform: scale(0.97);
}
.chip { transition: transform .16s var(--ease-out), background-color .2s ease, border-color .2s ease, color .2s ease; }
.chip.active { border-color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, var(--surface)); color: var(--orange-deep); }
@media (prefers-color-scheme: dark) { .chip.active { color: var(--orange); } }
.input:focus { outline: 3px solid color-mix(in srgb, var(--orange) 30%, transparent); border-color: var(--orange); }
.input { transition: border-color .2s ease, box-shadow .2s ease; }

/* ---- Surfaces: elevation by shadow, structure by border ---- */
.card, .work-card, .tile, .issue-row, .member, .pending-row, .table-wrap, .gantt, .stat, .doc-row, .check-item, .inv-row {
  border-radius: var(--radius); border-color: var(--border);
}
.card, .issue-row, .tile.clickable, .attn, .member, .doc-row {
  transition: transform .18s var(--ease-out), box-shadow .25s ease, border-color .25s ease;
}
@media (hover: hover) and (pointer: fine) {
  .card:hover, .issue-row:hover, .tile.clickable:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); border-color: transparent; }
}
.card { box-shadow: var(--shadow); border-color: transparent; }
.card h3 { font-size: 17px; font-weight: 700; }
.work-card { box-shadow: var(--shadow); border-color: transparent; }
.tile { box-shadow: var(--shadow); border-color: transparent; }
.tile b { font-weight: 800; }
.issue-row { box-shadow: 0 1px 2px rgba(11, 22, 38, .04); }
.attn { border-radius: 14px; }
.badge { border-radius: 8px; padding: 3px 9px; }
.fab { background: var(--orange); color: var(--orange-ink); box-shadow: 0 10px 28px rgba(255, 154, 31, .4); transition: transform .16s var(--ease-out); }
.spinner { border-top-color: var(--orange); }
.thumb { border-radius: 12px; }

/* ---- Dialogs, drawers, menus (motion lives in app.js) ---- */
.overlay { background: rgba(6, 12, 22, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: none; }
.modal { border-radius: 22px; box-shadow: 0 30px 80px rgba(6, 12, 22, .35); animation: none; will-change: transform; }
.modal h2 { font-size: 20px; font-weight: 750; }
@media (max-width: 640px) { .modal { border-radius: 24px 24px 0 0; animation: none; } }
.drawer { border-radius: 22px 0 0 22px; box-shadow: -20px 0 60px rgba(6, 12, 22, .28); animation: drawer-in .38s var(--ease-out); }
[dir=rtl] .drawer { border-radius: 0 22px 22px 0; }
@media (max-width: 640px) { .drawer { border-radius: 0; } }
@keyframes drawer-in { from { transform: translateX(56px); opacity: 0; } }
[dir=rtl] .drawer { animation-name: drawer-in-rtl; }
@keyframes drawer-in-rtl { from { transform: translateX(-56px); opacity: 0; } }
.menu { border-radius: 16px; box-shadow: var(--shadow-lift); border-color: var(--border); transform-origin: top right; }
.more-menu { transform-origin: bottom right; }
.menu button { border-radius: 10px; transition: background-color .15s ease, transform .16s var(--ease-out); }
.toast { border-radius: 14px; background: var(--navy); color: #fff; box-shadow: var(--shadow-lift); animation: toast-in .32s var(--ease-out); }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(14px) scale(0.96); opacity: 0; } }
.lightbox { background: rgba(4, 9, 17, .92); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.lightbox img { border-radius: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }

/* ---- Login: the brand's night sky ---- */
.auth { background: radial-gradient(120% 80% at 50% 0%, #1b3558 0%, #0b1626 55%, #060c16 100%); }
.auth-card { border-radius: 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); animation: auth-in .6s var(--ease-out) both; }
@keyframes auth-in { from { transform: translateY(18px) scale(0.98); opacity: 0; } }
.brand.big img { box-shadow: 0 0 0 4px rgba(255, 154, 31, .25), 0 16px 40px rgba(255, 154, 31, .25); }

/* ---- Content arriving after a tab change: one short cascade, never blocking ---- */
.route-enter .page > *, .route-enter .cards > .card, .route-enter .issue-list > .issue-row,
.route-enter .stack > .issue-row, .route-enter .tiles > .tile, .route-enter .attn-list > .attn {
  animation: rise .42s var(--ease-out) both;
}
.route-enter .page > *:nth-child(2), .route-enter .cards > .card:nth-child(2), .route-enter .stack > .issue-row:nth-child(2),
.route-enter .tiles > .tile:nth-child(2), .route-enter .attn-list > .attn:nth-child(2), .route-enter .issue-list > .issue-row:nth-child(2) { animation-delay: 40ms; }
.route-enter .page > *:nth-child(3), .route-enter .cards > .card:nth-child(3), .route-enter .stack > .issue-row:nth-child(3),
.route-enter .tiles > .tile:nth-child(3), .route-enter .issue-list > .issue-row:nth-child(3) { animation-delay: 80ms; }
.route-enter .page > *:nth-child(4), .route-enter .cards > .card:nth-child(4), .route-enter .stack > .issue-row:nth-child(4),
.route-enter .tiles > .tile:nth-child(4), .route-enter .issue-list > .issue-row:nth-child(4) { animation-delay: 120ms; }
.route-enter .page > *:nth-child(n+5), .route-enter .cards > .card:nth-child(n+5), .route-enter .stack > .issue-row:nth-child(n+5),
.route-enter .tiles > .tile:nth-child(n+5), .route-enter .issue-list > .issue-row:nth-child(n+5) { animation-delay: 160ms; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* View transition between tabs: content crossfades, header and tab bar stay put. */
::view-transition-old(root) { animation: vt-out .18s ease-in both; }
::view-transition-new(root) { animation: vt-in .32s var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }
::view-transition-group(topbar), ::view-transition-group(subnav) { animation-duration: 0s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
