:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --ink: #1d211e;
  --muted: #6b716c;
  --line: #e1dfd8;
  --accent: #1f3d2b;
  --accent-ink: #ffffff;
  --accent-soft: #e3ece5;
  --ok: #2f7a45;
  --ok-soft: #dcefe1;
  --warn: #9a5b00;
  --warn-soft: #fbefd9;
  --danger: #b3261e;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141614; --surface: #1d201d; --ink: #e8eae6; --muted: #9aa29b; --line: #2e332f;
    --accent: #8cc79f; --accent-ink: #0f1a12; --accent-soft: #24332a;
    --ok: #8cc79f; --ok-soft: #1f3226; --warn: #f0b860; --warn-soft: #3a2e17; --danger: #f2a39d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--danger); }
.ok-text { color: var(--ok); margin-left: .5rem; }
.empty { color: var(--muted); padding: 1rem; text-align: center; }
.nowrap { white-space: nowrap; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; min-height: 2.5rem; max-width: 100%;
}
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: 10px; padding: .55rem 1rem; text-decoration: none; cursor: pointer; font-weight: 600; min-height: 2.5rem;
}
.btn-light { background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); font-weight: 500; }
.btn-sm { padding: .3rem .65rem; min-height: 2rem; font-size: .875rem; }
.btn-big { width: 100%; min-height: 3.5rem; font-size: 1.1rem; margin-top: .75rem; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0 .25rem; }

.center-box { max-width: 380px; margin: 12vh auto; padding: 1.5rem; }
.stack { display: grid; gap: .6rem; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 6px; font-size: .8rem; background: var(--accent-soft); white-space: nowrap; }
.b-dismantled { background: var(--warn-soft); color: var(--warn); }
.b-inactive { background: var(--line); color: var(--muted); }
.b-docs { background: #e6eaf6; color: #34436e; }
@media (prefers-color-scheme: dark) { .b-docs { background: #252c40; color: #b8c4ea; } }

/* ---------------- водитель ---------------- */
.driver { padding-bottom: env(safe-area-inset-bottom); }
.d-head { background: var(--accent); color: var(--accent-ink); padding: calc(.75rem + env(safe-area-inset-top)) 1rem .9rem; position: sticky; top: 0; z-index: 5; }
.d-head .back { color: inherit; opacity: .85; text-decoration: none; font-size: .95rem; display: inline-block; padding: .2rem 0 .3rem; }
.d-title { font-size: 1.25rem; font-weight: 700; line-height: 1.25; }
.d-sub { font-size: .85rem; opacity: .8; margin-top: .15rem; }
.d-main { max-width: 640px; margin: 0 auto; padding: .75rem; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.row {
  display: flex; align-items: center; gap: .75rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .85rem .9rem; color: inherit; text-decoration: none; min-height: 3.5rem;
}
.row:active { background: var(--accent-soft); }
.row.done { border-color: var(--ok); }
.row-main { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.row-side { flex: none; }
.num { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; font-size: .85rem; font-weight: 700; }
.row.done .num { background: var(--ok); color: #fff; }
.addr { font-weight: 600; }
.meta { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .1rem .6rem; }
.warn { color: var(--warn); font-weight: 600; }
.hint { color: var(--muted); font-size: .85rem; margin: 1.25rem .25rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; }
.card h2 { margin-top: 0; }
.card .note { white-space: pre-line; font-size: .95rem; }
.task { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: .5rem .7rem; font-weight: 600; }
.links a { font-size: .95rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .state {
  position: absolute; inset: auto 0 0 0; padding: .2rem .35rem; font-size: .75rem; font-weight: 600;
  background: rgba(0,0,0,.55); color: #fff; text-align: center;
}
.tile.done .state { display: none; }
.tile.failed .state { background: var(--danger); }
.tile .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--ok); transition: width .2s; }
.tile .del {
  position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 18px; line-height: 30px; cursor: pointer; padding: 0;
}
.status { min-height: 1.4em; font-size: .9rem; color: var(--muted); margin: .5rem 0 0; }
.status.pending { color: var(--warn); font-weight: 600; }
.comment-form { display: grid; gap: .5rem; }
.comment-form label { font-weight: 600; font-size: .95rem; }
.next-nav { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 1rem 0 2rem; }
.next-nav .btn { min-height: 3rem; }

/* ---------------- админка ---------------- */
.a-head { display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.a-head .brand { font-weight: 800; text-decoration: none; color: var(--ink); }
.a-head nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.a-head nav a { text-decoration: none; color: var(--muted); padding: .35rem .7rem; border-radius: 8px; }
.a-head nav a.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.a-main { max-width: 1240px; margin: 0 auto; padding: 1.25rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.back { text-decoration: none; color: var(--muted); }
.meta-line { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; color: var(--muted); }
.note { white-space: pre-line; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .5rem 0; }
.filters input[type=search] { flex: 1 1 260px; }
.filters .reset { color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table th, .table td { padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.clickable tbody tr { cursor: pointer; }
.table.clickable tbody tr:hover { background: var(--accent-soft); }
.table a { text-decoration: none; }
.st-dismantled td, .st-inactive td { color: var(--muted); }
.table input:not([type=checkbox]), .table select { min-height: 2.1rem; padding: .3rem .5rem; }
.w-num { width: 5em; }
.link-cell { display: flex; gap: .4rem; align-items: center; }
.link-cell input { flex: 1; min-width: 220px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
form.inline { display: inline-flex; gap: .3rem; align-items: center; margin: 0; }
.add-form { margin-top: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem 1rem; max-width: 900px; }
.form-grid label { display: grid; gap: .3rem; font-size: .9rem; font-weight: 600; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .check { display: flex; align-items: center; gap: .5rem; align-self: end; min-height: 2.5rem; }
.form-grid input, .form-grid select { width: 100%; font-weight: 400; }
.form-grid textarea { font-weight: 400; }
.form-actions { margin-top: .25rem; }

.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .9rem; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.report + .report { border-top: 1px dashed var(--line); padding-top: .6rem; margin-top: .6rem; }
.report-meta { margin: 0 0 .5rem; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.thumb { margin: 0; }
.thumb > a { display: block; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s; }
.thumb > a:hover img { transform: scale(1.03); }
.thumb figcaption { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: .25rem; }

.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 9, .94); display: grid; grid-template-rows: 1fr auto; place-items: center; }
.viewer[hidden] { display: none; }
.viewer img { max-width: 96vw; max-height: calc(100vh - 70px); object-fit: contain; user-select: none; -webkit-user-drag: none; }
.viewer button { position: absolute; background: rgba(255,255,255,.1); color: #fff; border: 0; cursor: pointer; border-radius: 50%; width: 48px; height: 48px; font-size: 30px; line-height: 1; }
.viewer button:hover { background: rgba(255,255,255,.22); }
.v-close { top: 12px; right: 12px; }
.v-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.v-next { right: 12px; top: 50%; transform: translateY(-50%); }
.v-bar { width: 100%; display: flex; gap: 1rem; align-items: center; justify-content: center; padding: .6rem 1rem; color: #ddd; font-size: .9rem; flex-wrap: wrap; }
.v-bar .btn { background: #fff; color: #111; border-color: #fff; }
@media (max-width: 600px) {
  .a-main { padding: .75rem; }
  .viewer .v-prev, .viewer .v-next { display: none; }
}
