@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
*, *::before, *::after { font-family: 'Inter', sans-serif; box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #f4f6fa; }
#dashboard { height: 100vh; display: flex; }

.sb { width: 236px; flex-shrink: 0; height: 100vh; display: flex; flex-direction: column; background: white; border-right: 1px solid #e9ecf2; }
.sb-brand { padding: 26px 22px 20px; }
.sb-brand h1 { font-size: 22px; font-weight: 900; color: #0b1120; letter-spacing: -.04em; }
.sb-brand p { font-size: 11px; color: #9ba8bb; margin-top: 4px; font-weight: 500; }
.sb-divider { height: 1px; background: #f0f3f8; margin: 0 18px; }
.sb-label { font-size: 10px; font-weight: 700; color: #c4cdd9; text-transform: uppercase; letter-spacing: .1em; padding: 16px 24px 8px; }
.sb-nav { flex: 1; padding: 2px 0; overflow-y: auto; }
.ni { display: flex; align-items: center; gap: 11px; width: calc(100% - 24px); margin: 2px 12px; padding: 10px 13px; border-radius: 10px; cursor: pointer; border: none; background: none; font-size: 13px; font-weight: 500; color: #7a8699; text-align: left; transition: background .12s, color .12s; }
.ni:hover { background: #f4f6fa; color: #374151; }
.ni.on { background: linear-gradient(135deg,#eff4ff 0%,#dbeafe 100%); color: #1d4ed8; font-weight: 700; box-shadow: inset 2px 0 0 #3b82f6; }
.ni.on svg { color: #2563eb; }
.ni svg { width: 15px; height: 15px; flex-shrink: 0; }
.sb-foot { padding: 12px 18px 16px; border-top: 1px solid #f0f3f8; }
.logout-btn { display: flex; align-items: center; gap: 9px; width: 100%; padding: 10px 13px; border-radius: 10px; border: none; background: none; cursor: pointer; color: #9ba8bb; font-size: 13px; font-weight: 600; transition: all .12s; }
.logout-btn:hover { background: #fff1f2; color: #ef4444; }

.main { flex: 1; min-width: 0; height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 52px; background: white; border-bottom: 1px solid #edf0f5; flex-shrink: 0; padding: 0 20px 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 10px; box-shadow: 0 1px 0 #edf0f5; }
.topbar-title { font-size: 15px; font-weight: 800; color: #0b1120; letter-spacing: -.02em; background: linear-gradient(90deg,#0b1120 0%,#1e3a8a 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.topbar-sub { font-size: 11px; color: #9ba8bb; margin-top: 1px; font-weight: 500; }
.topbar-badge { font-size: 11px; background: #f4f6fa; color: #5a6478; font-weight: 600; padding: 5px 12px; border-radius: 8px; white-space: nowrap; }
.mf { display: flex; gap: 3px; align-items: center; }
.fb { font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 7px; border: 1.5px solid #e4e8f0; background: white; color: #8899b0; cursor: pointer; transition: all .14s ease; white-space: nowrap; }
.fb:hover { background: #f4f6fa; color: #374151; border-color: #d0d5e0; }
.fb:active { transform: scale(.95); }
.fb.on { background: linear-gradient(135deg,#2563eb 0%,#1e40af 100%); color: white; border-color: #1d4ed8; box-shadow: 0 2px 8px rgba(37,99,235,.3); }

.page { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.page.active { display: flex; animation: fadeIn .25s ease; }
.cf { flex: 1; min-height: 0; position: relative; }
.card { background: white; border-radius: 14px; border: 1px solid #edf0f5; transition: box-shadow .18s ease, transform .18s ease; }
.card:hover { box-shadow: 0 4px 14px rgba(15,23,42,.05); }
.card-h { padding: 14px 18px; border-bottom: 1px solid #f4f6fa; flex-shrink: 0; }
.card-h .ttl { font-size: 12px; font-weight: 700; color: #0b1120; letter-spacing:-.01em; }
.card-h .sub { font-size: 11px; color: #9ba8bb; margin-top: 2px; font-weight: 500; }
.card-h .pill { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.li { width: 100%; border: 1.5px solid #e0e6ef; border-radius: 10px; padding: 12px 16px; font-size: 14px; outline: none; background: #f8f9fc; color: #0b1120; transition: all .2s; }
.li:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.1); background: white; }
.kpi-bar { height: 3px; border-radius: 3px; margin-top: 11px; }
.kpi-card { transition: transform .18s ease, box-shadow .18s ease; cursor: pointer; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,.06); }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 6px 11px; border-radius: 8px; border: 1.5px solid #e4e8f0; background: white; color: #5a6478; cursor: pointer; transition: all .14s ease; }
.icon-btn:hover { background: #f4f6fa; color: #1e293b; border-color: #cbd5e1; }
.icon-btn svg { width: 13px; height: 13px; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #dde2ec; border-radius: 4px; transition: background .15s; }
::-webkit-scrollbar-thumb:hover { background: #b8c2d4; }

@keyframes rise { from { opacity:0; transform:translateY(10px) } to { opacity:1; transform:none } }
@keyframes fadeIn { from { opacity:0; transform:translateY(4px) } to { opacity:1; transform:none } }
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 0 0 rgba(59,130,246,.4) } 50% { box-shadow: 0 0 0 8px rgba(59,130,246,0) } }
.rise { animation: rise .3s ease; }

/* ── Накладные modal (clickable KPI drill-down) ───────────────────────────── */
.clickable { cursor: pointer; position: relative; }
.clickable::after { content: '›'; position: absolute; top: 11px; right: 13px; font-size: 15px; font-weight: 800; color: #cbd5e1; transition: color .15s, transform .15s; z-index: 2; }
.clickable:hover::after { color: #06b6d4; transform: translateX(2px); }
.card-h.clickable::after { top: 12px; right: 14px; }
.kpi-hint { font-size: 9px; font-weight: 700; color: #06b6d4; text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; opacity: .85; }

.nk-overlay { display: none; position: fixed; inset: 0; z-index: 1000; background: rgba(15,23,42,.46); backdrop-filter: blur(3px); align-items: center; justify-content: center; padding: 28px; }
.nk-overlay.show { display: flex; animation: fadeIn .18s ease; }
.nk-panel { width: 100%; max-width: 920px; max-height: 86vh; background: #fff; border-radius: 18px; box-shadow: 0 24px 60px rgba(15,23,42,.28); display: flex; flex-direction: column; overflow: hidden; animation: rise .24s ease; }
.nk-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 24px 14px; border-bottom: 1px solid #f0f3f8; }
.nk-title { font-size: 17px; font-weight: 900; color: #0b1120; letter-spacing: -.02em; }
.nk-sub { font-size: 12px; color: #9ba8bb; margin-top: 3px; font-weight: 600; }
.nk-x { border: none; background: #f4f6fa; color: #6b7a93; width: 32px; height: 32px; border-radius: 9px; font-size: 22px; line-height: 1; cursor: pointer; transition: all .14s; }
.nk-x:hover { background: #fee2e2; color: #ef4444; }

.nk-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; padding: 16px 24px; background: #fafbfd; border-bottom: 1px solid #f0f3f8; }
.nk-stat { display: flex; align-items: center; gap: 9px; }
.nk-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.nk-stat-l { font-size: 9.5px; font-weight: 700; color: #9ba8bb; text-transform: uppercase; letter-spacing: .06em; }
.nk-stat-v { font-size: 19px; font-weight: 900; color: #0b1120; letter-spacing: -.02em; line-height: 1.15; }

.nk-toolbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid #f4f6fa; flex-wrap: wrap; }
.nk-search { flex: 1; min-width: 180px; border: 1.5px solid #e4e8f0; border-radius: 9px; padding: 9px 13px; font-size: 13px; background: #f8f9fc; color: #0b1120; outline: none; transition: all .16s; }
.nk-search:focus { border-color: #06b6d4; background: #fff; box-shadow: 0 0 0 3px rgba(6,182,212,.12); }
.nk-sorts { display: flex; gap: 4px; }
.nk-sb { font-size: 11px; font-weight: 700; padding: 7px 11px; border-radius: 8px; border: 1.5px solid #e4e8f0; background: #fff; color: #8899b0; cursor: pointer; transition: all .14s; white-space: nowrap; }
.nk-sb:hover { background: #f4f6fa; color: #374151; }
.nk-sb.on { background: linear-gradient(135deg,#06b6d4 0%,#0891b2 100%); color: #fff; border-color: #0891b2; box-shadow: 0 2px 8px rgba(6,182,212,.3); }

.nk-body { overflow-y: auto; padding: 8px 16px 18px; flex: 1; min-height: 0; }
.nk-thead, .nk-ihead { display: grid; align-items: center; padding: 8px 12px; font-size: 10px; font-weight: 800; color: #b0bac9; text-transform: uppercase; letter-spacing: .05em; position: sticky; top: 0; background: #fff; z-index: 1; }
.nk-thead { grid-template-columns: 30px 1fr 90px 64px 56px 90px 18px; gap: 8px; }
.nk-row { display: grid; grid-template-columns: 30px 1fr 90px 64px 56px 90px 18px; gap: 8px; align-items: center; width: 100%; text-align: left; border: none; background: none; border-radius: 10px; padding: 9px 12px; cursor: pointer; transition: background .12s; border-bottom: 1px solid #f6f8fb; }
.nk-row:hover { background: #f4fbfd; }
.nk-rk { font-size: 11px; font-weight: 800; color: #c4cdd9; }
.nk-rn { font-size: 12.5px; font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nk-rb { height: 5px; background: #f0f3f8; border-radius: 3px; overflow: hidden; }
.nk-rbar { display: block; height: 5px; background: linear-gradient(90deg,#06b6d4,#22d3ee); border-radius: 3px; }
.nk-rc { text-align: center; }
.nk-rc b, .nk-rs { font-size: 13px; font-weight: 800; color: #0b1120; }
.nk-rc small, .nk-rs small { font-size: 9.5px; font-weight: 600; color: #9ba8bb; margin-left: 3px; }
.nk-rs { text-align: right; }
.nk-rchev { font-size: 16px; font-weight: 800; color: #cbd5e1; text-align: center; }
.nk-row:hover .nk-rchev { color: #06b6d4; }

.nk-drillhead { padding: 6px 12px 14px; }
.nk-back { border: none; background: none; color: #06b6d4; font-size: 12px; font-weight: 800; cursor: pointer; padding: 6px 0; }
.nk-back:hover { text-decoration: underline; }
.nk-dn { font-size: 16px; font-weight: 900; color: #0b1120; margin-top: 6px; letter-spacing: -.01em; }
.nk-dchips { display: flex; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.nk-chip { font-size: 11px; font-weight: 700; color: #5a6478; background: #f4f6fa; padding: 5px 11px; border-radius: 20px; }
.nk-chip-g { background: #ecfdf5; color: #059669; }
.nk-ihead { grid-template-columns: 1fr 96px 1fr 56px 56px 84px; gap: 8px; }
.nk-irow { display: grid; grid-template-columns: 1fr 96px 1fr 56px 56px 84px; gap: 8px; align-items: center; padding: 9px 12px; border-bottom: 1px solid #f6f8fb; font-size: 12.5px; }
.nk-irow:hover { background: #fafbfd; }
.nk-ink { font-weight: 800; color: #0b1120; }
.nk-idt { color: #6b7a93; font-weight: 600; font-size: 12px; }
.nk-ireg { color: #1e293b; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nk-ic { text-align: center; font-weight: 700; color: #334155; }
.nk-ic small { font-size: 9.5px; color: #9ba8bb; margin-left: 2px; font-weight: 600; }
.nk-is { text-align: right; font-weight: 800; color: #0b1120; }
.nk-is small { font-size: 9.5px; color: #9ba8bb; margin-left: 2px; font-weight: 600; }
.nk-empty { text-align: center; color: #9ba8bb; font-size: 13px; font-weight: 600; padding: 40px 0; }
@media (max-width: 720px) {
  .nk-stats { grid-template-columns: repeat(2,1fr); }
  .nk-thead, .nk-row { grid-template-columns: 24px 1fr 56px 78px 16px; }
  .nk-thead span:nth-child(3), .nk-row .nk-rb, .nk-thead span:nth-child(5), .nk-row .nk-rc:nth-of-type(2) { display: none; }
}

/* ── BI data explorer ─────────────────────────────────────────────────────── */
.bi-overlay { display: none; position: fixed; inset: 0; z-index: 1100; background: rgba(15,23,42,.5); backdrop-filter: blur(3px); align-items: center; justify-content: center; padding: 22px; }
.bi-overlay.show { display: flex; animation: fadeIn .16s ease; }
.bi-panel { width: 100%; max-width: 1180px; height: 90vh; background: #fff; border-radius: 18px; box-shadow: 0 24px 64px rgba(15,23,42,.3); display: flex; flex-direction: column; overflow: hidden; animation: rise .22s ease; }
.bi-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid #f0f3f8; flex-shrink: 0; }
.bi-title { font-size: 16px; font-weight: 900; color: #0b1120; letter-spacing: -.02em; }
.bi-crumb { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.bi-tag { font-size: 10.5px; font-weight: 700; color: #0369a1; background: #e0f2fe; padding: 3px 8px; border-radius: 14px; }
.bi-tag b { cursor: pointer; margin-left: 3px; color: #0284c7; }
.bi-tag b:hover { color: #ef4444; }
.bi-head-actions { display: flex; align-items: center; gap: 8px; }
.bi-csv { border: 1.5px solid #d1fae5; background: #ecfdf5; color: #059669; font-size: 11px; font-weight: 800; padding: 7px 12px; border-radius: 9px; cursor: pointer; transition: all .14s; }
.bi-csv:hover { background: #059669; color: #fff; border-color: #059669; }
.bi-x { border: none; background: #f4f6fa; color: #6b7a93; width: 32px; height: 32px; border-radius: 9px; font-size: 22px; line-height: 1; cursor: pointer; transition: all .14s; }
.bi-x:hover { background: #fee2e2; color: #ef4444; }

.bi-stats { display: grid; grid-template-columns: repeat(8,1fr); gap: 8px; padding: 13px 22px; background: #fafbfd; border-bottom: 1px solid #f0f3f8; flex-shrink: 0; }
.bi-stat { display: flex; align-items: center; gap: 7px; }
.bi-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bi-stat-l { font-size: 9px; font-weight: 700; color: #9ba8bb; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.bi-stat-v { font-size: 16px; font-weight: 900; color: #0b1120; letter-spacing: -.02em; line-height: 1.15; }

.bi-filters { display: grid; grid-template-columns: repeat(8,1fr); gap: 8px; padding: 12px 22px; border-bottom: 1px solid #f4f6fa; flex-shrink: 0; }
.bi-fcell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bi-fcell label { font-size: 9px; font-weight: 800; color: #b0bac9; text-transform: uppercase; letter-spacing: .04em; }
.bi-sel { border: 1.5px solid #e4e8f0; border-radius: 8px; padding: 6px 7px; font-size: 11.5px; background: #fff; color: #1e293b; outline: none; cursor: pointer; max-width: 100%; }
.bi-sel:focus { border-color: #06b6d4; box-shadow: 0 0 0 3px rgba(6,182,212,.1); }

.bi-subbar { display: flex; align-items: center; gap: 10px; padding: 11px 22px; border-bottom: 1px solid #f4f6fa; flex-shrink: 0; }
.bi-group { display: flex; align-items: center; gap: 7px; }
.bi-glabel { font-size: 11px; font-weight: 700; color: #6b7a93; }
.bi-search { flex: 1; border: 1.5px solid #e4e8f0; border-radius: 9px; padding: 8px 12px; font-size: 12.5px; background: #f8f9fc; color: #0b1120; outline: none; transition: all .15s; }
.bi-search:focus { border-color: #06b6d4; background: #fff; box-shadow: 0 0 0 3px rgba(6,182,212,.1); }
.bi-reset { border: 1.5px solid #e4e8f0; background: #fff; color: #8899b0; font-size: 11px; font-weight: 700; padding: 8px 13px; border-radius: 9px; cursor: pointer; transition: all .14s; }
.bi-reset:hover { background: #fff1f2; color: #ef4444; border-color: #fecaca; }

.bi-tablewrap { flex: 1; min-height: 0; overflow: auto; padding: 0 12px 8px; }
.bi-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bi-th { position: sticky; top: 0; background: #fff; z-index: 1; font-size: 10px; font-weight: 800; color: #8e9bb0; text-transform: uppercase; letter-spacing: .03em; padding: 10px 10px; cursor: pointer; white-space: nowrap; border-bottom: 2px solid #f0f3f8; user-select: none; }
.bi-th.l { text-align: left; } .bi-th.r { text-align: right; } .bi-th.c { text-align: center; }
.bi-th:hover { color: #06b6d4; } .bi-th.on { color: #06b6d4; }
.bi-table td { padding: 8px 10px; border-bottom: 1px solid #f6f8fb; color: #334155; vertical-align: top; }
.bi-table td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bi-table td.b { font-weight: 800; color: #0b1120; }
.bi-table td.neg { color: #ef4444; font-weight: 700; }
.bi-table tbody tr:hover { background: #f8fbfc; }
.bi-mono { font-weight: 700; color: #0b1120; }
.bi-prod { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #64748b; }
.bi-cap { font-size: 11px; color: #9ba8bb; font-weight: 600; padding: 10px 12px; }
.bi-grow.drill { cursor: pointer; }
.bi-grow.drill:hover { background: #f0fbfd; }
.bi-gk { position: relative; min-width: 220px; }
.bi-gbar { position: absolute; left: 0; top: 50%; transform: translateY(-50%); height: 22px; background: linear-gradient(90deg,rgba(6,182,212,.14),rgba(6,182,212,.04)); border-radius: 5px; z-index: 0; }
.bi-gname { position: relative; z-index: 1; font-weight: 600; color: #1e293b; }
.bi-chev { text-align: center; font-size: 16px; font-weight: 800; color: #cbd5e1; }
.bi-grow.drill:hover .bi-chev { color: #06b6d4; }
@media (max-width: 980px) {
  .bi-stats, .bi-filters { grid-template-columns: repeat(4,1fr); }
}
