:root {
  --bg: #f3f5f4;
  --card: #ffffff;
  --text: #15201d;
  --muted: #5f6d69;
  --line: #dfe5e3;
  --field: #f7f9f8;
  --accent: #0e6b5c;
  --accent-soft: #e2f1ed;
  --accent-text: #ffffff;
  --error: #c0392b;
  --error-soft: #fbeceA;
  --warn: #a86a00;
  --warn-soft: #fbf1df;
  --info: #2c62a8;
  --info-soft: #e8eff9;
  --module-base: #dcebe6;
  --module-upper: #eef5f2;
  --module-appliance: #dde3ea;
  --module-line: #3d5a52;
  --shadow: 0 1px 2px rgba(16, 32, 28, .06), 0 4px 16px rgba(16, 32, 28, .05);
  --radius: 14px;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1514;
    --card: #172120;
    --text: #e7efec;
    --muted: #93a39e;
    --line: #26332f;
    --field: #111a18;
    --accent: #3fb89f;
    --accent-soft: #173a33;
    --accent-text: #06201b;
    --error: #f08a7d;
    --error-soft: #3a1f1c;
    --warn: #e8b45a;
    --warn-soft: #3a2e17;
    --info: #8db5ef;
    --info-soft: #1b2a3e;
    --module-base: #23423a;
    --module-upper: #1c302b;
    --module-appliance: #273340;
    --module-line: #9cc7bb;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 20px; line-height: 1.25; margin: 0 0 14px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

.icon { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }
.icon-lg { width: 32px; height: 32px; }
.icon-xl { width: 44px; height: 44px; }
.icon-logo { width: 26px; height: 26px; color: var(--accent); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; margin-right: auto; }
.topbar-user { color: var(--muted); font-size: 13px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page { padding: 16px; max-width: 1480px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-icon { padding: 8px; min-width: 40px; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 16px; }
.btn-small { min-height: 32px; padding: 4px 8px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--muted); }
.field input, .field select, .table input, .table select, .tall-row select, .tall-row input {
  width: 100%; min-width: 0; min-height: 40px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--field); color: var(--text);
  padding: 8px 10px; font: inherit; font-size: 16px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 10px; align-items: center; margin: 4px 0 12px; min-height: 32px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form-error { color: var(--error); margin: 8px 0 0; font-size: 14px; }

.login-page .page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; }
.login-wrap { width: 100%; max-width: 400px; }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-logo { display: inline-flex; padding: 14px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; }
.login-brand h1 { font-size: 26px; margin-bottom: 6px; }
.login-brand p { color: var(--muted); margin: 0; }
.login-card { padding: 22px; }
.login-form { margin-top: 14px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.tg-wait { display: flex; gap: 12px; margin-top: 14px; padding: 12px; border-radius: 12px; background: var(--accent-soft); }
.tg-wait p { margin: 4px 0 6px; }
.link { font-size: 13px; }
.spinner { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.projects-layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 18px; align-items: start; }
.section-title { margin: 4px 0 12px; }
.shape-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.shape-option {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  color: var(--muted); font-size: 13px; background: var(--field);
}
.shape-option input { position: absolute; opacity: 0; pointer-events: none; }
.shape-option:has(input:checked) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.shape-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.project-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); text-decoration: none; color: var(--text); position: relative; }
.project-card:hover { border-color: var(--accent); }
.project-card strong { font-size: 16px; padding-right: 40px; overflow-wrap: anywhere; }
.project-card .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.project-card .delete { position: absolute; top: 8px; right: 8px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }

.badge { display: inline-flex; align-items: center; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--field); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge-warn { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.badge-accent { color: var(--accent); border-color: transparent; background: var(--accent-soft); }

.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.table-compact td { padding: 6px 8px; font-size: 13px; }
.table input { width: 90px; min-height: 34px; padding: 4px 8px; font-size: 14px; }
.table select { width: auto; min-height: 34px; padding: 4px 8px; font-size: 14px; }
#modules-table tr { cursor: pointer; }
#modules-table tr.selected td { background: var(--accent-soft); }

.project-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.project-title { display: flex; align-items: center; gap: 8px; margin-right: auto; min-width: 0; flex-wrap: wrap; }
.project-title h1 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.project-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.params { position: sticky; top: 76px; max-height: calc(100dvh - 92px); overflow-y: auto; }
.params fieldset { border: 0; border-top: 1px solid var(--line); padding: 14px 0 2px; margin: 0; }
.params fieldset:first-child { border-top: 0; padding-top: 0; }
.params legend { font-weight: 600; padding: 0; margin-bottom: 10px; }
.tall-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.tall-row { display: grid; grid-template-columns: 1fr 1fr 1fr 76px 40px; gap: 6px; }
.tall-row select, .tall-row input { font-size: 14px; padding: 6px; }

.warnings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.warnings li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--info-soft); color: var(--text); font-size: 14px; }
.warnings li .icon { color: var(--info); }
.warnings li.error { background: var(--error-soft); }
.warnings li.error .icon { color: var(--error); }
.warnings li.warn { background: var(--warn-soft); }
.warnings li.warn .icon { color: var(--warn); }
.warnings li.ok { background: var(--accent-soft); }
.warnings li.ok .icon { color: var(--accent); }

