/* ДДС 2026 — дашборд и аналитика */

.page-main.page-dds {
  max-width: min(1760px, calc(100vw - 2rem));
  padding-top: 1.25rem;
}

.dds-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.page-dds .page-title { margin: 0 0 0.25rem; letter-spacing: -0.02em; }
.page-dds .page-lead { margin: 0; max-width: 42rem; }

.dds-hero-asof {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  white-space: nowrap;
}

.dds-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 0.85rem;
  align-items: end;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin: 0.65rem 0 0.85rem;
  box-shadow: none;
}
.dds-filters[hidden] { display: none !important; }

.dds-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.dds-seg-btn {
  border: 0;
  background: transparent;
  color: #334155;
  padding: 0.38rem 0.75rem;
  font-weight: 650;
  font-size: 0.82rem;
  cursor: pointer;
}
.dds-seg-btn + .dds-seg-btn { border-left: 1px solid var(--border); }
.dds-seg-btn.is-active { background: #0f172a; color: #fff; }

.dds-filters label,
.dds-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.dds-filters select,
.dds-filters input,
.dds-toolbar select {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  background: #f8fafc;
  min-width: 9.5rem;
}

.dds-search { flex: 1; min-width: 12rem; }
.dds-search input { width: 100%; }

.dds-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.dds-pill {
  border: 0;
  background: #e2e8f0;
  color: #334155;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.dds-pill:hover { background: #cbd5e1; }
.dds-pill.is-active {
  background: #0f172a;
  color: #fff;
}
.dds-pill[hidden] { display: none !important; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.kpi {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.kpi .lbl { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.kpi .val {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.kpi .sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.35rem; }
.kpi.in .val { color: #0f766e; }
.kpi.out .val { color: #be123c; }
.kpi.warn { border-color: #fdba74; background: #fff7ed; }

.gap-banner {
  border-radius: 14px;
  padding: 0.85rem 1.1rem;
  margin-bottom: 0.85rem;
  font-size: 0.92rem;
}
.gap-banner.is-bad { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; }
.gap-banner.is-ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }

.dds-grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.dds-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.dds-card h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.card-hint { margin: 0.15rem 0 0.7rem; font-size: 0.8rem; }

.dds-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
  margin-bottom: 0.75rem;
}
.dds-toolbar label[hidden],
.dds-toolbar .chk[hidden],
#fact-month-wrap[hidden],
#fact-all-wrap[hidden],
#sandbox-sum-variant-wrap[hidden] {
  display: none !important;
}

.chk {
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem !important;
  text-transform: none !important;
  font-size: 0.85rem !important;
  color: var(--text) !important;
  letter-spacing: 0 !important;
  cursor: pointer;
  user-select: none;
}
.chk input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  margin: 0;
  accent-color: #1f4e79;
  cursor: pointer;
  flex: none;
}

.chart-box { height: 220px; }
.chart-box-sm { height: 160px; }
.chart-box svg { width: 100%; height: 100%; display: block; }

.flow-row, .wbar {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(5rem, 2fr) auto;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.82rem;
  padding: 0.28rem 0;
}

.bar-track {
  height: 8px;
  background: #f1f5f9;
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 99px; }
.bar-fill.in { background: #0f766e; }
.bar-fill.out { background: #e11d48; }
.bar-fill.wal { background: #4f46e5; }

.wbar .val, .flow-row .val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* Лист как в ДС / финмодели: голубая шапка, сетка, зелёный подытог */
.dds-sheet {
  border: 1px solid #9fc5e8;
  border-radius: 0 8px 8px 8px;
  background: #fff;
  margin-top: 0.65rem;
  overflow: hidden;
}
.dds-sheet .dds-toolbar {
  background: #cfe2f3;
  border-bottom: 1px solid #9fc5e8;
  margin: 0;
  padding: 0.5rem 0.75rem 0.45rem;
  color: #1f4e79;
}
.dds-sheet .dds-toolbar label,
.dds-sheet .dds-toolbar .muted {
  color: #1f4e79;
}
.dds-sheet .dds-toolbar .chk {
  color: #1f4e79 !important;
}
.dds-sheet .dds-toolbar select,
.dds-sheet .dds-toolbar input {
  background: #fff;
  border-color: #7ea7cc;
}

.sheet-scroll {
  max-height: calc(100vh - 140px);
  overflow: auto;
  background: #fff;
}
.dds-sheet .sheet-scroll,
.dds-sheet .days-scroll {
  border: 0;
  border-radius: 0;
}
.sheet-scroll.is-fitted {
  overflow: hidden;
}

.sheet-table, .sum-table, .days-table, .journal-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.sheet-table th, .sheet-table td,
.sum-table th, .sum-table td,
.journal-table th, .journal-table td {
  border-right: 1px solid #c5d4e3;
  border-bottom: 1px solid #c5d4e3;
  padding: 0.32rem 0.5rem;
  vertical-align: middle;
  background: #fff;
}
.sheet-table th:first-child, .sheet-table td:first-child,
.sum-table th:first-child, .sum-table td:first-child,
.journal-table th:first-child, .journal-table td:first-child {
  border-left: 1px solid #c5d4e3;
}

.sheet-table thead th, .sum-table thead th, .journal-table thead th {
  background: #cfe2f3;
  color: #1f4e79;
  font-weight: 600;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: 0 1px 0 #9fc5e8;
}

.sum-table thead th:not(:first-child),
.sum-table td:not(:first-child),
.journal-table td:nth-child(4),
.sheet-table .col-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.sum-table thead th:first-child {
  text-align: left;
  background: #cfe2f3;
  min-width: 12rem;
  position: sticky;
  left: 0;
  z-index: 4;
  color: #1f4e79;
}
.sum-table td:first-child {
  background: #fff;
  min-width: 12rem;
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
}
.sum-table tbody tr:nth-child(even):not(.row-section) td {
  background: #f8fbfd;
}
.sum-table tbody tr:nth-child(even):not(.row-section) td:first-child {
  background: #f8fbfd;
}
.sum-table tbody tr:hover:not(.row-section) td {
  background: #eef6fc;
}
.sum-table td:last-child, .sum-table thead th:last-child {
  position: sticky;
  right: 0;
}
.sum-table thead th:last-child {
  z-index: 4;
  background: #b6d4ee;
  color: #1f4e79;
  border-left: 1px solid #9fc5e8;
}
.sum-table td:last-child {
  z-index: 2;
  background: #eef6fc;
  font-weight: 650;
  border-left: 1px solid #9fc5e8;
}
.sum-table tfoot td,
.sum-table tr.sheet-subtotal td {
  background: #d9ead3;
  font-weight: 700;
  color: #111827;
}

.days-scroll {
  overflow: auto;
  max-height: calc(100vh - 140px);
  background: #fff;
}
.days-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}
.days-table thead th,
.days-table tbody th,
.days-table tbody td {
  border-right: 1px solid #c5d4e3;
  border-bottom: 1px solid #c5d4e3;
}
.days-table thead th:first-child,
.days-table tbody th {
  border-left: 1px solid #c5d4e3;
}
.days-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #cfe2f3;
  color: #1f4e79;
  font-weight: 650;
  text-align: center;
  padding: 0.28rem 0.28rem 0.22rem;
  min-width: 3.7rem;
  white-space: nowrap;
  box-shadow: 0 1px 0 #9fc5e8;
}
.days-table thead th .d-num {
  display: block;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.15;
  color: inherit;
}
.days-table thead th .d-wd {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  color: #3d85c6;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.days-table tbody th,
.days-table tbody td {
  padding: 0.28rem 0.32rem;
  vertical-align: middle;
  background: #fff;
}
.days-table tbody td {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  min-width: 3.7rem;
  color: #111827;
}
.days-table tbody th,
.days-table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  min-width: 13.5rem;
  max-width: 16rem;
  width: 13.5rem;
  text-align: left;
  font-weight: 600;
  white-space: normal;
  line-height: 1.25;
  padding: 0.32rem 0.65rem;
}
.days-table thead th:first-child {
  z-index: 6;
  background: #cfe2f3;
  color: #1f4e79;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.days-table tbody th {
  background: #fff;
  color: #111827;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  border-right: 1px solid #9fc5e8;
}
.days-table tbody td.col-total,
.days-table thead th:last-child {
  position: sticky;
  right: 0;
  min-width: 7.2rem;
}
.days-table thead th:last-child {
  z-index: 6;
  background: #b6d4ee;
  color: #1f4e79;
  text-align: right;
  padding-right: 0.7rem;
  border-left: 1px solid #9fc5e8;
}
.days-table tbody td.col-total {
  z-index: 3;
  background: #eef6fc;
  font-weight: 650;
  padding-right: 0.7rem;
  border-left: 1px solid #9fc5e8;
}

.days-table thead th.is-weekend { background: #b6d4ee; }
.days-table thead th.is-weekend .d-wd { color: #1f4e79; }
.days-table thead th.is-today {
  background: #3d85c6;
  color: #fff;
  box-shadow: inset 0 -3px 0 #1f4e79;
}
.days-table thead th.is-today .d-num,
.days-table thead th.is-today .d-wd { color: #fff; }
.days-table td.is-weekend { background: #f3f8fc; }
.days-table td.is-today { background: #eef6fc; }
.days-table thead th.is-future .d-num,
.days-table thead th.is-future .d-wd { color: #7ea7cc; }
.days-table td.is-future { background: #fafcfe; }

.row-section td, .row-section th {
  background: #cfe2f3 !important;
  font-weight: 700;
  color: #1f4e79;
}
.row-open th, .row-open td,
.row-close th, .row-close td {
  background: #d9ead3 !important;
  font-weight: 700;
  color: #111827;
}
.row-close th, .row-close td { border-top: 1px solid #6aa84f; }
.row-delta th, .row-delta td {
  background: #fff2cc !important;
  font-weight: 650;
  color: #111827;
}
.row-in-sum th, .row-in-sum td {
  background: #c9daf8 !important;
  font-weight: 700;
  color: #1f4e79;
}
.row-out-sum th, .row-out-sum td {
  background: #f4cccc !important;
  font-weight: 700;
  color: #111827;
}
.row-open td.col-total,
.row-close td.col-total { background: #c5e0bc !important; }
.row-in-sum td.col-total { background: #b6d4ee !important; }
.row-out-sum td.col-total { background: #ea9999 !important; }
.row-delta td.col-total { background: #ffe599 !important; }

.row-art th, .row-art td { background: #fff; font-weight: 500; color: #111827; }
.days-table tbody tr.row-art:nth-child(odd) th,
.days-table tbody tr.row-art:nth-child(odd) td { background: #f8fbfd; }
.days-table tbody tr.row-art:nth-child(odd) td.is-weekend { background: #eef6fc; }
.row-art .art-name { padding-left: 0.85rem; display: inline-block; }
.days-table tbody tr.row-art:hover th,
.days-table tbody tr.row-art:hover td { background: #eef6fc !important; }

.days-table .heat-out,
.days-table .heat-in { background: inherit; }

.sheet-subtotal td {
  background: #d9ead3;
  font-weight: 700;
}

.page-dds .sheet-table thead th {
  background: #cfe2f3;
  color: #1f4e79;
  text-align: left;
}
.page-dds .sheet-table tbody tr:nth-child(even) td { background: #f8fbfd; }

.num-neg { color: #be123c; }
.num-pos { color: #0f766e; }
.num-zero { color: #94a3b8; }

.act-chip {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}

.ok-pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: #d1fae5;
  color: #047857;
  font-weight: 700;
  font-size: 0.75rem;
}
.bad-pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: #fecaca;
  color: #9f1239;
  font-weight: 700;
  font-size: 0.75rem;
}

.dds-new-article {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.85rem;
}
.dds-new-article input,
.dds-new-article select,
.articles-edit input,
.articles-edit select {
  font-family: var(--font);
  font-size: 0.86rem;
  padding: 0.32rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  width: 100%;
}
.articles-edit .sheet-row-actions {
  white-space: nowrap;
  display: flex;
  gap: 0.25rem;
  align-items: center;
}
.articles-edit .art-del:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.dds-new-article input { min-width: 16rem; width: auto; }
.dds-new-article select { width: auto; }

.cash-cal {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}
.cash-cal th,
.cash-cal td {
  border-bottom: 1px solid #e8edf3;
  padding: 0.32rem 0.5rem;
  vertical-align: middle;
}
.cash-cal thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0f172a;
  color: #e2e8f0;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.cash-cal thead th.col-num,
.cash-cal td.col-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.cash-cal .cal-month td {
  background: #1e293b;
  color: #e2e8f0;
  font-weight: 700;
  padding: 0.45rem 0.5rem;
}
.cash-cal .cal-day { cursor: pointer; }
.cash-cal .cal-day:hover td { background: #f8fafc; }
.cash-cal .cal-day.is-open td { background: #eef2ff; }
.cash-cal .cal-empty td { color: #94a3b8; }
.cash-cal .cal-today td { box-shadow: inset 3px 0 0 #4f46e5; }
.cash-cal .cal-gap td { background: #fff1f2; }
.cash-cal .cal-wknd td { background: #f8fafc; }
.cash-cal .cal-compose {
  max-width: 28rem;
  color: #475569;
  font-size: 0.78rem;
}
.cash-cal .cal-ops td {
  background: #f8fafc;
  padding: 0.35rem 0.5rem 0.65rem;
}
.cal-ops-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.cal-ops-table th {
  text-align: left;
  color: #64748b;
  font-weight: 600;
  padding: 0.15rem 0.35rem;
  border-bottom: 1px solid #e2e8f0;
}
.cal-ops-table td { padding: 0.18rem 0.35rem; border-bottom: 1px solid #f1f5f9; }
.cal-chip {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  background: #e2e8f0;
  color: #334155;
}
.cal-chip.is-history { background: #fef3c7; color: #92400e; }
.cal-chip.is-ozon { background: #dbeafe; color: #1d4ed8; }
.cal-chip.is-recurring { background: #ede9fe; color: #5b21b6; }
.cal-chip.is-due { background: #ffedd5; color: #9a3412; }

.sandbox-toolbar { row-gap: 0.55rem; }
.sandbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding-bottom: 0.1rem;
}
.sandbox-add { min-width: 16rem; }
.sandbox-add-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.dds-sheet .dds-toolbar input[type="text"],
.dds-sheet .dds-toolbar input[type="search"] {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  border: 1px solid #9fc5e8;
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  background: #f8fbfe;
  min-width: 8.5rem;
}
.dds-sheet .sandbox-add-row input { min-width: 11rem; flex: 1; }
.days-table td.has-edit {
  position: relative;
}
.days-table input.cell-edit {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: inherit;
  appearance: none;
}
.days-table input.cell-edit:focus {
  outline: 2px solid #3d85c6;
  outline-offset: -2px;
  background: #fff;
}
.days-table.is-sandbox-sum td,
.days-table.is-sandbox-sum th { min-width: 5.2rem; }
.days-table.is-sandbox-sum tbody td.col-total,
.days-table.is-sandbox-sum thead th:last-child {
  position: static;
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .dds-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .dds-hero { flex-direction: column; align-items: flex-start; }
}

.articles-edit tr.art-opiu-miss td { background: #fff7ed; }
.articles-edit .art-opiu { min-width: 14rem; max-width: 22rem; }
