:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --sidebar: #16181d;
  --sidebar-soft: #22252c;
  --panel: #ffffff;
  --text: #14161c;
  --muted: #6b7080;
  --line: #e7e8ec;
  --line-soft: #eff0f3;
  --accent: #1d4ed8;
  --accent-dark: #15379e;
  --accent-soft: #e8edfc;
  --success: #0f7d5c;
  --warning: #92620a;
  --danger: #b3261e;
  --danger-soft: #fbeceb;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-full: 999px;

  --shadow-card: 0 1px 2px rgba(20, 22, 28, 0.04), 0 10px 24px -14px rgba(20, 22, 28, 0.16);
  --shadow-pop: 0 12px 32px -8px rgba(20, 22, 28, 0.22);
  --shadow: var(--shadow-card);

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  --h-sm: 32px;
  --h-md: 36px;
  --h-lg: 42px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  letter-spacing: -0.005em;
  font-weight: 700;
}

button,
input,
select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: var(--h-md);
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button,
.ghost-button,
.link-button {
  display: inline-flex;
  min-height: var(--h-md);
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}

button:hover,
.link-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button:active,
.ghost-button:active,
.link-button:active {
  transform: translateY(1px);
}

button.ghost,
.ghost-button {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--line);
}

button.ghost:hover,
.ghost-button:hover {
  background: #d7e0fa;
  border-color: var(--line);
}

button.danger {
  background: var(--danger-soft);
  border-color: #f2c9c6;
  color: var(--danger);
}

button.small {
  min-height: var(--h-sm);
  padding: 6px 10px;
  font-size: 12px;
}

button:disabled,
button:disabled:hover,
button:disabled:active {
  background: #f1f2f4;
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 60px;
  display: flex;
  flex-direction: column;
  padding: 14px 8px;
  background: var(--sidebar);
  color: #fff;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  transition: width 0.16s ease, box-shadow 0.16s ease;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.sidebar:hover,
.sidebar:focus-within {
  width: 224px;
  box-shadow: var(--shadow-pop);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 204px;
  padding: 6px 2px 20px;
}

.brand-mark {
  display: grid;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent);
  font-weight: 800;
  font-size: 12px;
}

.brand strong,
.brand small {
  display: block;
}

.brand div,
.nav-section-label,
.main-nav a span.nav-label,
.sidebar-footer {
  opacity: 0;
  transition: opacity 0.1s ease;
}

.sidebar:hover .brand div,
.sidebar:hover .nav-section-label,
.sidebar:hover .main-nav a span.nav-label,
.sidebar:hover .sidebar-footer,
.sidebar:focus-within .brand div,
.sidebar:focus-within .nav-section-label,
.sidebar:focus-within .main-nav a span.nav-label,
.sidebar:focus-within .sidebar-footer {
  opacity: 1;
}

.brand small {
  margin-top: 2px;
  color: #9aa1b0;
  white-space: nowrap;
}

.main-nav {
  display: grid;
  gap: 2px;
  min-width: 204px;
}

.nav-section-label {
  margin: 8px 0 4px;
  padding: 0 10px;
  color: #6b7280;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.main-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  color: #aeb4c2;
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  position: relative;
}

.main-nav a svg {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
}

.main-nav a.active,
.main-nav a:hover {
  background: var(--sidebar-soft);
  color: #fff;
}

.nav-badge {
  position: absolute;
  top: 4px;
  left: 28px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  display: grid;
  place-items: center;
  line-height: 1;
  pointer-events: none;
}

.sidebar:hover .nav-badge,
.sidebar:focus-within .nav-badge {
  position: static;
  margin-left: auto;
}

.main-nav a.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: var(--radius-full);
  background: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  min-width: 204px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 14px 2px 0;
}

.sidebar-footer span,
.sidebar-footer strong {
  display: block;
}