.elevations { display: flex; flex-direction: column; gap: 18px; }
.elevation-title { font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.elevation svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
.elevation rect[data-module] { cursor: pointer; }
.elevation .m-base { fill: var(--module-base); stroke: var(--module-line); }
.elevation .m-upper { fill: var(--module-upper); stroke: var(--module-line); }
.elevation .m-app { fill: var(--module-appliance); stroke: var(--module-line); }
.elevation .m-counter { fill: var(--module-line); }
.elevation .m-floor { stroke: var(--muted); }
.elevation .m-label { fill: var(--text); font-size: 34px; text-anchor: middle; font-family: inherit; }
.elevation .m-dim { fill: var(--muted); font-size: 30px; text-anchor: middle; font-family: inherit; }
.elevation .m-selected { stroke: var(--accent); stroke-width: 10; }

.tabbar { display: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; }

@media (max-width: 1100px) {
  .projects-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .page { padding: 12px; }
  .project { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
  .project-grid { grid-template-columns: 1fr; gap: 0; }
  .params { position: static; max-height: none; overflow: visible; }
  .tab-pane:not(.tab-active) { display: none; }
  .btn-label { display: none; }
  .project-head { position: sticky; top: 57px; z-index: 15; background: var(--bg); padding: 6px 0; margin: -6px 0 8px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--card); border-top: 1px solid var(--line);
  }
  .tab {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer;
  }
  .tab.active { color: var(--accent); }
  .tab.active::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .tab-dot { position: absolute; top: 10px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--error); }
  .topbar-user { display: none; }
  .toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }
}

@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .tall-row { grid-template-columns: 1fr 1fr; }
}

.viewer-card { padding: 0; overflow: hidden; }
.viewer { position: relative; height: clamp(360px, 58vh, 640px); background: var(--field); }
.viewer-stage { position: absolute; inset: 0; }
.viewer-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.viewer-toolbar {
  position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; align-items: center;
  padding: 4px; border-radius: 12px; background: color-mix(in srgb, var(--card) 88%, transparent);
  border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
.vbtn {
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 9px; background: transparent; color: var(--text); cursor: pointer;
}
.vbtn:hover { background: var(--field); }
.vbtn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.vbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.vsep { width: 1px; height: 24px; background: var(--line); margin: 0 2px; }
.viewer-hint {
  position: absolute; left: 12px; bottom: 10px; margin: 0; font-size: 12px; color: var(--muted);
  background: color-mix(in srgb, var(--card) 80%, transparent); padding: 4px 8px; border-radius: 8px; pointer-events: none;
}
.viewer-loading, .viewer-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted);
}
.viewer-fallback { display: none; padding: 24px; text-align: center; }
.viewer-ready .viewer-loading { display: none; }
.viewer-unsupported .viewer-loading, .viewer-unsupported .viewer-toolbar, .viewer-unsupported .viewer-hint { display: none; }
.viewer-unsupported .viewer-fallback { display: flex; }
.viewer.viewer-max { position: fixed; inset: 0; z-index: 60; height: 100dvh; border-radius: 0; }
.viewer.viewer-max .viewer-toolbar { top: max(12px, env(safe-area-inset-top)); }
body.viewer-lock { overflow: hidden; }

