:root {
  color-scheme: light dark;
  --bg: #0c1219;
  --panel: #141c28;
  --panel2: #1a2433;
  --border: #2a384c;
  --text: #e8eef6;
  --muted: #8fa3bb;
  --accent: #4da3ff;
  --ok: #3ddc84;
  --notice: #7ecbff;
  --warn: #ffb020;
  --critical: #ff8c42;
  --err: #ff5d6c;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  overflow: hidden;
}
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

body.mode-login {
  overflow: auto;
}

body.mode-login #login-screen { display: grid; }
body.mode-login #app-root { display: none !important; }
body.mode-app #login-screen { display: none !important; }
body.mode-app #app-root {
  display: flex;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

#login-screen[hidden],
#app-root[hidden] {
  display: none !important;
}

.app {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.brand { font-size: 1.1rem; font-weight: 700; padding: 0 10px 12px; }
.brand small { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 500; }

.nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  border: none; background: transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font: inherit;
}
.nav-btn:hover { background: rgba(77,163,255,.08); color: var(--text); }
.nav-btn.active { background: rgba(77,163,255,.16); color: var(--accent); font-weight: 600; }

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 20px 12px;
  overflow: hidden;
}

.view { display: none; }
.view.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
}

#view-dashboard.view.active,
#view-profile.view.active,
#view-orders.view.active,
#view-tasks.view.active,
#view-sync.view.active {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

#view-sync.view.active {
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

#view-sync .panel {
  overflow: visible;
  flex-shrink: 0;
}

#view-sync .panel .table-wrap {
  max-height: none;
  overflow: visible;
}

#view-sync .sync-hint,
#view-sync .sync-request-status {
  flex-shrink: 0;
}

#view-sync #sync-requests-panel {
  margin-top: 12px;
  margin-bottom: 8px;
}

#view-registers.view.active,
#view-expiries.view.active,
#view-clients.view.active,
#view-nomenclature.view.active,
#view-notifications.view.active {
  overflow: hidden;
}

#view-registers.view.active h1,
#view-expiries.view.active h1 {
  margin-bottom: 2px;
}

#view-registers.view.active .subtitle,
#view-expiries.view.active .subtitle {
  margin-bottom: 10px;
}

#view-registers.view.active .toolbar,
#view-expiries.view.active .toolbar,
#view-clients.view.active .toolbar {
  margin-bottom: 10px;
  flex-shrink: 0;
}

#view-registers.view.active .panel,
#view-expiries.view.active .panel,
#view-clients.view.active .panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#view-registers.view.active .table-wrap,
#view-expiries.view.active .table-wrap,
#view-clients.view.active .table-wrap {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

#view-clients.view.active h1,
#view-clients.view.active .subtitle {
  flex-shrink: 0;
}

#view-clients.view.active .clients-panel.active {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#view-clients.view.active .pager,
#view-clients.view.active .pipeline-toolbar {
  flex-shrink: 0;
}

#view-clients.view.active {
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

#view-clients.view.active .pager {
  margin-top: 8px;
  padding-bottom: 4px;
}

#view-clients.view.active .pipeline-board {
  flex: 1;
  min-height: 0;
  max-height: none;
}

h1 { margin: 0 0 4px; font-size: 1.45rem; }
.subtitle { color: var(--muted); margin-bottom: 14px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.card .label { color: var(--muted); font-size: 0.82rem; }
.card .value { font-size: 1.4rem; font-weight: 700; margin-top: 4px; }
.card.err .value { color: var(--err); }
.card.critical .value { color: var(--critical); }
.card.warn .value { color: var(--warn); }
.card.ok .value { color: var(--ok); }
.card.clickable {
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.card.clickable:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font: inherit; background: var(--panel); color: var(--text);
}
.toolbar input[type="search"] { min-width: 220px; }
.toolbar-labeled { align-items: flex-end; }
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
}
.filter-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}
.filter-field input,
.filter-field select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  background: var(--panel);
  color: var(--text);
}