.sidebar-footer span {
  color: #9aa1b0;
  font-size: 11.5px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user span {
  color: #9aa1b0;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user a {
  color: #e59a95;
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.logout-icon {
  display: none;
}

.sidebar-active-company {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-active-company-name {
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-support-link {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: #9aa1b0;
  text-align: center;
}

.sidebar-support-link:hover {
  color: #fff;
}

.company-switcher select {
  width: 100%;
  max-width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--sidebar-soft, rgba(255, 255, 255, 0.08));
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-switcher select:focus {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.workspace {
  display: grid;
  gap: 18px;
  margin-left: 60px;
  padding: 16px 14px 22px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.head-actions,
.quick-add,
.create-list,
.row-actions,
.panel-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-add {
  min-width: min(460px, 100%);
}

.alert,
.panel,
.kpi-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.alert {
  padding: 12px 14px;
  font-weight: 700;
  border-left: 3px solid var(--line);
}

.alert.error {
  background: var(--danger-soft);
  border-left-color: var(--danger);
  color: var(--danger);
}

.alert.notice {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--accent);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi-grid.wide {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.kpi-grid article {
  padding: 14px;
}

.kpi-grid span {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kpi-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.panel {
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title p,
.muted,
.empty {
  color: var(--muted);
}

td.empty {
  padding: 28px 12px !important;
  text-align: center;
  font-size: 12.5px;
}

div.empty {
  padding: 28px 16px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}

.reset-link {
  font-weight: 700;
}

.document-filter,
.report-filter {
  display: grid;
  align-items: end;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.document-filter {
  grid-template-columns: 160px minmax(240px, 1.2fr) 140px 140px minmax(260px, 1.3fr) auto;
}

.panel-title-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.custom-period-inputs {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.report-filter {
  grid-template-columns: minmax(160px, 220px) minmax(280px, 1fr) auto;
}

.export-form {
  align-items: end;
}

.export-form button[type="submit"] {
  grid-column: 3 / -1;
  justify-self: start;
  width: max-content;
}

.export-debug {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.export-debug h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.export-debug pre {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  color: #0f172a;
  white-space: pre-wrap;
  word-break: break-word;
}

.customers-table {
  min-width: 1500px;
}

.customers-table .col-name {
  width: 260px;
}

.customers-table .col-inn {
  width: 100px;
}

.customers-table .col-narrow {
  width: 70px;
}

.customers-table .col-money {
  width: 110px;
}

.customers-table .col-phone {
  width: 130px;
}

.customers-table .col-email {
  width: 150px;
}

.customers-table .col-contact {
  width: 140px;
}

.customers-table .col-address {
  width: 220px;
}

table.customers-table td {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}

table.customers-table td:nth-child(2),
table.customers-table td:nth-child(3),
table.customers-table td:nth-child(4),
table.customers-table td:nth-child(7) {
  white-space: nowrap;
}

.diag-filters {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 0 16px 12px;
  flex-wrap: wrap;
}

.shipment-summary-table {
  min-width: 1710px;
}

.shipment-summary-table .col-customer {
  width: 200px;
}

.shipment-summary-table .col-contract {
  width: 170px;
}

.shipment-summary-table .col-date {
  width: 100px;
}

.shipment-summary-table .col-item {
  width: 260px;
}

.shipment-summary-table .col-narrow {
  width: 70px;
}

.shipment-summary-table .col-money {
  width: 110px;
}

.shipment-summary-table .col-shipments {
  width: 260px;
}

.shipment-summary-table .col-status {
  width: 110px;
}

table.shipment-summary-table th,
table.shipment-summary-table td {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  vertical-align: top;
}

table.shipment-summary-table td:nth-child(3),
table.shipment-summary-table td:nth-child(5),
table.shipment-summary-table td:nth-child(6),
table.shipment-summary-table td:nth-child(9),
table.shipment-summary-table td:nth-child(11) {
  white-space: nowrap;
}

.shipment-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.diag-documents-wrap {
  max-height: 560px;
  overflow-y: auto;
}

.export-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.export-kpi-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #f8fafc;
}

.export-kpi-grid span,
.export-contract-main span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.export-kpi-grid strong {
  font-size: 20px;
  white-space: nowrap;
}

.export-contract-main {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
}

.export-contract-main > div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
}

.export-contract-main .wide {
  grid-column: span 2;
}

.export-contract-main strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.45;
}

.export-execution-table,
.export-items-table {
  min-width: 980px;
}

.export-items-table th:nth-child(3),
.export-items-table td:nth-child(3) {
  width: 34%;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table.compact {
  min-width: 720px;
}

.documents-table {
  table-layout: fixed;
}

.documents-table .col-date {
  width: 82px;
}

.documents-table .col-customer {
  width: 15%;
  min-width: 220px;
}

.documents-table .col-contract {
  width: 142px;
}

.documents-table .col-document {
  width: 120px;
}

.documents-table .col-money {
  width: 112px;
}

.documents-table .col-status {
  width: 92px;
}

.documents-table .col-action {
  width: 124px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.documents-table th,
.documents-table td {
  padding: 6px 6px;
  vertical-align: middle;
}

.documents-table .money {
  text-align: left;
}

.documents-table th:first-child,
.documents-table td:first-child {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.documents-table td:nth-child(2),
.documents-table td:nth-child(4) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.documents-table .pill {
  max-width: 100%;
  justify-content: center;
  padding: 3px 6px;
  font-size: 11px;
}

.documents-table .link-button {
  width: 100%;
  min-height: 26px;
  padding: 4px 6px;
  font-size: 11px;
  line-height: 1.15;
  white-space: normal;
  text-align: center;
}

.documents-table .doc-actions {
  display: grid;
  gap: 4px;
}

.documents-table .link-button.secondary {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--line);
}

th {
  background: #fafafb;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.data-table th,
.data-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table td {
  white-space: nowrap;
}

.data-table td:nth-child(2),
.data-table td:nth-child(4) {
  white-space: normal;
}

.documents-table td:nth-child(2),
.documents-table td:nth-child(4) {
  white-space: normal;
}

.muted {
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

.money {
  white-space: nowrap !important;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.num {
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.money .muted {
  white-space: nowrap;
}

tbody tr:hover {
  background: #f9f9fa;
}

.error-detail-row td {
  background: #fff7ed;
  color: #9a3412;
  white-space: normal;
}

.error-detail-row pre {
  max-height: 180px;
  margin: 8px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.mono {
  letter-spacing: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  padding: 3px 8px;
  background: #eef0f3;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}

.pill.success,
.pill.done {
  background: #ecfdf3;
  color: var(--success);
}

.pill.warning,
.pill.cancel_requested,
.pill.cancelled {
  background: #fffaeb;
  color: var(--warning);
}

.pill.rejected {
  background: #fef3c7;
  color: #92400e;
}

.pill.neutral {
  background: #f1f5f9;
  color: #475569;
}

.pill.danger,
.pill.failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill.running {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.active {
  background: #ecfdf3;
  color: var(--success);
}

.pill.closed {
  background: #f1f5f9;
  color: #475569;
}

.pill.matched {
  background: #ecfdf3;
  color: var(--success);
}

.pill.missing {
  background: #fffaeb;
  color: var(--warning);
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.sync-pill.synced {
  background: #ecfdf3;
  color: #15803d;
}

.sync-pill.partial {
  background: #fffaeb;
  color: #b45309;
}

.sync-pill.syncing {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.sync-pill.not_synced {
  background: #fff1f0;
  color: #b42318;
}

.two-columns,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.report-shell {
  display: grid;
  gap: 14px;
}

.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

.report-toolbar p {
  margin-top: 3px;
  color: var(--muted);
}

.compact-filter {
  display: grid;
  align-items: end;
  grid-template-columns: minmax(180px, 1fr) minmax(210px, 300px) 150px 170px auto auto;
  gap: 10px;
  padding: 0;
  border: 0;
}

.checkbox-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  align-self: end;
  padding-bottom: 2px;
}

.checkbox-label input {
  width: auto !important;
}

.report-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.report-kpis article {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.report-kpis span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.report-kpis strong {
  display: block;
  margin-top: 10px;
  font-size: 21px;
  white-space: nowrap;
}

.report-kpis .danger-card strong {
  color: var(--danger);
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(520px, 1.4fr);
  gap: 14px;
}

.report-grid.bottom-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-card .panel-title {
  padding: 12px 14px;
}

.status-report {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.donut {
  position: relative;
  display: grid;
  width: 176px;
  height: 176px;
  place-items: center;
  border-radius: 50%;
}

.donut::after {
  position: absolute;
  inset: 38px;
  border-radius: 50%;
  background: #fff;
  content: "";
}

.donut span {
  position: relative;
  z-index: 1;
  max-width: 104px;
  text-align: center;
  font-weight: 900;
  line-height: 1.2;
}

.status-list {
  display: grid;
  gap: 10px;
}

.status-list div,
.chart-legend span {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px;
  align-items: center;
}

.status-list i,
.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.status-list strong {
  font-variant-numeric: tabular-nums;
}

.month-chart {
  display: grid;
  min-height: 242px;
  grid-template-columns: repeat(12, minmax(28px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 20px 18px 10px;
  border-bottom: 1px solid var(--line);
}

.month-column {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.month-column span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.bars {
  display: flex;
  height: 190px;
  align-items: end;
  gap: 5px;
}

.bars i {
  width: 11px;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
}

.bar-shipped {
  background: #3b82f6;
}

.bar-paid {
  background: #22c55e;
}

.bar-unpaid {
  background: #f59e0b;
}

.bar-rest {
  background: #cbd5e1;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 10px 14px 14px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-grid;
}

.report-table {
  min-width: 900px;
}

.report-table.compact {
  min-width: 620px;
}

.report-table th,
.report-table td {
  padding: 8px 10px;
  vertical-align: middle;
}

.report-table td:first-child {
  white-space: normal;
}

.progress-cell {
  display: grid;
  grid-template-columns: 48px minmax(80px, 1fr);
  gap: 8px;
  align-items: center;
}

.progress-cell strong {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.progress-cell span {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f7;
}

.progress-cell i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #22c55e;
}

.bi-page {
  display: grid;
  gap: 10px;
}

.bi-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
}

.bi-filter p,
.bi-head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.bi-grid-2x2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.bi-dashboard {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.bi-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
}

.bi-head h2 {
  font-size: 16px;
}

.mini-kpis {
  display: grid;
  gap: 8px;
}

.mini-kpis.six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.mini-kpis.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.mini-kpis div {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
}

.mini-kpis span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-kpis strong {
  display: block;
  margin-top: 7px;
  font-size: 15px;
  white-space: nowrap;
}

.green {
  color: #16a34a;
}

.orange {
  color: #f59e0b;
}

.red {
  color: #ef4444;
}

.bi-two {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr);
  gap: 10px;
}

.chart-card {
  min-height: 178px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  background: #fff;
}

.chart-card h3 {
  margin: 0 0 8px;
  font-size: 12px;
}

.compact-status {
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 4px 0 0;
}

.donut.small {
  width: 112px;
  height: 112px;
}

.donut.small::after {
  inset: 27px;
}

.donut.small span {
  max-width: 68px;
  font-size: 11px;
}

.small-list {
  gap: 7px;
  font-size: 11px;
}

.mini-line-chart {
  display: grid;
  height: 136px;
  grid-template-columns: repeat(12, minmax(14px, 1fr));
  gap: 8px;
  align-items: end;
  padding-top: 8px;
}

.mini-line-chart div {
  display: flex;
  height: 120px;
  align-items: end;
  justify-content: center;
  gap: 3px;
  position: relative;
}

.mini-line-chart i {
  width: 7px;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
}

.mini-line-chart span {
  position: absolute;
  bottom: -16px;
  color: var(--muted);
  font-size: 10px;
}

.tight-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.mini-table {
  min-width: 0;
  table-layout: auto;
}

.mini-table th,
.mini-table td {
  padding: 6px 8px;
  font-size: 11px;
}

.risk-row {
  background: #fff7f7;
}

.inline-date-form input[type="date"] {
  width: 130px;
  padding: 4px 6px;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.age-bars {
  display: grid;
  gap: 9px;
}

.age-bars div {
  display: grid;
  grid-template-columns: 90px 48px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}

.age-bars i {
  height: 12px;
  border-radius: 999px;
}

.debt-donut {
  background: conic-gradient(#22c55e 0 60%, #f59e0b 60% 82%, #3b82f6 82% 94%, #cbd5e1 94% 100%);
  margin: 12px auto 0;
}

.customer-mini-bars {
  display: grid;
  gap: 7px;
}

.customer-mini-bars div {
  display: grid;
  grid-template-columns: 120px 1fr 54px;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}

.customer-mini-bars span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-mini-bars i {
  height: 12px;
  border-radius: 999px;
  background: #3b82f6;
}

.risk-matrix {
  position: relative;
  height: 150px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 49.5%, #dbe3ee 49.5%, #dbe3ee 50.5%, transparent 50.5%),
    linear-gradient(0deg, transparent 49.5%, #dbe3ee 49.5%, #dbe3ee 50.5%, transparent 50.5%),
    #fff;
}

.risk-matrix .zone {
  position: absolute;
  color: var(--muted);
  font-size: 10px;
}

.risk-matrix .z1 {
  left: 8px;
  top: 8px;
}

.risk-matrix .z2 {
  right: 8px;
  top: 8px;
}

.risk-matrix .dot {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.risk-matrix .dot.stable {
  background: rgba(34, 197, 94, 0.75);
}

.risk-matrix .dot.high {
  background: rgba(239, 68, 68, 0.78);
}

.forecast-line {
  position: relative;
  display: flex;
  height: 140px;
  align-items: end;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.forecast-line i {
  flex: 1;
  min-height: 3px;
  border-radius: 3px 3px 0 0;
  background: #22c55e;
}

.forecast-line em {
  position: absolute;
  right: 12px;
  top: 35px;
  width: 45%;
  border-top: 2px dashed #3b82f6;
}

.expected-bars {
  display: grid;
  height: 150px;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  align-items: end;
}

.expected-bars div {
  display: grid;
  gap: 5px;
  justify-items: center;
  font-size: 10px;
  text-align: center;
}

.expected-bars i {
  width: 28px;
  min-height: 3px;
  border-radius: 3px 3px 0 0;
  background: #3b82f6;
}

.customer-bars {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.customer-bar-row {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr 130px;
  gap: 12px;
  align-items: center;
}

.customer-bar-row > span {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-bar-row > strong {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.stacked-bar {
  display: flex;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f7;
}

.stacked-bar i {
  display: block;
  height: 100%;
  min-width: 0;
}

.feed {
  display: grid;
}

.feed article {
  display: grid;
  grid-template-columns: 130px minmax(180px, 0.9fr) minmax(240px, 1.2fr);
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.feed span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed time {
  color: var(--muted);
}

details summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 800;
}

.panel-tools {
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.inline-filter {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 220px) auto;
  gap: 10px;
  min-width: min(620px, 100%);
}

.list-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 18px;
}

.list-tab {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
}

.list-tab a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  color: var(--muted);
  font-weight: 800;
}

.list-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.list-tab.active a {
  color: var(--accent);
}

.delete-list {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.form-stack {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.import-example {
  padding: 0 18px 18px;
}

.import-example-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.form-stack form {
  display: grid;
  gap: 10px;
}

.supplier-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(240px, 1fr) max-content;
  gap: 12px;
  align-items: end;
  padding: 18px;
  border-top: 1px solid var(--line);
}

.supplier-form > * {
  min-width: 0;
}

.supplier-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.supplier-form input {
  width: 100%;
}

.supplier-form button {
  white-space: nowrap;
}

.supplier-run-table,
.supplier-found-table {
  min-width: 900px;
}

.price-analysis-form {
  grid-template-columns: minmax(260px, 520px) auto auto;
}

.price-kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.price-run-table {
  min-width: 720px;
}

.price-analysis-table {
  min-width: 1280px;
}

.price-analysis-table th:nth-child(4),
.price-analysis-table td:nth-child(4),
.price-analysis-table th:nth-child(5),
.price-analysis-table td:nth-child(5) {
  white-space: normal;
}

.price-analysis-table th:nth-child(5),
.price-analysis-table td:nth-child(5) {
  min-width: 320px;
}

.ktru-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.order-plan-form {
  grid-template-columns: minmax(360px, 1fr) auto;
}

.order-plan-table {
  min-width: 1500px;
}

.order-plan-table th:nth-child(4),
.order-plan-table td:nth-child(4) {
  min-width: 260px;
  white-space: normal;
}

.year-funding {
  display: grid;
  gap: 4px;
  min-width: 260px;
}

.year-funding div {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 48px 1fr 1fr 1fr;
}

.year-funding span,
.year-funding b,
.year-funding em,
.year-funding strong {
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}

.year-funding em {
  color: var(--muted);
}

.year-funding strong {
  color: var(--text);
}

.method-box {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  color: var(--muted);
}

.method-box p {
  margin: 0;
}

.supplier-found-table th:first-child,
.supplier-found-table td:first-child {
  width: 120px;
}

.auto-sync-form {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.supplier-watch-grid {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.supplier-watch-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.supplier-watch-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.supplier-watch-head div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.supplier-watch-head strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-watch-head .mono {
  color: var(--muted);
  font-size: 12px;
}

.auto-sync-form label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.auto-sync-form input[type="number"] {
  width: 56px;
  min-height: 26px;
  padding: 4px 6px;
}

.toggle-line {
  justify-content: flex-start !important;
  color: var(--text) !important;
  font-weight: 800;
}

.supplier-watch-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.supplier-watch-stats div {
  min-width: 0;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  background: #f8fafc;
}

.supplier-watch-stats span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.supplier-watch-stats strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-watch-errors {
  display: grid;
  gap: 5px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  background: #fff1f0;
  color: var(--danger);
  font-size: 12px;
}

.supplier-watch-actions {
  flex-wrap: wrap;
}

.supplier-watch-actions button {
  white-space: nowrap;
}

.ea-backfill-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ea-backfill-form input[name="days_back"] {
  width: 56px;
}

.danger-text {
  color: var(--danger);
}

.supplier-found-table th:nth-child(3),
.supplier-found-table td:nth-child(3) {
  width: 190px;
}

.registry-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  padding: 16px;
}

.registry-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.registry-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.registry-card h3 {
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.registry-card dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.registry-card dl div {
  display: grid;
  grid-template-columns: 105px 1fr;
  gap: 8px;
  font-size: 12px;
}

.registry-card dt {
  color: var(--muted);
}

.registry-card dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-card-list {
  display: grid;
  gap: 9px;
}

.contract-detail-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.contract-detail-card:hover {
  border-color: #bfcdf5;
  box-shadow: var(--shadow-pop);
  transform: translateY(-1px);
}

.contract-detail-card summary {
  display: grid;
  grid-template-columns: 178px 96px minmax(300px, 1fr) 150px 112px 172px;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  padding: 11px 16px;
  cursor: pointer;
  list-style: none;
}

.contract-detail-card summary::-webkit-details-marker {
  display: none;
}

.contract-detail-card[open] summary {
  border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
}

.contract-card-number {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: #f1f2f4;
  color: #3d4149;
  font-size: 12px;
}

.contract-card-date {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.contract-card-date small {
  color: #64748b;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.contract-card-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.contract-card-main strong,
.contract-card-main em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-card-main strong {
  color: #0f172a;
  font-size: 14px;
  font-style: normal;
  font-weight: 400;
}

.contract-card-main em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.contract-card-price {
  padding: 7px 9px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #047857;
  white-space: nowrap;
  font-weight: 800;
  text-align: right;
}

.customer-contract-card summary {
  grid-template-columns: 178px 96px minmax(300px, 1fr) 150px 128px 92px;
}

.contract-detail-body {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: #fff;
}

.contract-execution-summary {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.contract-execution-summary > div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.contract-execution-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.contract-execution-summary strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #0f172a;
  font-size: 13px;
  font-weight: 400;
}

.progress-box i {
  display: block;
  height: 7px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress-box b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.status-bar-list {
  display: grid;
  gap: 8px;
  flex: 1;
}

.status-stage {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
}

.status-bar {
  display: block;
  height: 6px;
  margin-top: 2px;
  margin-bottom: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.status-bar b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s ease;
}

.status-bar.indeterminate b {
  width: 35%;
  animation: status-bar-slide 1.1s infinite linear;
}

@keyframes status-bar-slide {
  0% {
    margin-left: -35%;
  }
  100% {
    margin-left: 100%;
  }
}

.contract-detail-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.contract-detail-grid div {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.contract-detail-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.contract-detail-grid strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #0f172a;
  font-size: 12px;
  font-weight: 400;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
}

.nomenclature-table {
  min-width: 1180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.nomenclature-table th:first-child,
.nomenclature-table td:first-child {
  width: 56%;
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
}

.nomenclature-table th:nth-child(2),
.nomenclature-table td:nth-child(2) {
  width: 8%;
}

.shipment-documents {
  display: grid;
  gap: 12px;
}

.shipment-doc {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.shipment-doc-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.shipment-doc-items {
  min-width: 1180px;
  border-radius: 0;
}

.shipment-doc-items th:first-child,
.shipment-doc-items td:first-child {
  width: 56%;
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
}

.shipment-doc-total {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: baseline;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.shipment-doc-total span {
  color: var(--muted);
  font-size: 12px;
}

.shipment-doc-total strong {
  font-size: 14px;
  font-weight: 400;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.spec-pagination {
  display: flex;
  justify-content: center;
  gap: 14px;
  align-items: center;
  padding: 8px 0;
}

.spec-pagination span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pagination span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.loading-banner {
  display: flex;
  gap: 12px;
  align-items: center;
}

.loading-banner strong {
  white-space: nowrap;
}

.pill.running {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.pill.running::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 999px;
  background: currentColor;
  display: inline-block;
  animation: pulse-dot 1s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.import-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

/* Аналитика заказчика */

.status-list b {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.analytics-header .document-filter {
  margin-top: 10px;
}

.panel-grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel-grid.two > .panel {
  margin: 0;
}

.score-panel .score-body {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 20px;
  align-items: center;
  padding: 4px 18px 18px;
}

.score-donut {
  width: 176px;
  height: 176px;
}

.score-donut span {
  font-size: 30px;
  font-weight: 900;
}

.score-donut span small {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.score-donut.level-success { --score-color: #22c55e; }
.score-donut.level-warning { --score-color: #f59e0b; }
.score-donut.level-danger { --score-color: #ef4444; }

.score-details {
  display: grid;
  gap: 10px;
}

.score-bars {
  display: grid;
  gap: 8px;
}

.score-bars div {
  display: grid;
  grid-template-columns: 150px 1fr 76px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.score-bars span {
  color: var(--muted);
}

.score-bars i {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.score-bars b {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.risk-factors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  padding: 0 18px 18px;
}

.risk-factor {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.risk-factor .dot {
  margin-top: 5px;
  width: 9px;
  height: 9px;
  min-width: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.risk-factor.success .dot { background: #22c55e; }
.risk-factor.warning .dot { background: #f59e0b; }
.risk-factor.danger .dot { background: #ef4444; }

.risk-factor b {
  display: block;
  font-size: 13px;
}

.risk-factor small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.funnel {
  display: grid;
  gap: 12px;
  padding: 6px 18px 18px;
}

.funnel-step {
  display: grid;
  grid-template-columns: 130px 1fr 120px 50px;
  align-items: center;
  gap: 10px;
}

.funnel-step span {
  font-size: 13px;
  color: var(--muted);
}

.funnel-bar {
  height: 14px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.funnel-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
}

.funnel-step b {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.funnel-step small {
  color: var(--muted);
  text-align: right;
}

.dynamics-chart {
  display: flex;
  min-height: 220px;
  align-items: end;
  gap: 10px;
  padding: 20px 18px 10px;
  border-bottom: 1px solid var(--line);
}

.dynamics-col {
  display: grid;
  gap: 8px;
  justify-items: center;
  min-width: 24px;
}

.dynamics-bars {
  display: flex;
  height: 180px;
  align-items: end;
  gap: 3px;
}

.dynamics-bars i {
  width: 8px;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
}

.bar-contracted {
  background: #cbd5e1;
}

.dynamics-col span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.dot-contracted,
.dot-shipped,
.dot-paid {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.dot-contracted { background: #cbd5e1; }
.dot-shipped { background: #3b82f6; }
.dot-paid { background: #22c55e; }

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 18px 12px;
}

.metric-row div {
  padding: 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.metric-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric-row b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.insight {
  margin: 0 18px 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
}

.insight-list {
  display: grid;
  gap: 8px;
  padding: 6px 18px 18px;
  margin: 0;
  list-style: none;
}

.insight-list li {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  font-size: 13px;
}

.cash-cycle {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 18px 16px;
  padding: 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  font-size: 13px;
}

.cash-cycle span {
  color: var(--muted);
}

.cash-cycle b {
  font-variant-numeric: tabular-nums;
}

.cash-cycle em {
  margin-left: auto;
  font-style: normal;
  font-weight: 800;
  color: var(--accent-dark);
}

.methodology-panel summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 700;
}

.methodology-panel p,
.methodology-panel ul {
  padding: 0 18px 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.methodology-panel ul {
  margin: 0;
  padding-left: 34px;
}

.quad-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.quad-panel {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.quad-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  vertical-align: middle;
}

.quad-panel .panel-title h2 {
  display: flex;
  align-items: center;
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--accent-dark);
}

.overview-chart-block {
  padding: 0 18px 4px;
}

.overview-chart-block h4,
.overview-funnel-block h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.overview-funnel-block {
  padding: 6px 18px 14px;
}

.funnel.compact.under-chart {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 0;
}

.funnel.compact.under-chart .funnel-step {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.funnel.compact.under-chart .funnel-step span {
  font-size: 11px;
  color: var(--muted);
}

.funnel.compact.under-chart .funnel-bar {
  width: 100%;
}

.funnel.compact.under-chart .funnel-step b {
  font-size: 13px;
}

.funnel.compact.under-chart .funnel-step small {
  color: var(--muted);
}

.quad-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 0 18px 14px;
  flex: 1;
}

.quad-cols.three {
  grid-template-columns: repeat(3, 1fr);
}

.quad-cols h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.funnel.compact {
  padding: 0;
  gap: 8px;
}

.funnel.compact .funnel-step {
  grid-template-columns: 84px 1fr 76px 34px;
}

.funnel.compact .funnel-step span {
  font-size: 11px;
}

.dynamics-chart.compact {
  min-height: 130px;
  padding: 8px 0 0;
  border-bottom: none;
  gap: 6px;
}

.dynamics-chart.compact .dynamics-bars {
  height: 100px;
}

.dynamics-chart.compact.by-year {
  justify-content: center;
  gap: 24px;
}

.dynamics-chart.compact.by-year .dynamics-col {
  min-width: 60px;
}

.dynamics-chart.compact.by-year .dynamics-bars {
  gap: 6px;
}

.dynamics-chart.compact.by-year .dynamics-bars i {
  width: 18px;
}

.dynamics-chart.compact.by-year .dynamics-col span {
  font-size: 12px;
  font-weight: 700;
}

.dynamics-chart.compact.by-year .dynamics-col span small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 10px;
}

.dynamics-values {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.dynamics-values .v-contracted {
  color: #94a3b8;
}

.dynamics-values .v-shipped {
  color: #3b82f6;
}

.dynamics-values .v-paid {
  color: #16a34a;
}

.dynamics-values em {
  font-style: normal;
}

.chart-legend.small {
  padding: 6px 0 0;
  gap: 14px;
  justify-content: flex-start;
  font-size: 11px;
}

.mini-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 4px 18px 18px;
  margin-top: auto;
}

.mini-stat-row > div {
  padding: 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  text-align: center;
}

.mini-stat-value {
  display: block;
  font-size: 18px;
  font-weight: 900;
}

.mini-stat-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.stat-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.stat-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.stat-list span {
  color: var(--muted);
}

.stat-list b {
  font-variant-numeric: tabular-nums;
}

.quad-cols .donut.small {
  margin: 0 auto 10px;
}

.status-list.compact {
  gap: 6px;
}

.status-list.compact div {
  grid-template-columns: 8px 1fr auto;
  font-size: 11px;
}

.status-list.compact i {
  width: 8px;
  height: 8px;
}

.year-trend-chart {
  display: flex;
  align-items: end;
  gap: 10px;
  height: 100px;
  padding-top: 8px;
}

.year-trend-col {
  display: grid;
  justify-items: center;
  gap: 6px;
  flex: 1;
}

.year-trend-col b {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.year-trend-col i {
  display: block;
  width: 26px;
  min-height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}

.year-trend-col span {
  color: var(--muted);
  font-size: 11px;
}

.insight.small {
  margin: 8px 0 0;
  padding: 8px 10px;
  font-size: 11px;
}

.mini-supplier-list {
  display: grid;
  gap: 8px;
}

.mini-supplier-list div {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.mini-supplier-list div:last-child {
  border-bottom: none;
}

.mini-supplier-list a {
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-supplier-list b {
  font-variant-numeric: tabular-nums;
}

.mini-supplier-list span {
  color: var(--muted);
  font-size: 11px;
}

.small-note {
  margin: 8px 0 0;
  font-size: 11px;
}

.risk-cols.quad-cols {
  align-items: start;
}

.risk-gauge-col {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.risk-gauge-col .score-donut {
  width: 120px;
  height: 120px;
}

.risk-gauge-col .score-donut::after {
  inset: 26px;
}

.risk-gauge-col .score-donut span {
  font-size: 22px;
}

.score-bars.compact div {
  grid-template-columns: 1fr 84px 56px;
}

.risk-factor-list {
  display: grid;
  gap: 8px;
}

.risk-line {
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  font-size: 11px;
}

.risk-line b {
  display: block;
  font-size: 12px;
}

.risk-line span {
  color: var(--muted);
}

.risk-line.success { border-left-color: #22c55e; }
.risk-line.warning { border-left-color: #f59e0b; }
.risk-line.danger { border-left-color: #ef4444; }

.recommendation-box {
  margin: 0 18px 18px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  line-height: 1.5;
}

.recommendation-box b {
  margin-right: 4px;
}

@media (max-width: 1180px) {
  .quad-grid,
  .quad-cols.three {
    grid-template-columns: 1fr;
  }

  .quad-cols {
    grid-template-columns: 1fr 1fr;
  }

  .panel-grid.two {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: auto;
  }

  .workspace {
    margin-left: 0;
  }

  .main-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  /* На сенсорном экране :hover не срабатывает, поэтому подписи вкладок,
     завязанные на .sidebar:hover, никогда не появляются — человек видит
     голый ряд иконок без подписей и не может понять, где какая вкладка. */
  .brand div,
  .nav-section-label,
  .main-nav a span.nav-label,
  .sidebar-footer {
    opacity: 1;
  }

  .sidebar-footer {
    display: none;
  }

  .document-filter,
  .report-filter,
  .compact-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid,
  .kpi-grid.wide,
  .report-kpis,
  .report-grid,
  .report-grid.bottom-grid,
  .contract-execution-summary,
  .supplier-watch-stats,
  .two-columns,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 16px;
  }

  .page-head,
  .head-actions,
  .quick-add,
  .panel-title,
  .panel-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .document-filter,
  .report-filter,
  .inline-filter,
  .compact-filter,
  .supplier-form,
  .kpi-grid,
  .kpi-grid.wide,
  .report-kpis,
  .report-grid,
  .report-grid.bottom-grid,
  .contract-execution-summary,
  .supplier-watch-stats,
  .two-columns,
  .settings-grid,
  .score-body,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .funnel.compact.under-chart {
    grid-template-columns: 1fr 1fr;
  }

  .status-report,
  .customer-bar-row {
    grid-template-columns: 1fr;
  }

  .contract-detail-card summary,
  .contract-detail-grid {
    grid-template-columns: 1fr;
  }

  .contract-card-price {
    text-align: left;
  }

  .feed article {
    grid-template-columns: 1fr;
  }
}

/* ==================== HOME COCKPIT (Главная) ==================== */

.home-greeting {
  margin-bottom: 4px;
}

.home-greeting h1 {
  font-size: 22px;
  margin: 0;
}

.home-greeting p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.home-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--h-md);
  height: var(--h-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  flex-shrink: 0;
}

.home-bell:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.home-bell svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.home-bell .badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* --- KPI row --- */

.home-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.home-kpi {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

a.home-kpi:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.home-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.home-kpi-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.home-kpi-label .info-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  cursor: help;
  flex-shrink: 0;
}

.home-kpi-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.home-kpi-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.home-kpi.accent-blue .home-kpi-icon { background: var(--accent-soft); color: var(--accent); }
.home-kpi.accent-danger .home-kpi-icon { background: var(--danger-soft); color: var(--danger); }
.home-kpi.accent-success .home-kpi-icon { background: #e8f5f0; color: var(--success); }
.home-kpi.accent-violet .home-kpi-icon { background: #efecfc; color: #6a4fd8; }

.home-kpi.accent-danger { background: #fffaf9; }

.home-kpi-value {
  margin-top: 12px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.home-kpi-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.home-kpi-foot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.home-kpi-foot.plain { color: var(--muted); font-weight: 500; }
.home-kpi-foot .up { color: var(--success); font-weight: 700; }
.home-kpi-foot .down { color: var(--text); font-weight: 700; }

/* --- operational row (3 cols) --- */

.home-op-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 14px;
  align-items: stretch;
}

.home-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
}

.home-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.home-panel-head h2 {
  font-size: 13px;
  margin: 0;
  letter-spacing: 0.01em;
}

.home-panel-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
}

.home-panel-foot {
  margin-top: auto;
  padding-top: 10px;
  font-size: 12px;
  font-weight: 700;
}

.home-panel-foot a { color: var(--accent); text-decoration: none; }
.home-panel-foot a:hover { text-decoration: underline; }

/* attention list */

.attention-list {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
}

a.attention-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 4px;
  border-top: 1px solid var(--line-soft);
  text-decoration: none;
  color: inherit;
}

.attention-row:first-child { border-top: none; }

a.attention-row:hover { background: var(--bg); }

.attention-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.attention-row.level-danger .attention-dot { background: var(--danger); }
.attention-row.level-warning .attention-dot { background: var(--warning); }
.attention-row.level-info .attention-dot { background: var(--accent); }

.attention-body { flex: 1; min-width: 0; }

.attention-text {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.4;
}

.attention-amount {
  margin-top: 3px;
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.attention-row.level-danger .attention-amount { color: var(--danger); }

.attention-arrow {
  align-self: center;
  color: var(--muted);
  flex-shrink: 0;
}

/* expected payments */

.expected-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 16px;
  margin-top: 8px;
  flex: 1;
}

.expected-figures {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.expected-figure {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
}

.expected-figure:first-child { border-top: none; }
.expected-figure span:first-child { color: var(--muted); }
.expected-figure strong { font-variant-numeric: tabular-nums; font-size: 13.5px; }

.expected-figure.overdue { margin-top: 4px; }
.expected-figure.overdue strong,
.expected-figure.overdue span:first-child { color: var(--danger); }

.expected-figures-scroll {
  max-height: 260px;
  overflow-y: auto;
}

.expected-chart-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.expected-chart-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 10.5px;
}

.expected-chart-toggle span {
  padding: 3px 8px;
  color: var(--muted);
  font-weight: 700;
}

.expected-chart-toggle span.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.expected-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 90px;
}

.expected-chart-bar {
  flex: 1;
  min-width: 2px;
  min-height: 4px;
  background: var(--line);
  border-radius: 2px 2px 0 0;
  position: relative;
}

.expected-chart-bar.has-amount { background: var(--accent); }

.expected-chart-bar:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  z-index: 5;
  pointer-events: none;
}

/* events feed */

.events-chips {
  display: flex;
  gap: 6px;
  margin: 8px 0 4px;
  flex-wrap: wrap;
}

.events-chip {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.events-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.events-feed {
  display: flex;
  flex-direction: column;
}

a.event-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 4px;
  border-top: 1px solid var(--line-soft);
  text-decoration: none;
  color: inherit;
}

.event-row:first-child { border-top: none; }
a.event-row:hover { background: var(--bg); }

.event-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.event-icon svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2.4; }

.event-row.type-paid .event-icon { background: #e8f5f0; color: var(--success); }
.event-row.type-signed .event-icon { background: var(--accent-soft); color: var(--accent); }
.event-row.type-overdue .event-icon { background: var(--danger-soft); color: var(--danger); }

.event-body { flex: 1; min-width: 0; display: flex; justify-content: space-between; gap: 8px; }
.event-main { min-width: 0; }
.event-title { font-size: 12.5px; color: var(--text); }
.event-title strong { font-variant-numeric: tabular-nums; }
.event-meta { margin-top: 2px; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-time { flex-shrink: 0; font-size: 11px; color: var(--muted); white-space: nowrap; }

/* --- execution row (2 cols) --- */

.home-exec-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
  gap: 14px;
}

.exec-funnel-mini {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.exec-funnel-mini-arrow {
  color: var(--line);
  flex-shrink: 0;
}

.exec-funnel-mini-arrow svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

.exec-stage {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--bg);
}

.exec-stage-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.exec-stage-amount {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.exec-stage-meta {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
}

.exec-stage-percent {
  margin-top: 8px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--line-soft);
  overflow: hidden;
}

.exec-stage-percent b {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.exec-sub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.exec-sub-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
}

a.exec-sub-card:hover { border-color: var(--accent); }

.exec-sub-label { font-size: 11.5px; color: var(--muted); }
.exec-sub-amount { margin-top: 4px; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.exec-sub-count { margin-top: 1px; font-size: 11px; color: var(--muted); }

/* active contracts card */

.contracts-summary-count {
  margin-top: 8px;
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.contracts-summary-caption {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
}

.contracts-summary-rows {
  margin-top: 14px;
  display: grid;
  gap: 0;
}

.contracts-summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
}

.contracts-summary-row:first-child { border-top: none; }
.contracts-summary-row span:first-child { color: var(--muted); }
.contracts-summary-row strong { font-variant-numeric: tabular-nums; }
.contracts-summary-row strong.danger-text { color: var(--danger); }

.contracts-progress {
  margin-top: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--line-soft);
  overflow: hidden;
}

.contracts-progress b {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

/* empty state (positive) */

.home-empty-ok {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 2px;
  margin-top: 6px;
}

.home-empty-ok .check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e8f5f0;
  color: var(--success);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.home-empty-ok .check svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 3; }
.home-empty-ok strong { display: block; font-size: 12.5px; color: var(--text); }
.home-empty-ok p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* footer status bar */

.home-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 4px 0;
  font-size: 11.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

@media (max-width: 1400px) {
  .home-op-grid { grid-template-columns: 1fr 1fr; }
  .home-op-grid .home-panel:last-child { grid-column: 1 / -1; }
}

@media (max-width: 1100px) {
  .home-kpi-grid { grid-template-columns: 1fr 1fr; }
  .home-exec-grid { grid-template-columns: 1fr; }
  .exec-funnel-mini { grid-template-columns: 1fr; }
  .exec-funnel-mini-arrow { display: none; }
}

@media (max-width: 760px) {
  .home-op-grid { grid-template-columns: 1fr; }
  .home-op-grid .home-panel:last-child { grid-column: auto; }
  .expected-layout { grid-template-columns: 1fr; }
  .exec-sub-grid { grid-template-columns: 1fr; }

  /* KPI-карточки ("Ожидается к оплате" и т.д.) в одну колонку каждая
     занимала весь экран по высоте — на телефоне это 4 полных "экрана"
     скролла ради 4 чисел. Ставим 2 колонки и уменьшаем внутренние отступы
     и размер шрифта, чтобы всё помещалось компактно. */
  .home-kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .home-kpi {
    padding: 10px 12px;
  }

  .home-kpi-icon {
    width: 20px;
    height: 20px;
  }

  .home-kpi-icon svg {
    width: 11px;
    height: 11px;
  }

  .home-kpi-label {
    font-size: 9px;
    letter-spacing: 0.02em;
  }

  .home-kpi-value {
    margin-top: 6px;
    font-size: 16px;
  }

  .home-kpi-sub {
    font-size: 10px;
  }

  .home-kpi-foot {
    margin-top: 6px;
    padding-top: 6px;
    font-size: 10px;
  }
}

/* ==================== Мобильная навигация — нижняя панель вкладок ====================
   На телефоне горизонтальный ряд иконок (см. брейкпоинт 1180px) не
   помещался в экран и раздвигал всю страницу вширь (сама .sidebar/.main-nav
   не были ничем ограничены по ширине) — из-за этого часть вкладок
   оказывалась за пределами экрана и переключиться на них было
   действительно невозможно. Нижняя панель — привычный для мобильных
   приложений паттерн: все вкладки видны сразу, без прокрутки и без
   раздувания страницы. */
@media (max-width: 760px) {
  html, body {
    overflow-x: hidden;
  }

  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    padding: 4px 2px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    overflow: visible;
    z-index: 50;
    box-shadow: 0 -8px 24px -12px rgba(11, 20, 40, 0.35);
  }

  .sidebar:hover,
  .sidebar:focus-within {
    width: 100%;
    box-shadow: 0 -8px 24px -12px rgba(11, 20, 40, 0.35);
  }

  .brand {
    display: none;
  }

  /* .sidebar-footer раньше скрывался целиком на мобильной версии вместе
     с кнопкой "Выйти" — на телефоне выйти из аккаунта было невозможно
     нигде в интерфейсе. Оставляем только саму кнопку выхода как ещё одну
     вкладку в нижней панели, остальное (название компании, логин,
     Telegram-поддержка) прячем — для них тут нет места. */
  .sidebar-footer {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    min-width: 0;
  }

  .sidebar-active-company,
  .sidebar-user > span,
  .sidebar-support-link,
  .sidebar-footer > span,
  .company-switcher {
    display: none;
  }

  .sidebar-user {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }

  .sidebar-user a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    padding: 6px 8px;
    color: #aeb4c2;
    font-size: 9.5px;
  }

  .logout-icon {
    display: block;
    width: 19px;
    height: 19px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
  }

  .main-nav {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex: 1 1 auto;
    min-width: 0;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-section-label {
    display: none;
  }

  .main-nav a {
    flex: 1 1 0;
    min-width: 54px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: var(--radius-sm);
    font-size: 9.5px;
    text-align: center;
    white-space: normal;
    line-height: 1.15;
  }

  .main-nav a svg {
    width: 19px;
    height: 19px;
  }

  .main-nav a span.nav-label {
    display: block;
  }

  .main-nav a.active::before {
    left: 10%;
    right: 10%;
    top: -4px;
    bottom: auto;
    width: auto;
    height: 2px;
  }

  .nav-badge {
    top: 2px;
    left: 50%;
    margin-left: 6px;
  }

  .sidebar:hover .nav-badge,
  .sidebar:focus-within .nav-badge {
    position: absolute;
    margin-left: 6px;
  }

  .workspace {
    margin-left: 0;
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  /* Внутри .workspace много вложенных grid/flex-контейнеров (панели,
     KPI-карточки, лента событий, "Ожидаемые поступления" и т.д.) — у
     каждого своя, отдельная точка, где может не сработать сжатие
     (min-width:auto по умолчанию у grid/flex-элементов). Патчить каждую
     панель по отдельности неэффективно — сразу нашлось 3 разных места за
     один день. Снимаем min-width везде внутри рабочей области целиком:
     это не влияет на элементы с явным width (иконки, бейджи), а любой
     текстовый блок начинает нормально сжиматься/переноситься. */
  .workspace,
  .workspace * {
    min-width: 0;
  }
}

/* ==================== Реестр документов — карточный вид на телефоне ====================
   Таблица .documents-table рассчитана на 9 колонок (min-width:1180px) и
   на телефоне была доступна только через горизонтальную прокрутку — де
   факто данные не читались, нужно было листать вбок ячейку за ячейкой.
   Разворачиваем каждую строку в отдельную карточку: подпись поля берётся
   из data-label на <td>, значения идут одно под другим. */
@media (max-width: 760px) {
  .documents-table {
    display: block;
    min-width: 0;
    width: 100%;
    table-layout: auto;
  }

  .documents-table colgroup {
    display: none;
  }

  .documents-table tbody {
    display: block;
  }

  .documents-table thead {
    display: none;
  }

  .documents-table tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel);
    box-shadow: var(--shadow-card);
    padding: 4px 12px;
  }

  .documents-table tbody tr td.empty {
    border: none;
    box-shadow: none;
    padding: 16px 4px;
  }

  .documents-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    width: auto !important;
    padding: 8px 0;
    border-top: 1px solid var(--line-soft);
    border-bottom: none !important;
    text-align: right;
    white-space: normal;
  }

  .documents-table td:first-child {
    border-top: none;
  }

  .documents-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    text-align: left;
  }

  .documents-table td.doc-actions {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    gap: 6px;
  }

  .documents-table td.doc-actions::before {
    margin-bottom: 2px;
  }
}

/* ==================== Дашборды — раскладка в одну колонку на телефоне ====================
   .bi-grid-2x2 (2 колонки), .mini-kpis.six/.five (5-6 колонок) и .bi-two
   (ещё 2 колонки графиков внутри каждой панели) не имели вообще никаких
   мобильных правил — на 375px это давало по 50-60px на колонку, то есть
   ни одно число или подпись физически не помещались и не читались. */
@media (max-width: 760px) {
  .bi-grid-2x2 {
    grid-template-columns: 1fr;
  }

  .mini-kpis.six,
  .mini-kpis.five {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bi-two {
    grid-template-columns: 1fr;
  }

  .compact-status {
    grid-template-columns: 100px 1fr;
  }

  .mini-line-chart {
    grid-template-columns: repeat(12, minmax(10px, 1fr));
    gap: 4px;
  }

  .age-bars div {
    grid-template-columns: 74px 40px 1fr;
    gap: 6px;
  }

  .risk-matrix {
    min-height: 140px;
  }
}
