*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #206bc4;
    --primary-light: #e8f1fb;
    --sidebar-w: 240px;
    --navbar-h: 60px;
    --body-bg: #f6f8fa;
    --card-bg: #fff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-soft: #94a3b8;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--body-bg);
    color: var(--text);
    min-height: 100vh;
}

/* ===== Splash / Login ===== */
.splash-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.splash-card {
    background: #fff;
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,.3);
}

.splash-logo { text-align: center; margin-bottom: 32px; }

.splash-logo h1 {
    font-size: 28px; font-weight: 700; color: #0f172a; letter-spacing: -0.5px;
}
.splash-logo span {
    display: block; font-size: 14px; color: var(--text-muted); font-weight: 400; margin-top: 4px;
}

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 600; color: #475569;
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.form-control {
    width: 100%; padding: 12px 16px; border: 2px solid var(--border);
    border-radius: 10px; font-size: 15px; outline: none; background: #f8fafc;
    transition: all .2s;
}
.form-control:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(32,107,196,.1); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 24px; border: none; border-radius: 10px;
    font-size: 15px; font-weight: 600; cursor: pointer; transition: all .2s; gap: 8px;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: #1a5aa8; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(32,107,196,.3); }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 8px; }
.btn-outline { background: transparent; border: 1.5px solid #cbd5e1; color: #475569; }
.btn-outline:hover { background: #f1f5f9; border-color: #94a3b8; }

.btn-danger-outline {
    background: #fef2f2; border: 1.5px solid #fecaca; color: #dc2626;
}
.btn-danger-outline:hover { background: #fee2e2; border-color: #fca5a5; }

.btn-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.btn-icon:hover {
    background: #f1f5f9;
    border-color: var(--primary);
    color: var(--primary);
}

.alert { padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 20px; }
.alert-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* ===== Dashboard Layout ===== */
.dashboard { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: #0f172a; color: #fff;
    display: flex; flex-direction: column;
    overflow-y: auto;
}

.sidebar-brand {
    display: block; padding: 20px 24px; border-bottom: 1px solid rgba(255,255,255,.08);
    font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
    color: #fff; text-decoration: none; cursor: pointer;
}
.sidebar-brand:hover { background: rgba(255,255,255,.04); }
.sidebar-brand span { display: block; font-size: 11px; color: var(--text-soft); font-weight: 400; margin-top: 2px; }

.sidebar-nav { padding: 12px 0; flex: 1; }

/* Группы пунктов — разделы дашборда будут прибавляться, плоский список поплывёт */
.nav-section {
    padding: 16px 24px 6px; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; color: #64748b;
}

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 24px; font-size: 14px; color: #94a3b8;
    cursor: pointer; transition: all .15s; border-left: 3px solid transparent;
    text-decoration: none; user-select: none;
}
.nav-item:hover { color: #e2e8f0; background: rgba(255,255,255,.04); }
.nav-item.active {
    color: #fff; background: rgba(32,107,196,.15);
    border-left-color: var(--primary); font-weight: 600;
}

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 16px 24px; border-top: 1px solid rgba(255,255,255,.08);
    font-size: 12px; color: var(--text-soft);
}

/* Main content area */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Top navbar (inside main) */
.topbar {
    height: var(--navbar-h); min-height: var(--navbar-h);
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 0 28px; display: flex; align-items: center; justify-content: space-between;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* Кнопка меню и затемнение нужны только телефону — см. блок @media в конце файла */
.nav-toggle {
    display: none; width: 40px; height: 40px; border: none; border-radius: 8px;
    background: transparent; color: var(--text); cursor: pointer;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.nav-toggle:hover { background: #f1f5f9; }
.sidebar-backdrop { display: none; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

/* Content panel */
.content { flex: 1; overflow-y: auto; padding: 28px; }

/* ===== Главная: плитки разделов ===== */
/* Группы те же, что в сайдбаре: контент товара отдельно от того,
   что происходит с ним на площадках. */
.home-section {
    max-width: 1100px; margin: 26px auto 0;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-soft);
}
.home-section:first-child { margin-top: 4px; }
.home-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px; max-width: 1100px; margin: 12px auto 0;
}
.home-tile {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px;
    padding: 24px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
    display: flex; flex-direction: column; gap: 6px; min-height: 170px;
}
.home-tile:hover {
    transform: translateY(-2px); border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(15,23,42,.08);
}
.home-tile.soon { cursor: default; opacity: .55; }
.home-tile.soon:hover { transform: none; border-color: var(--border); box-shadow: none; }
.tile-icon { font-size: 30px; line-height: 1; margin-bottom: 6px; }
.tile-title { font-size: 17px; font-weight: 700; }
.tile-meta { margin-top: auto; }
.tile-count { font-size: 26px; font-weight: 700; color: var(--primary); }
/* Разбивка по площадкам вместо крупного числа (плитка рича) */
.tile-lines { font-size: 15px; font-weight: 600; color: var(--primary); }

/* ===== Раздел «Рич-контент»: карточки по площадкам ===== */
.mp-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mp-chip {
    display: inline-block; padding: 2px 8px; border-radius: 20px;
    font-size: 11px; font-weight: 700; letter-spacing: .3px;
    background: var(--primary-light); color: var(--primary);
}
.rich-cards {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px; padding: 16px;
}
.rich-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
    padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.rich-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rich-card-date { font-size: 12px; color: var(--text-soft); }
/* Мокап длинный: показываем верх карточки, целиком открывается по клику. */
.rich-mockup {
    display: block; max-height: 340px; overflow: hidden; border-radius: 8px;
    border: 1px solid var(--border); background: #fff;
}
.rich-mockup img { display: block; width: 100%; }
.rich-mockup.empty {
    display: flex; align-items: center; justify-content: center; height: 120px;
    font-size: 13px; color: var(--text-soft); background: transparent;
}
.rich-card .btn { align-self: flex-start; }
.tile-unit { font-size: 13px; color: var(--text-muted); }
.tile-hint { font-size: 12px; color: var(--text-soft); line-height: 1.5; }
.tile-soon {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    background: var(--primary-light); color: var(--primary);
}

/* ===== Срезы поперёк товаров («Чертежи», «Слайды»): карточки SKU ===== */
.sku-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px;
}
.sku-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
    padding: 14px 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.sku-card:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(15,23,42,.07); }
.sku-card.empty { background: #fbfcfd; }
.sku-card.empty .sku-count { color: var(--text-soft); }
.sku-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.sku-cat { font-size: 12px; color: var(--text-soft); }
.sku-count { font-size: 12px; color: var(--primary); margin-top: 8px; }

.pdf-frame { width: 100%; height: 72vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

/* ===== Tab: TBD stub ===== */
.tbd-card {
    background: #fff; border-radius: 14px; border: 1px solid var(--border);
    padding: 48px; text-align: center; max-width: 600px; margin: 40px auto 0;
}
.tbd-card .tbd-icon { font-size: 48px; margin-bottom: 20px; opacity: .5; }
.tbd-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.tbd-card p { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 12px; }
.tbd-badge {
    display: inline-block; padding: 4px 12px; border-radius: 20px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    background: var(--primary-light); color: var(--primary);
}

/* ===== Tab: Products (file browser) ===== */
.file-browser { }
.file-browser-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.file-browser-header h2 { font-size: 20px; font-weight: 700; }
.search-input {
    padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; width: 240px; outline: none; background: #f8fafc;
    transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(32,107,196,.12); }
.search-input::placeholder { color: #94a3b8; }

.search-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,.12);
    max-height: 360px;
    overflow-y: auto;
    z-index: 600;
    padding: 6px;
}
.search-dd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.search-dd-item:hover { background: var(--primary-light); color: var(--primary); }
.search-dd-item b { color: var(--primary); }

.breadcrumbs {
    display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted);
    margin-bottom: 20px; flex-wrap: wrap; position: relative;
}
.breadcrumbs a { color: var(--primary); text-decoration: none; cursor: pointer; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { color: #cbd5e1; }

.breadcrumb-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,.12);
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 500;
    padding: 6px;
}
.breadcrumb-dd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.breadcrumb-dd-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.file-table {
    width: 100%; border-collapse: collapse; background: #fff;
    border-radius: 12px; overflow: hidden; border: 1px solid var(--border);
}
.file-table th {
    text-align: left; padding: 12px 20px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted);
    background: #f8fafc; border-bottom: 1px solid var(--border);
}
.file-table td { padding: 10px 20px; font-size: 14px; border-bottom: 1px solid #f1f5f9; }
.file-table tr:last-child td { border-bottom: none; }
.file-table tr:hover td { background: #f8fafc; }

.file-row { cursor: pointer; }
.file-name { font-weight: 500; display: flex; align-items: center; gap: 10px; }
.file-icon { width: 18px; height: 18px; opacity: .6; flex-shrink: 0; }
.file-type { font-size: 12px; color: var(--text-soft); }
.file-size { font-size: 12px; color: var(--text-soft); text-align: right; }

/* ===== File viewer modal ===== */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,42,.7); backdrop-filter: blur(4px);
    z-index: 200; align-items: center; justify-content: center; padding: 40px;
}
.modal-overlay.active { display: flex; }

.modal-dialog {
    background: #fff; border-radius: 18px; width: 100%; max-width: 900px;
    max-height: 85vh; display: flex; flex-direction: column;
    box-shadow: 0 30px 80px rgba(0,0,0,.25);
}

.modal-dialog.wide { max-width: 1100px; }

.modal-header {
    padding: 20px 28px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: #f1f5f9; cursor: pointer; font-size: 20px;
    display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.modal-close:hover { background: #e2e8f0; }

.modal-body { padding: 24px 28px; overflow-y: auto; }

/* Gallery in modal */
.gallery-grid-modal {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px;
}
.gallery-grid-modal img {
    width: 100%; height: 200px; object-fit: cover; border-radius: 10px; cursor: pointer;
    transition: transform .2s;
}
.gallery-grid-modal img:hover { transform: scale(1.03); }

/* ===== Gallery grid (file browser) ===== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.gallery-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
}

.gallery-thumb {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: #f1f5f9;
    cursor: pointer;
}
.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-label {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.gallery-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px 8px 12px;
    gap: 4px;
}

/* Selection mode */
.gallery-check {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.8);
    background: rgba(0,0,0,.3);
    color: #fff;
    font-size: 14px;
    align-items: center;
    justify-content: center;
    z-index: 2;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}
.gallery-grid.selecting .gallery-check {
    display: flex;
    opacity: .7;
}
.gallery-grid.selecting .gallery-card:hover .gallery-check {
    opacity: 1;
}
.gallery-card.selected .gallery-check {
    display: flex !important;
    opacity: 1 !important;
    background: var(--primary);
    border-color: var(--primary);
}
.gallery-card.selected {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
    border-radius: 14px;
}

.select-bar {
    position: sticky;
    bottom: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 -2px 16px rgba(0,0,0,.06);
    padding: 12px 20px;
    margin: 20px auto 0;
    display: inline-flex;
    align-items: center;
    gap: 20px;
    z-index: 10;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.btn-link {
    background: #f1f5f9;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
    padding: 3px 8px;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
    color: var(--text-muted);
}
.btn-link:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.file-action {
    width: 80px;
    text-align: center;
    padding: 4px !important;
    white-space: nowrap;
}
.file-action .btn-link {
    display: inline-flex;
}

/* Code / text viewer */
.code-block {
    background: #1e293b; color: #e2e8f0; border-radius: 10px;
    padding: 20px; font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 13px; line-height: 1.6; overflow-x: auto; white-space: pre-wrap;
    max-height: 60vh; overflow-y: auto;
}

.md-content { font-size: 14px; line-height: 1.8; }
.md-content h1, .md-content h2, .md-content h3 { margin: 16px 0 8px; }
.md-content h2 { font-size: 18px; }
.md-content h3 { font-size: 15px; }
.md-content p { margin-bottom: 10px; }
.md-content ul, .md-content ol { padding-left: 24px; margin-bottom: 10px; }
.md-content li { margin-bottom: 4px; }
.md-content code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.md-content pre { background: #1e293b; color: #e2e8f0; border-radius: 8px; padding: 14px 16px; overflow-x: auto; margin-bottom: 12px; }
.md-content pre code { background: none; color: inherit; padding: 0; font-size: 13px; }
.md-content a { color: var(--primary, #2563eb); }
.md-content hr { border: 0; border-top: 1px solid #e2e8f0; margin: 16px 0; }
.md-content table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; display: block; overflow-x: auto; }
.md-content th, .md-content td { border: 1px solid #e2e8f0; padding: 8px 12px; text-align: left; vertical-align: top; }
.md-content th { background: #f8fafc; font-weight: 600; }
.md-content tbody tr:nth-child(even), .md-content tbody tr:nth-child(even) { background: #fafbfc; }

.html-frame { width: 100%; height: 72vh; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; }

/* Loading & Empty */
.loading { text-align: center; padding: 60px 20px; color: var(--text-soft); }
.spinner {
    width: 36px; height: 36px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin .8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 80px 20px; color: var(--text-soft); }
.empty-state svg { width: 64px; height: 64px; opacity: .2; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text-muted); margin-bottom: 6px; }

/* Toast */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: #0f172a; color: #fff; padding: 12px 20px;
    border-radius: 10px; font-size: 14px; z-index: 300;
    animation: slideUp .3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Lightbox */
.lightbox-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.92);
    z-index: 400; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox-overlay.active { display: flex; }
.lightbox-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 8px; cursor: default; }

.lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,.1); color: #fff; border: none;
    font-size: 48px; width: 56px; height: 56px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s; z-index: 401; line-height: 1;
}
.lightbox-nav:hover { background: rgba(255,255,255,.25); }
.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }

.lightbox-counter {
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    color: rgba(255,255,255,.6); font-size: 14px; z-index: 401;
}

.lightbox-close {
    position: absolute; top: 16px; right: 24px;
    background: rgba(255,255,255,.1); color: #fff; border: none;
    font-size: 32px; width: 44px; height: 44px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s; z-index: 401; line-height: 1;
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ===== Раздел «Маркетинг»: продажи по каналам ===== */
/* Цвета графиков — отдельные роли, а не цвета интерфейса: --mkt-series для
   одиночной серии (везде, где сравниваются величины одного показателя) и три шага
   одного синего для месяцев — шкала упорядоченная, поэтому ramp, а не разные хюэ.
   Значения выбраны валидатором палитры против белой карточки; темы у дашборда
   одна, светлая, поэтому второго набора шагов нет. */
.mkt {
    --mkt-series: #2a78d6;
    --mkt-m1: #86b6ef;
    --mkt-m2: #3987e5;
    --mkt-m3: #1c5cab;
    --mkt-track: #f1f5f9;
    --mkt-grid: #e2e8f0;
    max-width: 1100px;
}
.mkt-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.mkt-head h2 { font-size: 20px; font-weight: 700; }
.mkt-source { font-size: 12px; color: var(--text-soft); }

/* KPI: одна крупная цифра на экран, остальные — обычные плитки */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
/* Главная цифра экрана. Сумма в гривнах длинная, поэтому плитка занимает две
   колонки и число не переносится — перенос ломает его на «7 691 218» и «₴». */
.kpi.hero { grid-column: span 2; }
.kpi.hero .kpi-value { font-size: 40px; line-height: 1.1; white-space: nowrap; }
@media (max-width: 720px) { .kpi.hero { grid-column: auto; } .kpi.hero .kpi-value { font-size: 30px; } }
.kpi-note { font-size: 12px; color: var(--text-soft); margin-top: 6px; }
.kpi-note.up { color: #006300; }

.mkt-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px;
    padding: 22px 24px; margin-bottom: 20px;
}
.mkt-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.mkt-card .mkt-sub { font-size: 12px; color: var(--text-soft); margin-bottom: 18px; }

/* Легенда: всегда при двух и более сериях */
.mkt-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.mkt-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.mkt-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Колонки: выручка по месяцам */
/* Ширина ограничена: три колонки по 24px посреди карточки в 1100px читаются как
   потерянные, а тянуть саму колонку правило запрещает. */
.mkt-cols { display: flex; align-items: flex-end; gap: 28px; height: 220px; padding-top: 28px; border-bottom: 1px solid var(--mkt-grid); max-width: 560px; }
.mkt-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.mkt-col-bar {
    width: 100%; max-width: 24px; background: var(--mkt-series);
    border-radius: 4px 4px 0 0; transition: filter .15s;
}
.mkt-col:hover .mkt-col-bar, .mkt-col:focus-visible .mkt-col-bar { filter: brightness(1.12); }
.mkt-col:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 6px; }
.mkt-col-cap { position: absolute; top: -22px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.mkt-cols-x { display: flex; gap: 28px; margin-top: 8px; max-width: 560px; }
.mkt-cols-x span { flex: 1; text-align: center; font-size: 12px; color: var(--text-muted); }

/* Горизонтальные бары: рейтинги направлений и каналов */
.mkt-bars { display: flex; flex-direction: column; gap: 10px; }
.mkt-bar { display: grid; grid-template-columns: 190px 1fr 150px; align-items: center; gap: 14px; }
.mkt-bar-name { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkt-bar-track { background: var(--mkt-track); border-radius: 4px; height: 18px; display: flex; overflow: hidden; }
.mkt-bar-fill { background: var(--mkt-series); height: 100%; border-radius: 0 4px 4px 0; transition: filter .15s; }
.mkt-bar-seg { height: 100%; }
/* Соседние сегменты разделяет полоса цвета карточки, а не обводка: обводка добавила
   бы чернил, которых нет в данных. Тень соседа ложится поверх предыдущего сегмента. */
.mkt-bar-seg + .mkt-bar-seg { box-shadow: -2px 0 0 0 var(--card-bg); }
.mkt-bar-seg:last-child { border-radius: 0 4px 4px 0; }
.mkt-bar-fill:hover, .mkt-bar-seg:hover { filter: brightness(1.12); }
.mkt-bar-fill:focus-visible, .mkt-bar-seg:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.mkt-bar-val { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.mkt-bar-share { color: var(--text-soft); margin-left: 8px; }

/* Таблица-двойник: те же числа без цвета и наведения */
.mkt-table-toggle { margin-top: 18px; font-size: 13px; color: var(--primary); cursor: pointer; }
.mkt-table-toggle::marker { color: var(--text-soft); }
.mkt-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.mkt-table th, .mkt-table td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; text-align: right; }
.mkt-table th:first-child, .mkt-table td:first-child { text-align: left; }
.mkt-table thead th { color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.mkt-table td { font-variant-numeric: tabular-nums; }
.mkt-table tfoot td { font-weight: 700; border-top: 1px solid var(--border); border-bottom: none; }

/* Тултип графиков */
.mkt-tip {
    position: fixed; z-index: 500; pointer-events: none; display: none;
    background: #0f172a; color: #fff; border-radius: 8px; padding: 8px 12px;
    font-size: 12px; line-height: 1.5; box-shadow: 0 8px 24px rgba(15,23,42,.25);
    max-width: 280px;
}
.mkt-tip.active { display: block; }
.mkt-tip b { font-size: 14px; display: block; }
.mkt-tip span { color: #cbd5e1; }

/* ===== Welcome card on dashboard ===== */
.welcome-card {
    background: #fff; border-radius: 14px; border: 1px solid var(--border);
    padding: 32px; margin-bottom: 24px;
}
.welcome-card h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.welcome-card p { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

/* ===== Телефон ===== */
/* Вся мобильная вёрстка — в этом блоке: компьютерная версия его не видит, и правка
   здесь не может её сломать. Граница 768px — планшет в портрете уже получает меню
   за кнопкой, 240px сайдбара ему тоже много. */
@media (max-width: 768px) {
    .dashboard { height: 100vh; height: 100dvh; }

    /* Сайдбар выезжает поверх контента по кнопке ☰ */
    .sidebar {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 300;
        width: 272px; min-width: 0; max-width: 85vw;
        transform: translateX(-100%); transition: transform .2s ease;
    }
    .dashboard.nav-open .sidebar { transform: none; box-shadow: 8px 0 32px rgba(0,0,0,.3); }
    .dashboard.nav-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 250; background: rgba(15,23,42,.5);
    }
    .nav-item { padding: 12px 24px; }
    .nav-toggle { display: inline-flex; }

    /* Шапка: синхронизация — одной иконкой, имя пользователя прячем */
    .topbar { padding: 0 8px 0 4px; }
    .topbar-right { gap: 8px; }
    .topbar-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    #syncBtn .btn-label, #userLabel { display: none; }
    #syncBtn { padding: 8px 10px; }

    .content { padding: 16px; }

    /* Главная */
    .home-section { margin-top: 20px; }
    .home-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .home-tile { padding: 16px; min-height: 0; border-radius: 14px; }
    .tile-icon { font-size: 24px; }
    .tile-title { font-size: 15px; }
    .tile-count { font-size: 20px; }
    .tile-lines { font-size: 13px; }

    /* Заголовок раздела: поиск и счётчик уходят на свою строку во всю ширину.
       У обёртки справа инлайновые flex и justify-content, поэтому !important. */
    .file-browser-header { flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
    .file-browser-header h2 { font-size: 18px; }
    .file-browser-header > div { flex: 1 1 100% !important; flex-wrap: wrap; justify-content: flex-start !important; }
    .search-input { width: auto; flex: 1 1 100%; font-size: 16px; } /* 16px — iOS не зумит поле при фокусе */

    /* Таблица файлов: остаются имя и кнопки */
    .file-table th, .file-table td { padding: 10px 12px; }
    .file-table .file-type, .file-table .file-size,
    .file-table thead th:nth-child(2), .file-table thead th:nth-child(3) { display: none; }
    .file-name { word-break: break-word; }
    .file-action { width: auto; }

    /* Сетки карточек — по две в ряд */
    .gallery-grid, .sku-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .rich-cards { grid-template-columns: 1fr; padding: 0; gap: 12px; }
    .select-bar { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
    .tbd-card { padding: 32px 20px; margin-top: 16px; }

    /* Просмотр файла — на весь экран */
    .modal-overlay { padding: 0; }
    .modal-dialog, .modal-dialog.wide { max-width: none; max-height: none; height: 100%; border-radius: 0; }
    .modal-header { padding: 12px 16px; gap: 10px; }
    .modal-header h3 { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .modal-close { flex-shrink: 0; }
    .modal-body { padding: 12px; flex: 1; }
    .pdf-frame, .html-frame { height: calc(100dvh - 110px); }
    .gallery-grid-modal { grid-template-columns: 1fr 1fr; gap: 10px; }
    .gallery-grid-modal img { height: 150px; }

    /* Лайтбокс: стрелки меньше и у краёв, на тёмной подложке — чертёж белый, и
       полупрозрачная белая стрелка на нём пропадает. Листать можно и свайпом. */
    .lightbox-overlay img { max-width: 100vw; max-height: 80vh; border-radius: 0; }
    .lightbox-nav { width: 40px; height: 40px; font-size: 30px; background: rgba(15,23,42,.55); }
    .lightbox-prev { left: 6px; }
    .lightbox-next { right: 6px; }
    .lightbox-close { top: 10px; right: 10px; }

    /* Маркетинг: имя и сумма строкой над полосой — рядом с ней места нет */
    .mkt-head { margin-bottom: 14px; }
    /* Выручка во всю ширину, продажи и чек — парой под ней */
    .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
    .kpi.hero { grid-column: 1 / -1; }
    .kpi { padding: 16px; }
    .kpi-value { font-size: 22px; }
    .mkt-card { padding: 16px; margin-bottom: 14px; }
    .mkt-bars { gap: 12px; }
    .mkt-bar { grid-template-columns: 1fr auto; gap: 4px 10px; }
    .mkt-bar-name { grid-column: 1; grid-row: 1; }
    .mkt-bar-val { grid-column: 2; grid-row: 1; font-size: 12px; }
    .mkt-bar-track { grid-column: 1 / -1; grid-row: 2; height: 14px; }
    .mkt-cols, .mkt-cols-x { gap: 12px; max-width: none; }
    .mkt-col-cap { font-size: 11px; }
    /* Таблицы-двойники шире экрана — листаются вбок внутри карточки, а не всей страницей */
    .mkt-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---- Каталог: список товаров из MDM-таблицы ---- */
/* Одна таблица обслуживает и весь каталог, и отдельную категорию: разница в фильтре. */
.catalog-head {
    display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.catalog-head .input { flex: 1; min-width: 220px; max-width: 420px; padding: 9px 14px; }
.catalog-count { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.catalog {
    width: 100%; border-collapse: collapse; background: var(--card-bg);
    border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.catalog th {
    text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-muted);
    padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fff;
}
.catalog td { padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.catalog tr:last-child td { border-bottom: none; }

/* Артикул — моноширинный: так колонка стоит ровно и читается как код, а не как слово. */
.catalog .c-sku {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px; white-space: nowrap; width: 1%;
}
.catalog .muted { color: var(--text-muted); }

/* Строка кликабельна, только если папка товара уже приехала с Drive. */
.catalog tr.has-folder { cursor: pointer; }
.catalog tr.has-folder:hover td { background: #f1f5f9; }
.catalog tr.no-folder td:first-child { opacity: .55; }

/* ---- Экран товара: медиапапки одна под другой ---- */
.product-group { margin-bottom: 28px; }
.product-group-head {
    font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.product-group-head .muted {
    font-weight: 400; text-transform: none; letter-spacing: 0;
    background: #eef2f7; border-radius: 10px; padding: 1px 8px; font-size: 12px;
}
.file-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.gallery-card.file { cursor: pointer; }
.gallery-card .file-thumb {
    display: flex; align-items: center; justify-content: center; font-size: 34px;
}
.breadcrumbs .crumb-drive { margin-left: auto; font-size: 13px; }
