:root {
  --bg: #f5f7f7; --card: #fff; --text: #13201f; --muted: #5d6b6a; --line: #dfe5e4;
  --brand: #0f766e; --brand-2: #115e59; --ok: #15803d; --bad: #b91c1c; --warn: #b45309; --info: #1d4ed8;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1514; --card: #16201f; --text: #e6efee; --muted: #94a3a2; --line: #26332f; --brand: #2dd4bf; --brand-2: #5eead4; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", "Noto Sans Georgian", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.35rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); }
.brand span { color: var(--brand); }
#nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
#nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); }
#nav a.on { background: var(--bg); color: var(--text); font-weight: 600; }
.top-right { display: flex; gap: 8px; align-items: center; }

main { max-width: 1000px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 1.5rem; }
.list > a, .list > div { display: block; color: inherit; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
a.item:hover { border-color: var(--brand); }
dl.kv { display: grid; grid-template-columns: fit-content(45%) minmax(0, 1fr); gap: 4px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

button, .btn { font: inherit; border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 9px 14px;
  border-radius: 8px; cursor: pointer; min-height: 40px; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.small { padding: 4px 10px; min-height: 30px; }
button.ok { background: var(--ok); border-color: var(--ok); }
button.bad { background: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
.big { width: 100%; font-size: 1.05rem; min-height: 50px; }

form.stack { display: grid; gap: 10px; }
.fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; min-height: 40px; width: 100%; }
textarea { min-height: 70px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input[type=range] { padding: 0; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.s-assigned { color: var(--muted); }
.s-in_progress { color: var(--info); border-color: currentColor; }
.s-submitted { color: var(--warn); border-color: currentColor; }
.s-accepted, .s-paid { color: var(--ok); border-color: currentColor; }
.s-defect { color: var(--bad); border-color: currentColor; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--brand); }

.photos { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
.photos a { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--line); }
.photos img { width: 100%; height: 100%; object-fit: cover; }
.defect { border-left: 4px solid var(--bad); }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }
details > summary { cursor: pointer; color: var(--brand); padding: 4px 0; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px); z-index: 10; }
#toast.err { background: var(--bad); color: #fff; }
.login { max-width: 360px; margin: 10vh auto; }

@media (max-width: 600px) {
  .top { padding: 8px 12px; }
  #nav { order: 3; flex: 1 1 100%; overflow-x: auto; flex-wrap: nowrap; }
  #nav a { white-space: nowrap; }
  .top-right { margin-left: auto; }
  #who { display: none; }
  main { padding: 12px; }
}

/* service */
.s-trapped { color: #fff; background: var(--bad); border-color: var(--bad); }
.s-urgent, .s-open, .s-unpaid { color: var(--bad); border-color: currentColor; }
.s-scheduled, .s-paused { color: var(--info); border-color: currentColor; }
.s-resolved, .s-done { color: var(--ok); border-color: currentColor; }
.bad-text { color: var(--bad); }
a.btn.ghost-link { background: transparent; color: var(--text); border-color: var(--line); }
label.check { display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 10px; font-size: 1rem; padding: 4px 0; }
label.check span { flex: 1; min-width: 0; }
label.check input { width: 22px; height: 22px; flex: none; margin: 0; }
.sticker { display: grid; justify-items: center; gap: 6px; text-align: center; max-width: 220px; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; }
.sticker img { background: #fff; }
/* Orders: an A4-like sheet on white paper in both themes. */
.doc { background: #fff; color: #111; max-width: 760px; margin: 12px auto; padding: 40px 48px; border-radius: 6px; box-shadow: 0 1px 6px rgba(0,0,0,.2); font-size: 15px; line-height: 1.55; }
.doc header { text-align: center; border-bottom: 1px solid #111; padding-bottom: 8px; margin-bottom: 18px; }
.doc h2, .doc h3 { text-align: center; color: #111; margin: 8px 0; }
.doc .doc-row { display: flex; justify-content: space-between; margin-bottom: 12px; }
.doc .doc-order { font-weight: 700; margin: 14px 0 6px; }
.doc ol { padding-left: 22px; }
.doc li { margin-bottom: 6px; }
.doc .doc-sign { display: grid; grid-template-columns: minmax(0, 1fr) 160px minmax(0, 1fr); gap: 10px; align-items: end; margin-top: 28px; }
.doc .doc-sign .line { border-bottom: 1px solid #111; height: 1.2em; }
.doc-bi { max-width: 900px; font-family: Sylfaen, "Noto Sans Georgian", "Times New Roman", serif; font-size: 13.5px; line-height: 1.45; }
.doc-bi .bi { display: grid; grid-template-columns: 1fr 1fr; gap: 0 36px; margin-bottom: 8px; }
.doc-bi .bi.co { text-align: center; border-bottom: 1px solid #111; padding-bottom: 6px; margin-bottom: 16px; }
.doc-bi .bi.h1 { font-weight: 700; font-size: 1.1em; }
.doc-bi .bi.date { text-align: right; margin-bottom: 14px; }
.doc-bi .bi.h2 { font-weight: 700; text-align: center; margin: 4px 0 12px; }
.doc-bi .bi.name { font-weight: 700; font-size: 1.1em; margin: 10px 0 14px; }
.doc-bi .bi.p { text-align: justify; margin-top: 10px; }
.doc-bi .bi.b { font-weight: 700; }
.doc-bi .bi.gap { margin-top: 26px; }
.doc-bi .bi.sign > div { display: flex; align-items: flex-end; gap: 8px; margin-top: 14px; }
.doc-bi .fill { flex: 1; border-bottom: 1px solid #111; min-width: 100px; height: 1.1em; }
.doc-bi .bi.small { font-size: 12px; color: #444; margin-top: 18px; }
.doc-bi .kv2 { display: grid; grid-template-columns: 9.5em 1fr; gap: 8px; }
.doc-bi .kv2 > span:first-child { font-weight: 700; }
@media screen and (max-width: 640px) {
  .doc-bi .bi { grid-template-columns: 1fr; }
  .doc-bi .bi > div[lang="ru"] { color: #555; font-style: italic; margin-top: 2px; }
  .doc-bi .kv2 { grid-template-columns: 7.5em 1fr; }
}
@media (max-width: 600px) { .doc { padding: 20px 16px; font-size: 14px; } .doc .doc-sign { grid-template-columns: 1fr 90px 1fr; } }
@media print {
  body.print-doc * { visibility: hidden; }
  body.print-doc .doc, body.print-doc .doc * { visibility: visible; }
  body.print-doc .doc { position: absolute; left: 0; top: 0; margin: 0; box-shadow: none; max-width: none; width: 100%; padding: 0 10mm; }
  body.print-sticker * { visibility: hidden; }
  body.print-sticker .sticker, body.print-sticker .sticker * { visibility: visible; color: #000; }
  body.print-sticker .sticker { position: absolute; left: 0; top: 0; border: 2px solid #000; max-width: 70mm; }
}

/* sales ladder */
.btn.ghost-btn { background: transparent; color: var(--brand); }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs { margin: 6px 0 10px; }
.ladder { display: flex; gap: 4px; overflow-x: auto; margin: 8px 0 10px; padding-bottom: 2px; }
.ladder .step { flex: 1 0 auto; min-width: 82px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font-size: .8rem; min-height: 0; }
.ladder .step b { font-size: 1.1rem; }
.ladder .step.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.ladder .step.done { background: color-mix(in srgb, var(--brand) 14%, transparent); border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.ladder-project .step { min-width: 70px; padding: 6px 4px; cursor: default; }
.badge.ph-lead { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.badge.ph-sold { background: #dcfce7; color: #166534; border-color: #86efac; }
.badge.biz { background: #e0e7ff; color: #3730a3; border-color: #a5b4fc; }

/* document tree */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tree summary { cursor: pointer; padding: 4px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tree details details { margin-left: 18px; border-left: 1px dashed var(--line); padding-left: 10px; }
.tree > details { margin-left: 0; }
.tree .tree-phase.later > summary { opacity: .55; }
.tree .tree-folder { margin-left: 18px; border-left: 1px dashed var(--line); padding: 3px 0 3px 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tree .tree-folder.empty { opacity: .6; }
.tree .tree-file { margin-left: 18px; font-family: system-ui, sans-serif; }
.tree .tree-up { color: var(--brand); cursor: pointer; }
.ok-text { color: var(--ok); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.media { border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.media img:not(.qr-mini), .media video { width: 100%; max-height: 220px; object-fit: cover; border-radius: 6px; background: #000; }
.media a { overflow-wrap: anywhere; }
.qr-mini { width: 56px; height: 56px; flex: none; background: #fff; }
.qr-mini.big { width: 110px; height: 110px; }
.sig-img { height: 64px; max-width: 200px; object-fit: contain; vertical-align: middle; margin: 0 6px; }