button {
  border: none; border-radius: 10px; padding: 9px 14px;
  font: inherit; cursor: pointer; background: var(--accent);
  color: #041018; font-weight: 600;
}
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.btn-danger {
  background: var(--err);
  color: #fff;
  border: 1px solid rgba(255, 93, 108, 0.55);
}
button.btn-danger:hover { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: not-allowed; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.panel-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.table-wrap { overflow: auto; max-height: calc(100dvh - 280px); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: #121a26; z-index: 1; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(77,163,255,.06); }
.mono { font-family: Consolas, monospace; font-size: 0.84rem; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 700; white-space: nowrap;
}
.badge.expired { background: rgba(255,93,108,.15); color: var(--err); }
.badge.critical { background: rgba(255,140,66,.15); color: var(--critical); }
.badge.warning { background: rgba(255,176,32,.15); color: var(--warn); }
.badge.notice { background: rgba(126,203,255,.12); color: var(--notice); }
.badge.ok { background: rgba(61,220,132,.12); color: var(--ok); }

.badge.fn { background: rgba(126,203,255,.12); color: var(--notice); }
.badge.ofd { background: rgba(94,234,212,.12); color: #5eead4; }
.badge.firmware { background: rgba(201,160,255,.12); color: #c9a0ff; }
.badge.software { background: rgba(77,163,255,.12); color: var(--accent); }
.badge.esp { background: rgba(255,176,32,.12); color: var(--warn); }
.badge.tspiot { background: rgba(61,220,132,.12); color: var(--ok); }
.badge.custom { background: rgba(255,255,255,.08); color: var(--text); }
.badge.equipment { background: rgba(255,140,66,.12); color: var(--critical); }
.badge.other { background: rgba(255,255,255,.05); color: var(--muted); }

.status-select {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 8px; font: inherit; background: var(--panel2); color: var(--text); font-size: 0.85rem;
}

.pager { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); }
.pager span { color: var(--muted); font-size: 0.88rem; }

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer-backdrop.drawer-elevated { z-index: 1330; }

.drawer {
  position: fixed; top: 0; right: 0; width: min(520px, 100vw); height: 100vh;
  background: var(--panel); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .25s; z-index: 50;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer.drawer-elevated { z-index: 1340; }
.drawer-head {
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: start; gap: 10px;
}
.drawer-body { padding: 16px 18px; overflow: auto; flex: 1; min-height: 0; }
.drawer-footer {
  padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--panel);
  flex-shrink: 0;
}
.drawer-footer.hidden { display: none; }
.deal-danger-inline {
  margin-top: 24px;
  padding-top: 8px;
}
.btn-danger-subtle {
  background: none;
  color: var(--muted);
  border: none;
  font-size: 0.8rem;
  font-weight: 400;
  padding: 2px 0;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--muted) 55%, transparent);
  text-underline-offset: 3px;
  opacity: 0.85;
}
.btn-danger-subtle:hover {
  color: var(--err);
  background: none;
  opacity: 1;
  text-decoration-color: currentColor;
}
.deal-modal-close-x {
  flex: 0 0 auto;
}
.client-modal-head {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: nowrap;
}
.client-modal-head-content {
  flex: 1 1 auto;
  min-width: 0;
}
.client-modal-head-inner {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 16px;
  align-items: start;
}
.client-modal-head-inner .deal-modal-head-main {
  grid-column: 1;
}
.client-modal-head-inner .deal-modal-head-actions {
  grid-column: 2;
  align-self: start;
}
.client-modal-head-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: max-content;
  min-width: 108px;
  max-width: 132px;
}
.client-modal-head-actions button {
  width: 100%;
  text-align: center;
}
@media (max-width: 720px) {
  .client-modal-head-inner {
    grid-template-columns: 1fr;
  }
  .client-modal-head-inner .deal-modal-head-actions {
    grid-column: 1;
  }
}

.form-grid { display: grid; gap: 12px; }
.form-grid label { display: grid; gap: 4px; font-size: 0.84rem; color: var(--muted); }
.form-grid input, .form-grid textarea, .form-grid select {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font: inherit; background: var(--panel2); color: var(--text);
}
.form-grid textarea { min-height: 70px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.section-title {
  margin: 18px 0 8px; font-size: 0.92rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}

.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 1500;
  background: var(--panel2); border: 1px solid var(--border);
  padding: 12px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s;
  max-width: min(420px, calc(100vw - 24px));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}
.toast.show { opacity: 1; }
.toast.toast-error {
  border-color: var(--danger, #e05a5a);
  background: #2a1418;
  color: #ffd6d6;
}
.deal-modal-hint-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--danger, #e05a5a);
  background: rgba(224, 90, 90, 0.12);
  color: #ffd6d6;
  font-size: 0.92rem;
}
.deal-modal-hint-error.hidden {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(77, 163, 255, 0.12), transparent 40%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  display: grid;
  gap: 14px;
}

.login-card h1 { margin: 0; font-size: 1.4rem; }

.login-card label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font: inherit;
}

.login-card button[type="submit"] {
  margin-top: 8px;
  padding: 11px 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #04101f;
  font-weight: 700;
  cursor: pointer;
}

.login-retry {
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.login-error {
  margin: 0;
  color: var(--err);
  font-size: 0.9rem;
}

.login-status {
  margin: 0;
  color: var(--accent);
  font-size: 0.9rem;
}

.login-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.login-hint code {
  font-size: 0.76rem;
}

.login-card.is-loading {
  opacity: 0.92;
}

.login-card.is-loading button[type="submit"] {
  opacity: 0.7;
  cursor: wait;
}

.app-loading {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--muted);
}

