:root {
  --accent: #259ea2;
  --accent-2: #18a38f;
  --accent-dark: #0f6b6e;
  --ink: #16324a;
  --muted: #64788d;
  --bg: #f2f6f9;
  --card: #ffffff;
  --border: #e3eaf0;
  --line: #edf2f6;
  --topbar-h: 60px;
  --sidebar-w: 250px;
  --gap: 1rem;
}

html, body { background: var(--bg); color: var(--ink); font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }

.eyebrow { font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.brand-icon { width: 42px; height: 42px; border-radius: 13px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.2rem; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 16px rgba(37, 158, 162, .25); }

.btn-med { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; color: #fff; }
.btn-med:hover { color: #fff; filter: brightness(.97); }
.btn-ghost { background: #fff; border: 1px solid var(--border); color: #41617c; }
.btn-ghost:hover { background: #f2f8fa; color: var(--accent-dark); border-color: #cfe3e4; }

/* ===== ЗАГРУЗКА ===== */
.upload-screen { min-height: 100vh; display: flex; align-items: center; padding: 2rem 0; }
.upload-card { border-radius: 1.1rem; overflow: hidden; background: var(--card); border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(22, 50, 74, .10); }
.upload-hero { padding: 1.6rem 1.8rem; color: #fff; background: linear-gradient(120deg, rgba(255,255,255,.14), rgba(255,255,255,0)), linear-gradient(135deg, var(--accent), var(--accent-2)); }
.upload-body { padding: 1.8rem; }
.dropzone { border: 1.5px dashed #b9d3de; border-radius: .9rem; padding: 2.4rem 1.2rem; cursor: pointer; transition: .18s ease; background: linear-gradient(180deg, #fff, #f7fbfc); }
.dropzone:hover, .dropzone.active { border-color: var(--accent); background: #f0f9fa; box-shadow: inset 0 0 0 4px rgba(37, 158, 162, .06); }
.dropzone-icon { font-size: 2.6rem; color: var(--accent); }
.privacy-note { margin-top: 1rem; font-size: .82rem; color: #2d6d70; background: #eef7f7; border: 1px solid #d5eaea; border-radius: .7rem; padding: .7rem .9rem; }

/* ===== ОБОЛОЧКА ===== */
.topbar { position: sticky; top: 0; z-index: 1040; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 1rem; padding: .55rem 1.25rem; min-height: var(--topbar-h); }
.brand-title { font-weight: 800; font-size: .98rem; line-height: 1.15; }
.brand-sub { color: var(--muted); font-size: .74rem; }
.topbar-meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-left: auto; margin-right: .5rem; }
.shell { display: flex; align-items: flex-start; }
.sidebar { width: var(--sidebar-w); flex: 0 0 auto; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; background: #fbfdfe; border-right: 1px solid var(--border); padding: 1rem .8rem; }
.side-label { font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #93a6b8; padding: 0 .8rem .5rem; }
.side-nav { display: flex; flex-direction: column; gap: .2rem; }
.nav-btn { display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left; padding: .62rem .8rem; border: 0; border-radius: .7rem; background: transparent; color: #41617c; font-weight: 600; font-size: .9rem; }
.nav-btn i { font-size: 1.05rem; color: #7d97ab; }
.nav-btn:hover { background: #eef5f8; }
.nav-btn.active { background: linear-gradient(90deg, rgba(37,158,162,.14), rgba(24,163,143,.07)); color: var(--accent-dark); }
.nav-btn.active i { color: var(--accent); }
.nav-count { margin-left: auto; font-size: .7rem; font-weight: 800; color: #51718a; background: #e8f0f4; border-radius: 999px; padding: .16rem .5rem; }
.nav-btn.active .nav-count { background: #d5edee; color: var(--accent-dark); }
.side-note { margin-top: 1.2rem; font-size: .76rem; color: var(--muted); background: #f2f8f8; border: 1px solid #dfeeee; border-radius: .7rem; padding: .7rem .8rem; }
.side-note {display: flex; gap: .5rem; align-items: flex-start;}
.side-note i {margin-top: .15rem;}

.content { flex: 1; min-width: 0; padding: 1.4rem 1.6rem 2.5rem; }
.page { display: none; }
.page.active { display: block; animation: pageIn .25s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: 0; }
.page-title { font-size: 1.35rem; font-weight: 800; }
.page-sub { color: var(--muted); font-size: .88rem; }

.section-head { display: flex; align-items: center; gap: .55rem; margin: 0; font-weight: 800; font-size: .98rem; color: #22455f; }
.section-head i { color: var(--accent); font-size: 1.05rem; }

/* ===== ЕДИНЫЙ РИТМ ОТСТУПОВ ===== */
.page > * + * { margin-top: var(--gap); }
.row.g-3 { --bs-gutter-x: var(--gap); --bs-gutter-y: var(--gap); }

.card { border: 1px solid var(--border); border-radius: .9rem; overflow: hidden; box-shadow: 0 6px 20px rgba(22, 50, 74, .05); background: var(--card); margin-bottom: 0; }
.card > .card-body { padding: 1rem 1.1rem; }
.card-h { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); background: #fff; }
.h-icon { width: 34px; height: 34px; border-radius: .6rem; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; background: #e7f4f4; color: var(--accent); font-size: 1rem; }
.h-title { font-weight: 700; font-size: .93rem; color: #22455f; line-height: 1.2; }
.h-sub { color: var(--muted); font-size: .76rem; }
.h-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

/* ===== KPI ===== */
.kpi { border: 1px solid var(--border); border-radius: .9rem; background: #fff; padding: .95rem 1rem; height: 100%; display: flex; flex-direction: column; gap: .55rem; box-shadow: 0 6px 20px rgba(22, 50, 74, .05); }
.kpi-icon { width: 40px; height: 40px; border-radius: .8rem; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.kpi-value { font-size: 1.55rem; font-weight: 800; line-height: 1.05; color: #123049; }
.kpi-label { color: var(--muted); font-size: .82rem; font-weight: 700; margin-top: .12rem; }
.kpi-foot { margin-top: auto; padding-top: .5rem; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; align-items: center; font-size: .76rem; color: var(--muted); gap: .5rem; flex-wrap: wrap; }

/* ===== СИГНАЛЫ ===== */
.signal { display: flex; gap: .7rem; padding: .68rem .85rem; border-radius: .7rem; border: 1px solid; margin-bottom: .5rem; font-size: .87rem; }
.signal:last-child { margin-bottom: 0; }
.signal i { margin-top: .12rem; }
.signal.danger { background: #fdf3f2; border-color: #f2d9d5; color: #8d3a30; }
.signal.warning { background: #fcf8ec; border-color: #efe2bd; color: #7d651c; }
.signal.info { background: #f1f7fb; border-color: #d3e4f0; color: #2d5d80; }
.signal.success { background: #f2f9f4; border-color: #d7eadd; color: #2d6a44; }

/* ===== МЕТА ===== */
.meta-row { display: flex; justify-content: space-between; gap: 1rem; padding: .48rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.meta-row:last-child { border-bottom: 0; }
.meta-label { color: var(--muted); flex: 0 0 200px; }
.meta-value { font-weight: 700; text-align: right; }
.meta-chip { display: inline-flex; align-items: center; gap: .45rem; background: #fff; border: 1px solid var(--border); color: #30516b; border-radius: 999px; padding: .38rem .75rem; font-size: .8rem; }
.meta-chip i { color: var(--accent); }

/* ===== БЕЙДЖИ ===== */
.badge-soft { display: inline-block; font-weight: 600; font-size: .74rem; line-height: 1; border-radius: .45rem; padding: .34em .55em; border: 1px solid transparent; white-space: nowrap; }
.badge-neutral { background: #f4f7f9; color: #5c6d7e; border-color: #e2e8ee; }
.badge-good { background: #eef8f1; color: #3a7a52; border-color: #dcebe0; }
.badge-warn { background: #fbf7ec; color: #8a721f; border-color: #efe3c0; }
.badge-bad { background: #fcf3f2; color: #a0564b; border-color: #f2dfdb; }

/* ===== ДИАГРАММЫ ===== */
.col-chart { --chart-h: 230px; }
.col-chart-body { display: flex; gap: 6px; padding: 22px 6px 0; }
.col-group { flex: 1 1 0; min-width: 0; }
.col-bars { height: var(--chart-h); display: flex; align-items: flex-end; justify-content: center; gap: 5px; padding: 0 4px; border-bottom: 2px solid #dce6ee; }
.col-bar { flex: 1 1 0; max-width: 64px; min-height: 3px; border-radius: 6px 6px 0 0; position: relative; transition: height .3s ease; }
.col-bar.prev { background: #c9d7e4; }
.col-bar.curr { background: linear-gradient(180deg, #35b6ba, #18a38f); }
.col-bar.good { background: linear-gradient(180deg, #4cc08d, #2f9e6e); }
.col-bar.warn { background: linear-gradient(180deg, #e8c25c, #d9a83c); }
.col-bar.bad { background: linear-gradient(180deg, #e08a80, #d0685c); }
.col-val { position: absolute; top: -17px; left: 50%; transform: translateX(-50%); font-size: .68rem; font-weight: 700; color: #46647e; white-space: nowrap; }
.col-label { margin-top: .45rem; text-align: center; font-size: .74rem; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-legend { display: flex; flex-wrap: wrap; gap: 1.1rem; justify-content: center; margin-top: .8rem; font-size: .78rem; color: var(--muted); }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .4rem; vertical-align: -1px; }
.legend-swatch.prev { background: #c9d7e4; }
.legend-swatch.curr { background: linear-gradient(180deg, #35b6ba, #18a38f); }
.legend-swatch.good { background: linear-gradient(180deg, #4cc08d, #2f9e6e); }
.legend-swatch.warn { background: linear-gradient(180deg, #e8c25c, #d9a83c); }
.legend-swatch.bad { background: linear-gradient(180deg, #e08a80, #d0685c); }

/* ===== ГОРИЗОНТАЛЬНЫЕ БАРЫ ===== */
.bar-h { margin-bottom: .9rem; }
.bar-h:last-child { margin-bottom: 0; }
.bar-h-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .3rem; }
.bar-h-label { font-size: .85rem; font-weight: 600; color: #2d4862; }
.bar-h-value { font-size: .9rem; font-weight: 800; color: #123049; }
.bar-h-track { height: 11px; background: #edf2f6; border-radius: 6px; overflow: hidden; }
.bar-h-fill { height: 100%; border-radius: 6px; transition: width .4s ease; }
.bar-h-fill.good { background: linear-gradient(90deg, #4cc08d, #2f9e6e); }
.bar-h-fill.warn { background: linear-gradient(90deg, #e8c25c, #d9a83c); }
.bar-h-fill.bad { background: linear-gradient(90deg, #e08a80, #d0685c); }
.bar-h-fill.info { background: linear-gradient(90deg, #35b6ba, #18a38f); }
.bar-h-sub { font-size: .73rem; color: var(--muted); margin-top: .2rem; }

/* ===== ТАБЛИЦЫ ===== */
.table-scroll { max-height: 560px; overflow: auto; border-radius: .5rem; }
.data-table { table-layout: fixed; width: 100%; }
.data-table thead th { background: #f7fbfd; color: #40607a; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid #e1ebf2; white-space: normal; overflow-wrap: anywhere; vertical-align: middle; position: sticky; top: 0; z-index: 5; }
.data-table tbody td { overflow-wrap: anywhere; vertical-align: middle; font-size: .88rem; }
.data-table tbody tr:nth-child(odd) { background: #fcfeff; }
.data-table tbody tr:hover { background: #f2fafb; }
.data-table tbody tr[data-total="1"] td { font-weight: 800; background: #f0f8fa !important; }
.data-table th.center-cell, .data-table td.center-cell { text-align: center; }
th.sortable { cursor: pointer; position: relative; padding-right: 1.3rem; user-select: none; }
th.sortable::after {content: "\2195"; position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); color: #9db3c4; font-size: .7rem; line-height: 1;}
th.sorted-asc::after { content: "\2191"; color: var(--accent); }
th.sorted-desc::after { content: "\2193"; color: var(--accent); }
.dt-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.cell-tall { max-height: 6.2em; overflow-y: auto; display: block; line-height: 1.3; }
.empty-box { padding: 2.2rem 1rem; text-align: center; color: var(--muted); }
.empty-box i { font-size: 2.1rem; color: #b4c7d5; display: block; margin-bottom: .5rem; }

/* ===== ОВЕРЛЕЙ ===== */
.processing-overlay { position: fixed; inset: 0; z-index: 3000; background: rgba(247, 251, 254, .85); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; }
.processing-card { background: #fff; border: 1px solid var(--border); border-radius: 1rem; box-shadow: 0 18px 50px rgba(22, 50, 74, .14); padding: 2rem 3rem; text-align: center; }
.processing-card .spinner-border { width: 2.4rem; height: 2.4rem; color: var(--accent); }

/* ===== АДАПТИВ ===== */
@media (max-width: 991.98px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--border); padding: .6rem; }
  .side-nav { flex-direction: row; overflow-x: auto; gap: .3rem; }
  .nav-btn { white-space: nowrap; width: auto; }
  .side-note, .side-label { display: none; }
  .content { padding: 1rem; }
  .topbar-meta { display: none !important; }
}

/* ===== ПЕЧАТЬ ===== */
@media print {
  .no-print, .sidebar, .topbar { display: none !important; }
  .page { display: block !important; }
  .content { padding: 0; }
  body, html { background: #fff; }
  .card, .kpi { box-shadow: none; }
  .table-scroll { max-height: none; overflow: visible; }
}