.swatch-group { margin-bottom: 12px; }
.swatch-title { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35); background-size: cover;
}
.swatch[aria-checked="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch-name { font-size: 12px; color: var(--muted); margin-top: 4px; min-height: 16px; }

@media (max-width: 900px) {
  .viewer-card { margin-left: -12px; margin-right: -12px; border-radius: 0; border-left: 0; border-right: 0; }
  .viewer { height: 62vh; }
  .viewer-hint { display: none; }
  .viewer-toolbar { top: 8px; right: 8px; }
}

.viewer-label {
  position: absolute; transform: translateX(-50%); pointer-events: none; white-space: nowrap; z-index: 5;
  background: var(--text); color: var(--bg); font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 8px;
  box-shadow: var(--shadow); max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis;
}
.viewer-label.error { background: var(--error); color: #fff; }

.module-panel { padding: 12px 16px 14px; border-top: 1px solid var(--line); background: var(--card); }
body.viewer-lock .module-panel {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 61;
  width: min(560px, calc(100% - 24px)); max-height: 46vh; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.mp-head { display: flex; align-items: center; gap: 8px; }
.mp-title { display: flex; align-items: baseline; gap: 8px; margin-right: auto; min-width: 0; }
.mp-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-title span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.mp-kinds { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: thin; }
.kind-chip {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 64px;
  padding: 7px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--field);
  color: var(--muted); font: inherit; font-size: 11px; cursor: pointer;
}
.kind-chip .icon { width: 24px; height: 24px; }
.kind-chip[aria-checked="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.kind-chip:disabled { opacity: .4; cursor: default; }
.mp-count { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 0; font-size: 13px; color: var(--muted); }
.mp-count:empty { display: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--field); color: var(--text); min-width: 40px; min-height: 34px; font: inherit; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.mp-actions { display: flex; gap: 6px; padding-top: 8px; }
.mp-actions #mp-add { flex: 1; }
.btn-danger { color: var(--error); }
.btn-danger:hover { border-color: var(--error); }
.mp-addbox { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.mp-addbox p { margin: 0; }
.mp-note { margin: 8px 0 0; font-size: 13px; color: var(--warn); }
.viewer-drop {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 5; pointer-events: none;
  background: var(--accent); color: var(--accent-text); padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 600;
}

@media (max-width: 900px) {
  .module-panel { padding: 10px 12px 12px; }
}

.viewer, .viewer *, .module-panel, .module-panel *, .tabbar, .tabbar *, .btn, .vbtn, .kind-chip, .seg button, .swatch, .shape-option {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.viewer-stage canvas { -webkit-user-drag: none; }

.topnav { display: flex; gap: 4px; margin-left: 8px; }
.topnav a {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px; max-width: 220px;
}
.topnav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topnav a:hover { background: var(--field); color: var(--text); }
.topnav a.active { background: var(--accent-soft); color: var(--accent); }
.appnav { display: none; }

.narrow { max-width: 760px; margin: 0 auto; }
.profile-card { display: flex; align-items: center; gap: 14px; }
.profile-card.compact { margin-bottom: 8px; }
.profile-card h1 { margin: 0 0 2px; }
.profile-card p { margin: 0; }
.avatar { width: 56px; height: 56px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.kpi-title { font-size: 12px; color: var(--muted); }
.kpi strong { font-size: 18px; letter-spacing: -.01em; }
.kpi-warn strong { color: var(--warn); }
.kpi-ok strong { color: var(--accent); }
.link-list { display: flex; flex-direction: column; }
.link-list.card { padding: 6px 8px; }
.link-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 10px; text-decoration: none;
  color: var(--text); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; width: 100%;
}
.link-row:hover { background: var(--field); }
.link-row > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row .chev { color: var(--muted); width: 18px; height: 18px; }
.link-row.danger { color: var(--error); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-only { display: none; }

.customers-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); margin-bottom: 10px; }
.search-box .icon { color: var(--muted); }
.search-box input { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; padding: 11px 0; outline: none; min-width: 0; }
.stage-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: thin; }
.stage-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.stage-chip b { font-weight: 600; color: var(--text); }
.stage-chip[aria-selected="true"], .stage-chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.stage-chip[aria-selected="true"] b, .stage-chip[aria-checked="true"] b { color: var(--accent-text); }
.customer-list { display: flex; flex-direction: column; gap: 8px; }
.customer-card {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
.customer-card:hover { border-color: var(--accent); }
.cc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cc-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-card .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.customer-card .call { color: var(--accent); }
.debt { color: var(--warn); font-weight: 600; }
.stage-badge.stage-new { color: var(--info); background: var(--info-soft); border-color: transparent; }
.stage-badge.stage-measure, .stage-badge.stage-offer { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.stage-badge.stage-agreed, .stage-badge.stage-production { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.stage-badge.stage-lost { color: var(--error); background: var(--error-soft); border-color: transparent; }

.contact-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.contact-actions .btn { flex: 1; }
.contact-line { margin: 0 0 6px; }
.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input, .pay-form input, .pay-form select, textarea {
  border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--text);
  padding: 8px 10px; font: inherit; font-size: 16px; min-height: 40px; min-width: 0;
}
.inline-form input { flex: 1; }
textarea { width: 100%; resize: vertical; }
.pay-form { display: grid; grid-template-columns: 130px 1fr 150px 1fr auto; gap: 8px; margin-bottom: 10px; }
.neg { color: var(--error); }
.rem-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rem { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--field); }
.rem .icon { color: var(--accent); }
.rem-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rem-done, .rem-cancelled { opacity: .55; }
.rem-sent .icon { color: var(--warn); }

@media (max-width: 1100px) {
  .customers-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .topnav { display: none; }
  .mobile-only { display: block; }
  .tab-pane.mobile-only:not(.tab-active) { display: none; }
  .page.with-appnav { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .appnav {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--card); border-top: 1px solid var(--line);
  }
  .appnav a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); text-decoration: none; font-size: 11px;
  }
  .appnav a.active { color: var(--accent); }
  .appnav a.active::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .pay-form { grid-template-columns: 1fr 1fr; }
  .pay-form button { grid-column: 1 / -1; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
.pay-form.rem-form { grid-template-columns: 1fr 160px 120px auto; }
@media (max-width: 900px) {
  .pay-form.rem-form { grid-template-columns: 1fr 1fr; }
  .pay-form.rem-form input[name="text"] { grid-column: 1 / -1; }
}
.customers-layout > *, .projects-layout > *, .narrow > * { min-width: 0; }
@media (max-width: 1100px) {
  .customers-layout, .projects-layout { grid-template-columns: minmax(0, 1fr); }
}