.user-panel {
  margin: 0 6px 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
}

.user-name { font-weight: 700; font-size: 0.95rem; }

.user-meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 4px;
}

.access-notice {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 183, 77, 0.35);
  background: rgba(255, 183, 77, 0.12);
  color: #ffd89a;
}

.sync-notices {
  background: rgba(255, 176, 32, 0.12);
  border: 1px solid rgba(255, 176, 32, 0.35);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.sync-toolbar { align-items: center; gap: 10px; flex-wrap: wrap; }
.sync-hint { margin-top: -8px; font-size: 0.88rem; }
.sync-request-status { margin-top: -8px; }

.connectors-table td { vertical-align: top; }
.sync-connector-error { color: var(--danger, #e57373); }

.mini-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.mini-table th, .mini-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.mini-table th { color: var(--muted); font-weight: 600; }

.drawer-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; align-items: center; }
.drawer-toolbar-btn-icon {
  min-width: 36px;
  padding: 8px 10px;
  font-size: 1.05rem;
  line-height: 1;
}
.catalog-offer-warehouse { background: rgba(61, 220, 132, 0.06); border-radius: 8px; padding: 8px 10px; }
.drawer-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.drawer-serial {
  font-size: 1.1rem;
  font-weight: 700;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.drawer-serial:hover { color: var(--accent); }
.drawer-ext-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}
.drawer-ext-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.copyable {
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.copyable:hover { color: var(--accent); }
code.copyable {
  cursor: pointer;
  border-bottom: 1px dashed rgba(255,255,255,0.25);
}
code.copyable:hover { color: var(--accent); }
.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}
.field-with-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.field-with-copy input { flex: 1 1 180px; }
.btn-field-action {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  text-decoration: none;
  white-space: nowrap;
}
@media (max-width: 899px) {
  .btn-field-action .btn-field-action-label { display: inline; }
}
@media (min-width: 900px) {
  .btn-field-action .btn-field-action-label { display: none; }
}
.form-grid input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  background: var(--panel);
  color: var(--text);
}
.user-vseofd {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.45;
}
.user-vseofd-muted { color: var(--muted); }
.user-vseofd-balance {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.user-vseofd-balance:hover strong { color: var(--accent); }
.profile-tochka { margin-top: 16px; flex-shrink: 0; }
.profile-dadata { margin-top: 16px; flex-shrink: 0; }
.profile-dadata-hint,
.profile-dadata-stats-line { margin: 0 0 12px; }
.profile-dadata-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-dadata-docs a { color: var(--accent); }
.profile-tochka-hint {
  margin: 0 16px 12px;
  font-size: 0.88rem;
  color: var(--muted);
}
.profile-tochka-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.profile-tochka-result {
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
}
.profile-tochka-result:empty {
  display: none;
}
.profile-tochka-warnings {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #ffd6d6;
}
.profile-tochka-body { padding-bottom: 4px; }
.profile-tochka-oauth-grid {
  padding: 0;
  width: 100%;
}
.profile-tochka-docs a { color: var(--accent); }
.drawer-deals-hint,
.drawer-deals-empty { margin: 0 0 12px; }
.drawer-deals-table { margin-bottom: 16px; }
.drawer-deal-title { color: var(--text); }
.drawer-deal-row:hover .drawer-deal-title { color: var(--accent); }
.warehouse-hint { margin: 0 16px 12px; color: var(--muted); font-size: 0.88rem; }
.warehouse-panel .panel-head { gap: 12px; flex-wrap: wrap; }
.warehouse-order-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 12px 0 16px;
}
.warehouse-order-facts > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.warehouse-order-title { margin: 0 0 4px; }
.warehouse-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
#view-orders.view.active .subtitle {
  margin-bottom: 10px;
}
#view-orders .orders-toolbar {
  margin-bottom: 10px;
  flex-shrink: 0;
}
#view-orders .table-wrap {
  max-height: none;
  overflow: visible;
  margin-bottom: 4px;
}
.orders-search-result { margin-bottom: 16px; flex-shrink: 0; }
.full-catalog-panel {
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel2);
}
.full-catalog-panel.hidden { display: none; }
.full-catalog-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.full-catalog-head input[type="search"] {
  flex: 1 1 180px;
  min-width: 160px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  background: var(--panel);
  color: var(--text);
}
.full-catalog-list {
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}
.renew-block { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.renew-block-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.catalog-offer { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
.catalog-offer:first-of-type { border-top: 0; }
.catalog-offer-muted { opacity: 0.72; }
.catalog-offer-recommended {
  background: rgba(46, 160, 67, 0.08);
  border: 1px solid rgba(46, 160, 67, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 4px 0;
}
.catalog-offer-recommended:first-of-type { border-top: 1px solid rgba(46, 160, 67, 0.35); }
.catalog-match-badge { display: inline-block; margin-bottom: 4px; font-size: 0.75rem; }
.catalog-offer-main { min-width: 0; }
.catalog-offer-group {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
}
.catalog-offer-group:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}
.catalog-offer-group-head {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.catalog-offer-group .catalog-offer:first-of-type { border-top: 0; }
.order-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }

.profile-topup-body {
  padding: 16px;
}
.profile-topup-field {
  display: block;
  max-width: 220px;
  font-size: 0.9rem;
}
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  min-width: 0;
}
.profile-field-wide {
  grid-column: 1 / -1;
}
.profile-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
}
.profile-input,
.profile-field input,
.profile-field select,
.profile-topup-field input {
  display: block;
  width: 100%;
  margin-top: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  background: var(--panel2);
  color: var(--text);
  box-sizing: border-box;
}
.profile-input:focus,
.profile-field input:focus,
.profile-field select:focus,
.profile-topup-field input:focus {
  outline: none;
  border-color: var(--accent);
}
.profile-input-secret {
  -webkit-text-security: disc;
  text-security: disc;
}
.profile-topup-field input {
  margin-top: 6px;
}
.profile-topup-hint {
  margin: 8px 0 12px;
}
.profile-topup-result {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel2);
}
.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 8px;
}
.profile-actions a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text);
  background: transparent;
}
.profile-actions a.primary {
  background: var(--accent);
  color: #041018;
  border-color: transparent;
}
.profile-section-title {
  font-size: 1rem;
  margin: 18px 0 8px;
}
.profile-empty {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 8px 0 12px;
}
#profile-content {
  flex: 1;
  min-height: 0;
  padding-bottom: 24px;
}
#orders-content {
  flex: 1;
  min-height: 0;
  padding-bottom: 24px;
}
#view-profile.view.active .subtitle {
  margin-bottom: 10px;
}
#view-profile .table-wrap {
  max-height: none;
  overflow: visible;
  margin-bottom: 4px;
}
#view-profile .profile-toolbar {
  margin-bottom: 8px;
}
.map-modal-panel {
  width: min(380px, 100%);
}
.map-modal-address {
  margin: 0;
  padding: 12px 14px;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}
