:root {
  --bg: #f4f6f9; --card: #fff; --text: #1b2430; --muted: #6b7686; --line: #e2e7ee;
  --brand: #1F5E56; --brand-2: #2a7a6f; --ok: #1f8a57; --ok-bg: #e5f5ec; --warn: #a86400; --warn-bg: #fff3dc;
  --bad: #c0392b; --bad-bg: #fde9e7; --info-bg: #e8f0fb; --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body.manager { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.manager input, body.manager textarea { -webkit-user-select: text; user-select: text; }
button, input, select, textarea { font: inherit; color: inherit; }
.center { min-height: 60vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* шапка и вкладки */
.top { position: sticky; top: 0; z-index: 5; background: var(--brand); color: #fff; padding: calc(env(safe-area-inset-top) + 10px) 16px 0; }
.top-row { display: flex; align-items: center; gap: 12px; max-width: 1100px; margin: 0 auto; }
.top h1 { font-size: 18px; margin: 0; flex: 1; }
.top .who { font-size: 13px; opacity: .85; }
.link-btn { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 4px; font-size: 14px; }
.tabs { display: flex; gap: 4px; max-width: 1100px; margin: 8px auto 0; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; color: rgba(255,255,255,.75); padding: 10px 12px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; font-size: 15px; }
.tabs button.on { color: #fff; border-color: #fff; font-weight: 600; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #e74c3c; color: #fff; font-size: 12px; line-height: 18px; text-align: center; margin-left: 4px; }

main { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px); }
.narrow { max-width: 560px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }

/* формы */
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid #cfd6e0; border-radius: 10px; background: #fff; font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px;
  padding: 12px 18px; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; padding: 15px; font-size: 17px; }
.btn.light { background: var(--info-bg); color: var(--brand); }
.btn.ok { background: var(--ok); }
.btn.bad { background: var(--bad); }
.btn.sm { padding: 8px 12px; font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1; }
.err { color: var(--bad); font-size: 14px; margin: 8px 0; }

/* фото */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 10px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #e9edf2; display: grid; place-items: center; font-size: 13px; color: var(--muted); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .x { 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: 16px; line-height: 26px; padding: 0; }

/* статусы */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.new { background: var(--info-bg); color: var(--brand-2); }
.chip.checked, .chip.sent { background: var(--ok-bg); color: var(--ok); }
.chip.rejected, .chip.error, .chip.order_not_found { background: var(--bad-bg); color: var(--bad); }
.chip.pending, .chip.queued { background: var(--warn-bg); color: var(--warn); }
.chip.disabled { background: #eef0f3; color: var(--muted); }

.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.banner { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.info { background: var(--info-bg); color: var(--brand); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }

/* админ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.stat b { display: block; font-size: 22px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.filters input, .filters select { padding: 9px 10px; font-size: 15px; }
.rc { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.rc:hover { border-color: var(--brand-2); }
.rc .sum { font-weight: 700; font-size: 17px; text-align: right; }
.rc .meta { font-size: 13px; color: var(--muted); }
.total { text-align: right; color: var(--muted); font-size: 14px; margin: 4px 0 10px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t td, table.t th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* окно */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(15, 23, 35, .55); display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); }
@media (min-width: 760px) { .modal { align-items: center; } .modal .sheet { border-radius: 18px; } }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; }
.viewer { display: grid; gap: 10px; }
.viewer img { width: 100%; border-radius: 10px; background: #fff; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 15px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

/* чат */
.chat { display: flex; flex-direction: column; gap: 8px; min-height: 200px; max-height: 60vh; overflow-y: auto; padding: 4px 0 8px; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg.mine { align-self: flex-end; background: var(--brand); color: #fff; border-color: var(--brand); }
.msg .t { font-size: 11px; opacity: .7; margin-top: 3px; }
.chat-form { display: flex; gap: 8px; }
.chat-form textarea { min-height: 46px; height: 46px; }
.threads .list-item { cursor: pointer; }
.threads .list-item.on { background: var(--info-bg); border-radius: 10px; padding-left: 8px; }

/* водяной знак */
.wm { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; opacity: .07; }
.wm div { position: absolute; left: -50%; width: 200%; transform: rotate(-28deg); white-space: nowrap; font-size: 18px; font-weight: 700; color: #000; letter-spacing: 2px; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%); z-index: 40;
  background: #1b2430; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.login { max-width: 380px; margin: 10vh auto 0; padding: 0 16px; }
.login .logo { width: 72px; height: 72px; margin: 0 auto 12px; display: block; }
.login h1 { text-align: center; font-size: 22px; margin: 0 0 4px; }
.success { text-align: center; padding: 28px 12px; }
.success .big { font-size: 54px; line-height: 1; }

/* ===== DaVinci Home: разделы ===== */
header.top .brand { height: 30px; width: auto; margin-right: auto; background: #fff; border-radius: 6px; padding: 2px 6px; }
.login .logo-wide { display: block; width: min(280px, 80%); margin: 0 auto 8px; }
.sections { display: flex; gap: 6px; max-width: 1100px; margin: 10px auto 0; }
.sections button { flex: 1; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 10px; padding: 9px 10px; font-size: 15px; font-weight: 600; cursor: pointer; position: relative; }
.sections button.on { background: #fff; color: var(--brand); }
.sections .badge { margin-left: 6px; }
.calc-frame { position: fixed; left: 0; right: 0; bottom: 0; top: 120px; width: 100%; border: 0; background: #F3F4F1; z-index: 5; }
body.in-calc { overflow: hidden; }
body.in-calc .wm { display: none; }
body.in-calc header.top { padding-bottom: 10px; }
