:root {
  --bg: #f3f4f6; --card: #fff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #f97316; --accent-2: #ea580c; --blue: #2563eb; --green: #16a34a; --red: #dc2626; --amber: #d97706;
  --radius: 14px; --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --card: #1a1d24; --text: #f3f4f6; --muted: #9ca3af; --line: #2a2e37; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
body { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px); }
body.no-nav { padding-bottom: 24px; }
a { color: var(--blue); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.wrapflex { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 14px 8px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
.top .inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.top .title { font-weight: 700; font-size: 19px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { font-size: 26px; line-height: 1; padding: 0 6px 0 0; color: var(--text); background: none; border: 0; cursor: pointer; }

/* карточки и плитки */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; border: 1px solid var(--line); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 19px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile.hl { border-color: var(--accent); }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); }

/* списки */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.item:first-child { border-top: 0; }
.item:active { background: rgba(127,127,127,.08); }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item .amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; flex: none; }
.k-work { background: #dbeafe; } .k-material { background: #fef3c7; } .k-expense { background: #fee2e2; } .k-payment { background: #dcfce7; }
@media (prefers-color-scheme: dark) {
  .k-work { background: #1e3a5f; } .k-material { background: #4a3a12; } .k-expense { background: #4c1d1d; } .k-payment { background: #14432a; }
}
.empty { padding: 28px 14px; text-align: center; color: var(--muted); }
.daysep { font-size: 12px; color: var(--muted); padding: 8px 14px 4px; background: var(--bg); text-transform: capitalize; }

/* бейджи */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; vertical-align: middle; }
.b-pending { background: #fef3c7; color: #92400e; }
.b-confirmed { background: #dcfce7; color: #166534; }
.b-disputed { background: #fee2e2; color: #991b1b; }
.b-gray { background: var(--line); color: var(--muted); }

/* кнопки */
.btn { appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600;
  background: var(--accent); color: #fff; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.btn:active { background: var(--accent-2); }
.btn.sec { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--blue); padding: 8px 10px; }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--line); }
.btn.green { background: var(--green); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.act { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 4px; text-align: center;
  font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text); }
.act .ico { margin: 0 auto 6px; }
.fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 30px; border: 0; box-shadow: 0 6px 20px rgba(0,0,0,.25); cursor: pointer; z-index: 6; }

/* чипы-фильтры */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; scrollbar-width: none; }
.chip { flex: none; padding: 7px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 13px; cursor: pointer; color: var(--text); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* нижнее меню */
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--line); display: flex; z-index: 7; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--muted); }
.nav a .i { font-size: 21px; filter: grayscale(1); opacity: .7; }
.nav a.on { color: var(--accent); }
.nav a.on .i { filter: none; opacity: 1; }

/* формы */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 0.7fr 1fr; gap: 10px; }
.err { color: var(--red); font-size: 14px; margin: 8px 0; min-height: 1em; }

/* шторка */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s; }
.sheet { background: var(--card); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + var(--safe-b)); animation: up .2s ease-out; }
@media (min-width: 700px) { .backdrop { align-items: center; } .sheet { border-radius: 18px; } }
.sheet .hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet .hd b { font-size: 18px; }
.x { background: var(--line); border: 0; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; cursor: pointer; color: var(--text); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* фото */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.thumb { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.thumb .del { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; cursor: pointer; }
.viewer { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.92); display: grid; place-items: center; }
.viewer img { max-width: 100vw; max-height: 100vh; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 20px); transform: translateX(-50%); z-index: 50;
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; animation: up .2s; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 360px; padding: 24px; }
.logo { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 28px; font-weight: 800; margin-bottom: 14px; }

.note { background: #fff7ed; color: #9a3412; border-radius: 12px; padding: 12px 14px; margin: 10px 0; font-size: 14px; }
@media (prefers-color-scheme: dark) { .note { background: #3b2410; color: #fdba74; } }
.comment { font-size: 13px; margin-top: 4px; color: var(--red); }

/* печать отчёта */
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; padding: 0; font-size: 12px; }
  .no-print, .nav, .fab, .top { display: none !important; }
  .print-only { display: block; }
  .screen-only { display: none !important; }
  table.rep { width: 100%; border-collapse: collapse; margin-top: 10px; }
  table.rep th, table.rep td { border: 1px solid #999; padding: 4px 6px; text-align: left; vertical-align: top; }
  table.rep td.n, table.rep th.n { text-align: right; white-space: nowrap; }
  .rep-h { display: flex; justify-content: space-between; align-items: flex-start; }
  .sign { margin-top: 40px; display: flex; justify-content: space-between; gap: 40px; }
  .sign div { flex: 1; border-top: 1px solid #000; padding-top: 4px; }
  @page { margin: 14mm; }
}