.map-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 14px;
}
.btn-map-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  text-decoration: none;
  text-align: center;
}

.main,
#view-profile.view.active,
#view-orders.view.active,
.sidebar,
.drawer-body,
.table-wrap,
.notifications-list-wrap {
  scrollbar-width: thin;
  scrollbar-color: #3a4a5c #121a26;
}
.main::-webkit-scrollbar,
#view-profile.view.active::-webkit-scrollbar,
#view-orders.view.active::-webkit-scrollbar,
.notifications-list-wrap::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.drawer-body::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.main::-webkit-scrollbar-track,
#view-profile.view.active::-webkit-scrollbar-track,
#view-orders.view.active::-webkit-scrollbar-track,
.notifications-list-wrap::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.drawer-body::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: #121a26;
}
.main::-webkit-scrollbar-thumb,
#view-profile.view.active::-webkit-scrollbar-thumb,
#view-orders.view.active::-webkit-scrollbar-thumb,
.notifications-list-wrap::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: #3a4a5c;
  border-radius: 5px;
}
.profile-action-cell {
  white-space: nowrap;
  min-width: 120px;
}
.profile-history-codes {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.profile-history-codes.hidden {
  display: none !important;
}
.order-codes { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.renewal-code { background: var(--panel2); padding: 4px 8px; border-radius: 6px; font-size: 0.9rem; }
.order-actions { margin-top: 8px; }
.muted-row { opacity: 0.55; }

.sync-requests-list { display: grid; gap: 12px; padding: 12px 16px 16px; }
.sync-request-card {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.sync-request-card .secondary { margin-top: 10px; }

.mobile-topbar {
  display: none;
}

.input-with-action {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}
.input-with-action > input,
.input-with-action > select {
  flex: 1;
  min-width: 0;
}
.btn-scan {
  flex-shrink: 0;
  min-width: 44px;
  padding-left: 12px;
  padding-right: 12px;
}

.sidebar-backdrop {
  display: none;
}

.scan-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.scan-modal.hidden {
  display: none;
}
.scan-modal-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.scan-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.scan-reader {
  min-height: 260px;
  background: #000;
}
.scan-hint {
  margin: 0;
  padding: 10px 14px 14px;
  font-size: 0.82rem;
}

body.scan-active {
  overflow: hidden;
}

@media (max-width: 899px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-bottom: 10px;
    padding-top: env(safe-area-inset-top);
  }

  .mobile-menu-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.2rem;
    line-height: 1;
  }

  .mobile-topbar-title {
    font-weight: 700;
    font-size: 1.05rem;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 35;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(280px, 88vw);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    flex-direction: column;
    flex-wrap: nowrap;
    height: 100dvh;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .main {
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .drawer {
    width: 100vw;
    max-width: 100vw;
    padding-top: env(safe-area-inset-top);
  }

  .toolbar-labeled,
  .toolbar {
    align-items: stretch;
  }

  .filter-field {
    min-width: 0;
    width: 100%;
  }

  .toolbar input[type="search"],
  .filter-field input,
  .filter-field select,
  .form-grid input,
  .form-grid textarea,
  .form-grid select {
    font-size: 16px;
  }

  .nav-btn,
  button,
  .btn-scan {
    min-height: 44px;
  }

  table {
    font-size: 0.84rem;
  }

  th, td {
    padding: 8px 10px;
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: max(16px, env(safe-area-inset-bottom));
    transform: none;
    width: auto;
  }
}

@media (min-width: 900px) {
  body.sidebar-open .sidebar-backdrop {
    display: none;
  }
}

/* ——— Клиенты и воронка сделок ——— */
.clients-subnav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.clients-subnav-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}
.clients-panel { display: none; }
.clients-panel.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#clients-body tr.client-row-engineer {
  background: rgba(255, 176, 32, 0.1);
  box-shadow: inset 3px 0 0 var(--warn);
}
#clients-body tr.client-row-engineer:hover {
  background: rgba(255, 176, 32, 0.16);
}
.client-engineer-badge { margin-left: 4px; vertical-align: middle; font-size: 0.78rem; }

.pipeline-toolbar {
  margin-bottom: 12px;
}

.pipeline-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
}

.pipeline-column {
  flex: 0 0 260px;
  max-width: 280px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-height: none;
  align-self: stretch;
}

.pipeline-column-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.pipeline-column-body {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.deal-card:hover { border-color: var(--accent); }
.deal-card-title { font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.deal-card-meta { font-size: 0.8rem; color: var(--muted); }
.deal-card-amount { margin-top: 6px; font-weight: 600; color: var(--ok); }

.deal-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 12px;
  overflow: auto;
}
.deal-modal.hidden { display: none; }
.deal-modal.confirm-delete-modal {
  z-index: 1700;
  align-items: center;
  background: rgba(0, 0, 0, 0.78);
}
.deal-modal.client-modal-elevated {
  z-index: 1320;
}
.deal-modal.deal-modal-elevated {
  z-index: 1300;
}
#deal-documents-modal.deal-modal:not(.hidden) {
  z-index: 1350;
}
.deal-modal.confirm-delete-modal .deal-modal-panel {
  width: min(460px, calc(100vw - 32px));
  background: var(--panel2);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.deal-modal.confirm-delete-modal .deal-modal-body {
  padding: 16px 18px 18px;
}
.confirm-delete-message {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}
body.confirm-delete-open .drawer,
body.confirm-delete-open .drawer-backdrop {
  pointer-events: none;
}
.deal-modal-panel {
  width: min(1200px, calc(100vw - 24px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
.deal-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.deal-modal-head.client-modal-head {
  flex-wrap: nowrap;
  position: relative;
  padding-right: 16px;
}
.deal-modal-head.client-modal-head .client-modal-head-content {
  padding-right: 50px;
}
.deal-modal-head.client-modal-head .deal-modal-close-x {
  position: absolute;
  top: 14px;
  right: 16px;
  margin: 0;
  z-index: 1;
}
.deal-modal-head-main {
  flex: 1 1 220px;
  min-width: 0;
}
.deal-modal-head-inn {
  flex: 0 0 auto;
  align-self: flex-start;
  padding-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}
.deal-head-stage-row { margin-top: 6px; }
.deal-head-stage-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.deal-head-stage-select {
  flex: 0 1 220px;
  min-width: 140px;
  padding: 4px 8px;
  font-size: 0.85rem;
  min-height: 32px;
}
.deal-head-hint { margin-top: 4px; }
.deal-modal-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}
.deal-modal-head-actions-stack {
  flex-direction: column;
  align-items: stretch;
  min-width: 148px;
}
.deal-modal-head-actions-stack button {
  width: 100%;
}
#deal-documents-modal .deal-documents-panel {
  width: min(1320px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
}
.deal-documents-body.deal-modal-body {
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
}
.deal-documents-layout {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}
.deal-documents-main {
  flex: 1 1 auto;
  min-width: 0;
}
.deal-documents-sc-hint {
  margin: 0 0 10px;
  font-size: 0.85rem;
}
.deal-documents-subhead {
  margin: 4px 0 8px;
  font-size: 0.95rem;
}
.deal-form-grid.deal-documents-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 12px;
  margin-bottom: 12px;
}
.deal-doc-field-client {
  grid-column: span 2;
}
.deal-doc-register-field select {
  min-width: 220px;
}
.deal-doc-defects-field textarea {
  min-height: 92px;
  resize: vertical;
}
.profile-topup-row {
  align-items: flex-end;
}
.profile-topup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
}
.profile-topup-body {
  padding: 0 16px 16px;
}
.deal-documents-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.deal-documents-history {
  flex: 0 0 320px;
  max-width: 320px;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}
.deal-documents-history .table-wrap {
  max-height: 460px;
}
.deal-documents-history th,
.deal-documents-history td {
  padding: 6px 8px;
  font-size: 0.82rem;
}
.deal-doc-history-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.deal-doc-history-actions button {
  padding: 4px 8px;
  font-size: 0.78rem;
}
.deal-documents-items-table input.deal-input {
  width: 100%;
  min-width: 0;
}
.deal-documents-items-table th,
.deal-documents-items-table td {
  padding: 5px 8px;
}
@media (max-width: 1100px) {
  .deal-documents-layout {
    flex-direction: column;
  }
  .deal-doc-field-client {
    grid-column: auto;
  }
  .deal-documents-history {
    flex: 1 1 auto;
    max-width: none;
    width: 100%;
    padding-left: 0;
    padding-top: 12px;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
.deal-title-input {
  font-size: 1.05rem;
  font-weight: 600;
  padding: 8px 10px;
  min-height: 38px;
}
.deal-modal-body {
  padding: 16px;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.deal-spec-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 16px;
  flex: 1;
  min-height: 0;
  margin-bottom: 8px;
}
.deal-spec-sticky {
  flex: 1 1 520px;
  min-width: 480px;
  flex-shrink: 0;
  padding-bottom: 0;
  padding-right: 12px;
  border-bottom: none;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.deal-spec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.deal-spec-head .section-title {
  margin: 0;
}
.deal-spec-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.deal-spec-head-actions .deal-register-select-wrap {
  margin-bottom: 0;
}
.client-add-dadata-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}
.client-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.client-section-head h3 {
  margin: 0;
}
.client-shared-inn-hint {
  margin: 0 0 10px;
  color: var(--muted);
}
.deal-register-select-wrap {
  flex: 1 1 180px;
  max-width: min(360px, 100%);
  margin-bottom: 0;
}
.deal-register-select {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 0.88rem;
}
.deal-catalog-scroll {
  flex: 1 1 620px;
  min-width: 320px;
  min-height: 0;
  overflow: auto;
  padding-top: 0;
  padding-right: 2px;
}
.deal-items-table .deal-item-serial-cell {
  white-space: nowrap;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}
.deal-items-table th:nth-child(2),
.deal-items-table td:nth-child(2) {
  width: 1%;
  white-space: nowrap;
}
.deal-items-table .deal-item-name-cell {
  min-width: 120px;
}
.deal-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.deal-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}
.deal-form-wide {
  grid-template-columns: 1fr;
}
.deal-form-inline {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 12px;
  margin-bottom: 12px;
}
.deal-next-contact-row {
  display: flex;
  gap: 10px 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.deal-next-contact-grid {
  flex: 1;
  min-width: 0;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 10px 12px;
  margin-bottom: 0;
}
.deal-next-contact-done {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  margin-bottom: 2px;
  border: 1px solid rgba(34, 197, 94, 0.5);
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.14);
  color: #4ade80;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.deal-next-contact-done:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.24);
  border-color: rgba(74, 222, 128, 0.65);
}
.deal-next-contact-done:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.deal-card-next {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}
.deal-field-wide { grid-column: 1 / -1; }
.deal-payment-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.deal-payment-row .deal-input { flex: 1; min-width: 0; }
.deal-tochka-btn {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.deal-tochka-result { margin-top: -4px; }
.deal-tochka-result .deal-actions { margin-top: 8px; }
.deal-tochka-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  grid-column: 1 / -1;
}
.deal-tochka-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.deal-tochka-link-actions {
  flex: 0 0 auto;
  order: 0;
}
.deal-tochka-link-label {
  min-width: 4.5rem;
  flex-shrink: 0;
  order: 1;
}
.deal-tochka-link-value {
  flex: 1 1 auto;
  min-width: 0;
  order: 2;
}
.deal-tochka-link-paid {
  flex: 0 0 auto;
  margin-left: auto;
  order: 3;
}
.deal-tochka-paid-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.deal-tochka-link-value a {
  color: var(--accent, #2563eb);
  text-decoration: underline;
}
.deal-tochka-link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent, #2563eb);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
.deal-tochka-link-btn:hover { opacity: 0.85; }
.deal-tochka-paid {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel2);
  border: 1px solid var(--border);
}
.deal-item-code { margin-top: 4px; }
.deal-item-code .renewal-code {
  display: inline-block;
  max-width: 100%;
  font-size: 0.72rem;
  line-height: 1.25;
  word-break: break-all;
  padding: 2px 6px;
}
.deal-vseofd-order-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  max-height: min(42vh, 360px);
  overflow-y: auto;
}
.deal-vseofd-order-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
  cursor: pointer;
}
.deal-vseofd-order-item.is-disabled {
  opacity: 0.65;
  cursor: default;
}
.deal-vseofd-order-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.deal-vseofd-order-meta { font-size: 0.82rem; }
.deal-vseofd-skip { font-size: 0.82rem; }
.deal-vseofd-warning {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.35);
  font-size: 0.88rem;
  line-height: 1.45;
}
.deal-vseofd-oferta-note {
  margin: 0 0 12px;
  line-height: 1.45;
}
.deal-vseofd-oferta-note a { color: var(--accent, #2563eb); }
@media (max-width: 760px) {
  .deal-form-inline {
    grid-template-columns: 1fr;
  }
}
.deal-field-full {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.register-model-field {
  position: relative;
}
.register-model-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 1600;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.register-model-option {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.register-model-option:last-child {
  border-bottom: 0;
}
.register-model-option:hover,
.register-model-option:focus {
  background: var(--panel2);
  outline: none;
}
.deal-input,
.deal-modal .deal-input,
.nom-client-price {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font: inherit;
  min-height: 42px;
}
.deal-input:focus {
  outline: none;
  border-color: var(--accent);
}
.deal-client-banner {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.deal-client-main {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}
.deal-nom-picker {
  position: relative;
}
.deal-nom-picker-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel2);
  padding: 12px;
  margin-bottom: 14px;
}
.deal-nom-loading { margin: 8px 0; }
.deal-nom-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.deal-nom-mode {
  flex: 1;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.deal-nom-mode.active {
  border-color: var(--accent);
  background: rgba(77, 163, 255, 0.12);
}
.deal-nom-pane.hidden { display: none; }
.deal-nom-register-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.deal-nom-register-tab {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.deal-nom-register-tab.active {
  border-color: var(--accent);
  background: rgba(77, 163, 255, 0.12);
}
.deal-nom-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.deal-nom-chip {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.deal-nom-chip.active {
  border-color: var(--accent);
  background: rgba(77, 163, 255, 0.12);
}
.deal-nom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding-right: 4px;
}
.deal-nom-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 88px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.deal-nom-tile:hover { border-color: var(--accent); }
.deal-nom-tile-name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.25;
}
.deal-nom-tile-price { color: var(--ok); font-weight: 600; }
.deal-nom-tile-src { font-size: 0.75rem; }
.deal-nom-picker-panel .catalog-offer .btn-deal-add-item {
  flex-shrink: 0;
  min-height: 40px;
}
.deal-items-wrap { margin-top: 10px; overflow-x: visible; max-height: none; }
.deal-items-table { width: 100%; table-layout: auto; }
.deal-sum-row { margin-top: 10px; text-align: right; font-size: 1rem; }
.deal-spec-section { margin: 14px 0; }
.deal-items-table .deal-input { min-width: 72px; }
.deal-items-table td:first-child .deal-input { min-width: 180px; }
#view-nomenclature.view.active .panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#view-nomenclature.view.active .table-wrap {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
}
.nom-table .nom-client-price { max-width: 120px; }
.nom-table .badge { white-space: nowrap; }
.nom-table td:nth-child(2) { width: 1%; }
.nom-modal-panel { width: min(480px, 100%); }
.deal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.deal-actions-top {
  margin-top: 0;
  margin-bottom: 14px;
}
.deal-nom-add-title {
  margin-top: 0;
  margin-bottom: 8px;
}
.deal-nom-register-label {
  margin: 12px 0 6px;
  font-weight: 600;
}
.deal-spec-group-head td {
  background: var(--panel2);
  font-weight: 600;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.deal-spec-group-active td {
  background: rgba(77, 163, 255, 0.1);
}
.deal-spec-group-active.deal-spec-item-row td {
  box-shadow: inset 3px 0 0 var(--accent);
}
.deal-spec-group-dim td {
  opacity: 0.42;
}
.deal-events {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.deal-events li {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.client-detail-section { margin-bottom: 18px; }
.client-detail-section h3 {
  font-size: 0.95rem;
  margin: 0 0 8px;
}
.client-modal-panel {
  width: min(960px, calc(100vw - 24px));
}
.client-modal-body {
  overflow: auto;
}
.client-modal-head-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.client-head-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.client-head-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.client-head-name-input {
  width: 100%;
  max-width: 100%;
}
.client-head-row {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(140px, 1fr) minmax(160px, 1.2fr);
  gap: 10px 12px;
  align-items: end;
}
.client-head-field-inn {
  min-width: 0;
}
.client-head-inn-input {
  font-family: ui-monospace, monospace;
}
.client-head-inn-warn,
.client-head-no-reg {
  margin: 0;
}
.client-inn-warn { color: #ffd6d6; margin: 0 0 10px; }
.client-modal-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-bottom: 14px;
}
.client-phone-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.client-phone-call {
  min-width: auto;
  min-height: auto;
  padding: 4px 10px;
  font-size: 0.95rem;
}
.client-evotor-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #22b573;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
  flex-shrink: 0;
  line-height: 1;
}
.client-evotor-link:hover {
  filter: brightness(1.1);
  color: #fff;
}
.client-phone-sep {
  margin: 0 2px;
}
.client-dadata-phone + .client-dadata-phone,
.client-dadata-phone-follow {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.client-dadata-phone-label {
  font-size: 0.82rem;
  margin-bottom: 4px;
}
#client-modal-body tr.row-active {
  background: rgba(77, 163, 255, 0.08);
}
#client-modal-body tr.row-active td {
  border-color: rgba(77, 163, 255, 0.2);
}
.client-dadata-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 10px;
}
.client-dadata-stats {
  font-size: 0.82rem;
  flex: 1 1 220px;
}
.client-dadata-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.client-dadata-block h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}
.client-dadata-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 0.88rem;
  margin-bottom: 4px;
}
.client-dadata-row .muted {
  min-width: 110px;
}
.client-dadata-summary {
  font-size: 0.86rem;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.45;
}
.client-dadata-email {
  padding-top: 6px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
.client-dadata-email:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

@media (max-width: 899px) {
  .pipeline-column {
    flex-basis: 85vw;
    max-height: none;
  }
  .deal-spec-layout {
    flex-direction: column;
  }
  .deal-spec-sticky {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 12px;
    min-width: 0;
  }
  .deal-catalog-scroll {
    padding-top: 12px;
  }
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}
.nav-badge.hidden { display: none; }

#view-notifications.view.active {
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
#view-notifications.view.active h1,
#view-notifications.view.active .subtitle,
#view-notifications.view.active .notifications-toolbar {
  flex-shrink: 0;
}
#view-notifications.view.active .notifications-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.notifications-toolbar {
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-bottom: 10px;
}
#notifications-search {
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 420px;
}
.notifications-unread-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
}
.notifications-list-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px;
}
.notifications-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.notification-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--panel2);
  cursor: default;
}
.notification-item.notification-unread {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(59, 130, 246, 0.08);
}
.notification-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}
.notification-kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.notif-kind-payment { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.notif-kind-payment-in { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.notif-kind-payment-out { background: rgba(248, 113, 113, 0.18); color: #fca5a5; }
.notification-item.notif-payment-in {
  border-left: 3px solid rgba(74, 222, 128, 0.85);
}
.notification-item.notif-payment-out {
  border-left: 3px solid rgba(248, 113, 113, 0.85);
}
.notif-kind-reminder { background: rgba(251, 191, 36, 0.18); color: #fbbf24; }
.notif-kind-message { background: rgba(96, 165, 250, 0.18); color: #93c5fd; }
.notif-kind-chat { background: rgba(45, 212, 191, 0.18); color: #5eead4; }
.notif-kind-action { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; }
.notif-kind-system { background: rgba(168, 85, 247, 0.16); color: #c4b5fd; }
.notification-time {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}
.notification-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.notification-party {
  margin: 0 0 4px;
  font-weight: 600;
  color: var(--text);
}
.notification-body {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}
.notification-meta {
  margin-top: 6px;
  font-size: 0.8rem;
}
.notification-actions {
  margin-top: 8px;
}
.notification-deal-btn {
  font-size: 0.82rem;
  padding: 4px 10px;
}
.notification-attachment-btn {
  font-size: 0.82rem;
  padding: 4px 10px;
  margin-left: 6px;
}
.profile-colleague-hint {
  margin: 0 16px 12px;
}
.profile-sc-hint {
  padding-top: 12px;
}
.profile-sc-empty {
  padding: 0 16px 16px;
}
.profile-inline-save-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
}
.profile-inline-field {
  flex: 1 1 auto;
  min-width: 0;
}
.profile-inline-save-row > button {
  flex: 0 0 auto;
  white-space: nowrap;
  margin-bottom: 1px;
}
@media (max-width: 640px) {
  .profile-inline-save-row {
    flex-direction: column;
    align-items: stretch;
  }
  .profile-inline-save-row > button {
    width: 100%;
    margin-bottom: 0;
  }
}
.sc-chat-textarea {
  min-height: 120px;
  resize: vertical;
}
