/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy:   #0F172A;
    --white:  #FFFFFF;
    --gray:   #F8FAFC;
    --blue:   #2563EB;
    --blue-hover: #1D4ED8;
    --border: #E2E8F0;
    --text:   #1E293B;
    --muted:  #64748B;
    --green:  #16A34A;
    --red:    #DC2626;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow:    0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
    --radius: 10px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--gray); color: var(--text); line-height: 1.6; min-height: 100vh; }
a { color: inherit; text-decoration: none; }

/* ===== TOPBAR ===== */
.topbar {
    background: var(--navy);
    color: var(--white);
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 40px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(255,255,255,.06);
}

.topbar-logo {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: .5px;
    color: var(--white);
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
}
.topbar-logo span { color: #60A5FA; }

.topbar-nav { display: flex; gap: 4px; flex: 1; }

.topbar-nav a {
    color: #94A3B8;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.topbar-nav a:hover { background: rgba(255,255,255,.07); color: var(--white); }
.topbar-nav a.active { background: rgba(37,99,235,.35); color: #93C5FD; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-right a {
    color: #94A3B8;
    font-size: .875rem;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.topbar-right a:hover { background: rgba(255,255,255,.07); color: var(--white); }

/* ===== HERO ===== */
.hero {
    background: var(--navy);
    padding: 56px 32px 64px;
    text-align: center;
}

.hero-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1.25;
    margin-bottom: 10px;
}

.hero-sub {
    color: #94A3B8;
    font-size: 1rem;
    margin-bottom: 36px;
}

.hero-search-box {
    max-width: 680px;
    margin: 0 auto;
    display: flex;
    gap: 0;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 0 0 1px rgba(255,255,255,.1), var(--shadow-lg);
    overflow: hidden;
}

.hero-search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 16px 20px;
    font-size: 1rem;
    font-family: var(--font);
    color: var(--text);
    background: transparent;
}
.hero-search-box input::placeholder { color: #94A3B8; }

.hero-search-box button {
    background: var(--blue);
    color: var(--white);
    border: none;
    padding: 0 28px;
    font-size: .95rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}
.hero-search-box button:hover { background: var(--blue-hover); }

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 10px 10px;
    box-shadow: var(--shadow-lg);
    list-style: none;
    margin: 0;
    padding: 4px 0;
    z-index: 300;
    max-height: 280px;
    overflow-y: auto;
}
.search-suggestions li {
    padding: 10px 20px;
    cursor: pointer;
    font-size: .95rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 3px solid transparent;
}
.search-suggestions li:hover,
.search-suggestions li.active {
    background: var(--bg);
    border-left-color: var(--blue);
}
.search-suggestions li .sug-icon { color: #94A3B8; font-size: .85rem; flex-shrink: 0; }
.search-suggestions li .sug-del {
    margin-left: auto;
    color: #CBD5E1;
    font-size: .8rem;
    padding: 2px 6px;
    border-radius: 4px;
    display: none;
}
.search-suggestions li:hover .sug-del { display: inline; }
.search-suggestions li .sug-del:hover { background: #FEE2E2; color: #DC2626; }

.hero-badges {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 28px;
    color: #64748B;
    font-size: .85rem;
}
.hero-badges span { display: flex; align-items: center; gap: 6px; }
.hero-badges span::before { content: '✓'; color: #34D399; font-weight: 700; }

/* ===== MAIN LAYOUT ===== */
.main-wrap {
    width: 100%;
    padding: 28px 32px 60px;
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    align-items: start;
    box-sizing: border-box;
}

/* ===== SIDEBAR ===== */
.sidebar { display: flex; flex-direction: column; gap: 16px; }

.sidebar-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.sidebar-card-title {
    padding: 12px 16px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    background: var(--gray);
}

.source-list { padding: 8px 0; }

.source-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: .875rem;
    cursor: pointer;
    transition: background .12s;
    user-select: none;
}
.source-item:hover { background: var(--gray); }
.source-item input[type=checkbox] { accent-color: var(--blue); width: 15px; height: 15px; cursor: pointer; }
.source-item-name { flex: 1; color: var(--text); }
.source-status { font-size: .7rem; font-weight: 600; }
.source-status.online  { color: var(--green); }
.source-status.offline { color: var(--red); }

.filter-block { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.filter-row { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.filter-input {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: .875rem;
    font-family: var(--font);
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    background: var(--gray);
    width: 100%;
}
.filter-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); background: var(--white); }

/* ===== CONTENT ===== */
.content { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

/* ===== RESULTS INFO BAR ===== */
.results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.results-count {
    font-size: .875rem;
    color: var(--muted);
}
.results-count strong { color: var(--text); font-size: 1rem; }

.results-actions { display: flex; gap: 8px; }

/* ===== SORT BAR ===== */
.sort-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .8rem;
    color: var(--muted);
}
.sort-btn {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    font-size: .8rem;
    font-family: var(--font);
    cursor: pointer;
    color: var(--muted);
    transition: border-color .15s, color .15s, background .15s;
}
.sort-btn:hover { border-color: var(--blue); color: var(--blue); }
.sort-btn.active { background: var(--blue); color: var(--white); border-color: var(--blue); }

/* ===== TABLE ===== */
.table-wrap {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.results-table { width: 100%; border-collapse: collapse; }

.results-table thead th {
    background: var(--gray);
    padding: 11px 16px;
    text-align: left;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.results-table thead th.sortable { cursor: pointer; }
.results-table thead th.sortable:hover { color: var(--blue); }
.results-table thead th .sort-icon { margin-left: 4px; opacity: .5; }
.results-table thead th.sort-asc .sort-icon::after { content: ' ↑'; }
.results-table thead th.sort-desc .sort-icon::after { content: ' ↓'; }

.results-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}
.results-table tbody tr:last-child { border-bottom: none; }
.results-table tbody tr:hover { background: #F0F7FF; }

.results-table tbody td {
    padding: 12px 16px;
    font-size: .9rem;
    color: var(--text);
    vertical-align: middle;
}

/* Priority row — item in Arsentiev */
.results-table tbody tr.row-priority { background: #F0FDF4; }
.results-table tbody tr.row-priority:hover { background: #DCFCE7; }

.cell-name { max-width: 360px; }
.cell-name-main { font-weight: 500; line-height: 1.4; }
.cell-name-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }

.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: .75rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background .12s, color .12s;
    vertical-align: middle;
}
.copy-btn:hover { background: var(--border); color: var(--text); }

/* Source chip */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}
.chip-1c    { background: #EFF6FF; color: #1D4ED8; }
.chip-gsm   { background: #F0FDF4; color: #15803D; }
.chip-mem     { background: #FFF7ED; color: #C2410C; }
.chip-mem-ars { background: #DCFCE7; color: #15803D; }
.chip-mem-uss { background: #EFF6FF; color: #1D4ED8; }
.chip-moba  { background: #FAF5FF; color: #7E22CE; }
.chip-tag   { background: #FFF1F2; color: #BE123C; }
.chip-other { background: var(--gray); color: var(--muted); }

/* Stock badge */
.stock-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
}
.stock-in   { background: #DCFCE7; color: #15803D; }
.stock-out  { background: #FEE2E2; color: #B91C1C; }
.stock-low  { background: #FEF3C7; color: #B45309; }
.cell-avail { white-space: nowrap; }

/* Priority badge (name cell) */
.badge-ars {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: .68rem;
    font-weight: 700;
    background: #DCFCE7;
    color: #15803D;
    margin-right: 5px;
    vertical-align: middle;
}

/* Branch availability badges (stock cell) */
.branch-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .72rem;
    font-weight: 600;
    margin: 1px 2px 1px 0;
    white-space: nowrap;
}
.branch-ars { background: #DCFCE7; color: #15803D; }
.branch-uss { background: #EFF6FF; color: #1D4ED8; }

/* Price */
.price { font-weight: 700; font-size: .95rem; }
.price-nd { color: var(--muted); font-size: .875rem; }
.price-loading { color: var(--muted); font-size: .875rem; font-style: italic; }

/* URL link */
.tbl-link { color: var(--blue); font-size: .8rem; }
.tbl-link:hover { text-decoration: underline; }

/* ===== EXPORT ROW ===== */
.export-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--gray);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 60px 32px;
    text-align: center;
    color: var(--muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: .9rem; max-width: 360px; margin: 0 auto; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-hover); }
.btn-outline {
    background: var(--white);
    color: var(--text);
    border-color: var(--border);
}
.btn-outline:hover { border-color: #94A3B8; background: var(--gray); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }

/* ===== LOADING ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: none;
}
.spinner {
    width: 44px; height: 44px;
    border: 4px solid rgba(255,255,255,.2);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin .75s linear infinite;
    margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p { color: var(--white); font-size: .95rem; }

/* ===== CONN STATUS ===== */
#connStatus1C { font-size: .875rem; line-height: 1.6; }
.conn-ok   { color: var(--green); font-weight: 600; }
.conn-fail { color: var(--red);   font-weight: 600; }
.conn-pending { color: #92400E;   font-weight: 600; }

/* ===== CONFIG / ABOUT PAGE ===== */
.page-wrap { max-width: 860px; margin: 0 auto; padding: 32px; }
.page-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.page-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); color: var(--navy); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.form-group input[type=text],
.form-group input[type=password],
.form-group input[type=number],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .9rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--gray);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); background: var(--white); }
.form-group textarea { min-height: 120px; resize: vertical; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toggle-label { font-size: .875rem; font-weight: 500; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    /* Topbar */
    .topbar { padding: 0 16px; gap: 12px; height: 50px; }
    .topbar-nav { display: none; }
    .topbar-logo { font-size: 1rem; }

    /* Hero */
    .hero { padding: 24px 16px 32px; }
    .hero-title { font-size: 1.25rem; }
    .hero-sub { font-size: .875rem; margin-bottom: 20px; }
    .hero-badges { display: none; }
    .hero-search-box { flex-direction: column; border-radius: 10px; }
    .hero-search-box input { padding: 14px 16px; font-size: 1rem; }
    .hero-search-box button { padding: 13px 16px; border-radius: 0 0 10px 10px; }

    /* Layout */
    .main-wrap {
        grid-template-columns: 1fr;
        padding: 12px 12px 40px;
        gap: 10px;
    }

    /* Sidebar hidden on mobile — sources configured via /config */
    .sidebar { display: none; }

    /* Table: horizontal scroll */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .results-table { min-width: 560px; }
    .results-table tbody td { padding: 10px 12px; font-size: .82rem; }
    .results-table thead th { padding: 9px 12px; }
    .cell-name { max-width: 220px; }

    /* Results bar: stack vertically */
    .results-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
    .sort-bar { flex-wrap: wrap; }

    /* Export row */
    .export-row { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .hero-title { font-size: 1.1rem; }
    .results-table { min-width: 480px; }
    .results-table tbody td { padding: 8px 10px; font-size: .78rem; }
}

/* ===== SEARCH WORKSPACE REDESIGN ===== */
body.app-shell { background: #f5f7fb; color: #14213d; }
.app-shell .app-layout { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.app-shell .app-sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 14px 18px; background: linear-gradient(160deg, #0c2b51 0%, #06182f 100%); color: #fff; }
.app-shell .brand { display: flex; align-items: center; gap: 13px; padding: 0 14px 27px; color: #fff; font-size: 1.25rem; font-weight: 750; line-height: 1.08; letter-spacing: -.02em; }
.app-shell .brand-mark { display: grid; place-items: center; width: 41px; height: 41px; border-radius: 13px; background: linear-gradient(145deg, #48a5ff, #1263c6); font-size: .82rem; box-shadow: 0 7px 18px rgba(0,0,0,.23); }
.app-shell .app-nav { display: grid; gap: 6px; }
.app-shell .app-nav a { display: flex; align-items: center; gap: 14px; min-height: 49px; padding: 0 15px; border-radius: 9px; color: #b9c9df; font-size: .95rem; font-weight: 600; transition: .16s ease; }
.app-shell .app-nav .nav-icon { width: 18px; color: #87c5ff; font-size: 1.35rem; line-height: 1; text-align: center; }
.app-shell .nav-icon { display: inline-grid; place-items: center; }
.app-shell .nav-icon svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.app-shell .app-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.app-shell .app-nav a.active { color: #fff; background: linear-gradient(90deg, #156fe1, #0d5fc6); box-shadow: 0 8px 18px rgba(2,48,108,.38); }
.app-shell .app-nav a.active span { color: #fff; }
.app-shell .sidebar-account { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 15px 10px 0; border-top: 1px solid rgba(255,255,255,.12); color: #cbd6e5; font-size: .82rem; }
.app-shell .account-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; background: #2a6eb7; color: #fff; font-weight: 700; }
.app-shell .account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-shell .sidebar-account a { margin-left: auto; color: #a7c6ea; font-size: 1.25rem; }
.app-shell .mobile-logout { display: none; }

.app-shell .app-main { width: min(100%, 1540px); margin: 0 auto; padding: 36px 42px 70px; }
.app-shell .workspace-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 28px; margin-bottom: 25px; }
.app-shell .eyebrow { margin-bottom: 3px; color: #6b7b93; font-size: .73rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.app-shell .workspace-header h1 { color: #112545; font-size: clamp(2rem, 3vw, 3.1rem); line-height: 1.04; letter-spacing: -.055em; }
.app-shell .workspace-header p:not(.eyebrow) { margin-top: 9px; color: #68768b; font-size: 1.02rem; }
.app-shell .db-health { display: flex; align-items: center; gap: 13px; min-width: 295px; padding: 15px 18px; border: 1px solid #d9efe3; border-radius: 11px; background: linear-gradient(110deg, #f3fff8, #e8f9ee); color: #123b2c; box-shadow: 0 5px 18px rgba(24,113,67,.07); }
.app-shell .health-icon { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 50%; background: #16a86b; color: #fff; font-size: 1.25rem; font-weight: 800; }
.app-shell .db-health strong, .app-shell .db-health small { display: block; }
.app-shell .db-health strong { font-size: .95rem; }
.app-shell .db-health small { margin-top: 2px; color: #638073; font-size: .78rem; }
.app-shell .db-health b { margin-left: auto; color: #4d8067; font-size: 1.7rem; font-weight: 400; }

.app-shell .search-workspace { padding: 18px; border: 1px solid #e0e7f0; border-radius: 14px; background: #fff; box-shadow: 0 12px 32px rgba(30,51,83,.06); }
.app-shell .search-row { display: flex; gap: 14px; }
.app-shell .search-field { position: relative; display: flex; flex: 1; align-items: center; min-width: 0; border: 1px solid #cbd8e7; border-radius: 9px; background: #fff; transition: .15s ease; }
.app-shell .search-field:focus-within { border-color: #1972db; box-shadow: 0 0 0 4px rgba(25,114,219,.12); }
.app-shell .search-icon { margin-left: 17px; color: #61728a; font-size: 1.7rem; line-height: 1; }
.app-shell .search-field input { width: 100%; min-width: 0; padding: 16px 42px 16px 13px; border: 0; outline: 0; color: #14213d; font: 600 1.05rem var(--font); }
.app-shell .search-field input::placeholder { color: #92a0b3; font-weight: 400; }
.app-shell .search-clear { position: absolute; right: 13px; border: 0; background: transparent; color: #9aa8b9; font-size: 1.55rem; line-height: 1; cursor: pointer; }
.app-shell .search-button { min-width: 174px; border: 0; border-radius: 9px; background: linear-gradient(135deg, #237ae6, #1665cd); color: #fff; font: 750 1rem var(--font); cursor: pointer; box-shadow: 0 7px 15px rgba(24,102,204,.19); transition: .16s ease; }
.app-shell .search-button:hover { transform: translateY(-1px); background: #125ec6; }
.app-shell .search-suggestions { top: calc(100% + 6px); left: 0; right: 0; border: 1px solid #dce5f0; border-radius: 9px; }
.app-shell .filter-toolbar { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; padding-top: 14px; }
.app-shell .sources-inline { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.app-shell .source-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 12px; border: 1px solid #e0e7f0; border-radius: 8px; color: #384c68; background: #fbfcff; font-size: .84rem; font-weight: 700; cursor: pointer; }
.app-shell .source-pill input { width: 15px; height: 15px; accent-color: #1972db; }
.app-shell .source-pill.more { color: #6b7c93; font-weight: 600; }
.app-shell .source-logo { display: inline-grid; place-items: center; width: 21px; height: 21px; border-radius: 6px; color: #fff; font-size: .64rem; font-weight: 800; }
.app-shell .source-logo.one-c { background: #e53225; }.app-shell .source-logo.gsm { background: #e1424b; }.app-shell .source-logo.mem { background: #2875c9; }
.app-shell .role-sources { color: #718097; font-size: .87rem; }
.app-shell .stock-switch { display: inline-flex; align-items: center; gap: 8px; color: #32445f; font-size: .88rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.app-shell .stock-switch input { position: absolute; opacity: 0; }.app-shell .stock-switch span { width: 37px; height: 22px; padding: 3px; border-radius: 999px; background: #c4ceda; transition: .18s ease; }.app-shell .stock-switch span::after { display: block; width: 16px; height: 16px; border-radius: 50%; background: #fff; content: ''; transition: .18s ease; box-shadow: 0 1px 3px rgba(0,0,0,.24); }.app-shell .stock-switch input:checked + span { background: #1878e5; }.app-shell .stock-switch input:checked + span::after { transform: translateX(15px); }
.app-shell .more-filters { position: relative; }.app-shell .more-filters summary { min-height: 40px; padding: 10px 12px; border-radius: 8px; color: #566981; background: #f4f7fb; font-size: .82rem; font-weight: 700; cursor: pointer; list-style: none; white-space: nowrap; }.app-shell .more-filters summary::-webkit-details-marker { display: none; }.app-shell .filter-popover { position: absolute; right: 0; z-index: 30; display: grid; gap: 10px; width: 210px; margin-top: 7px; padding: 13px; border: 1px solid #dfe7f0; border-radius: 9px; background: #fff; box-shadow: 0 12px 28px rgba(25,45,77,.16); }.app-shell .filter-popover label { display: grid; gap: 4px; color: #63748b; font-size: .75rem; font-weight: 700; }.app-shell .filter-popover input { width: 100%; padding: 8px; border: 1px solid #dce4ee; border-radius: 6px; font: .84rem var(--font); }

.app-shell .results-panel { margin-top: 24px; }.app-shell .results-panel .empty-state { min-height: 330px; display: grid; place-content: center; border-radius: 14px; box-shadow: 0 8px 25px rgba(26,50,84,.04); }.app-shell .empty-state-icon { color: #237ae6; font-size: 3rem; opacity: 1; }
.app-shell .results-bar { padding: 0 2px 13px; }.app-shell .results-count { color: #6a7a90; }.app-shell .results-count strong { color: #152844; font-size: 1.05rem; }.app-shell .sort-bar { gap: 7px; }.app-shell .sort-btn { border-radius: 7px; }.app-shell .table-wrap { border: 1px solid #e0e7f0; border-radius: 13px; box-shadow: 0 10px 26px rgba(26,50,84,.05); }.app-shell .results-table thead th { padding: 13px 18px; background: #f4f7fb; color: #56667d; }.app-shell .results-table tbody td { padding: 15px 18px; }.app-shell .results-table tbody tr:hover { background: #f5f9ff; }.app-shell .results-table tbody tr.row-priority { background: #f5fdf8; }.app-shell .cell-name-main { font-weight: 700; color: #142744; }.app-shell .chip { border-radius: 6px; }.app-shell .price { color: #13294a; font-size: 1rem; }.app-shell .tbl-link { display: inline-flex; padding: 7px 10px; border-radius: 7px; background: #eff6ff; color: #1768cf; font-weight: 700; text-decoration: none; }.app-shell .tbl-link:hover { background: #dcebff; text-decoration: none; }.app-shell .export-row { background: #fbfcfe; }
.app-shell .table-wrap { overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.app-shell .results-table, .app-shell .results-table tbody { display: block; width: 100%; border-collapse: initial; }
.app-shell .results-table thead { display: none; }
.app-shell .results-table tbody { display: grid; gap: 9px; }
.app-shell .results-table tbody tr:not(#non1c-start) { display: grid; grid-template-columns: minmax(270px, 1fr) auto auto minmax(112px, auto) auto; align-items: center; gap: 12px; padding: 13px 15px 13px 18px; border: 1px solid #e1e8f1; border-radius: 12px; background: #fff; box-shadow: 0 3px 10px rgba(22, 45, 76, .035); transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.app-shell .results-table tbody tr:not(#non1c-start):hover { border-color: #a9cef8; background: #fbfdff; box-shadow: 0 8px 18px rgba(30, 81, 143, .09); transform: translateY(-1px); }
.app-shell .results-table tbody tr.row-priority { border-color: #c8ead6; background: #f4fcf7; }
.app-shell .results-table tbody tr.row-priority:hover { border-color: #91d3ad; background: #eefaf2; }
.app-shell .results-table tbody tr:not(#non1c-start) td { display: flex; align-items: center; min-width: 0; padding: 0; border: 0; background: transparent; }
.app-shell .results-table .cell-name { display: block; grid-column: 1 / -1; min-width: 0; padding-bottom: 11px !important; border-bottom: 1px solid #edf1f6 !important; }.app-shell .results-table .cell-name-main { font-size: 1rem; line-height: 1.35; }.app-shell .results-table .cell-name-sub { margin-top: 5px; }.app-shell .results-table .cell-source, .app-shell .results-table .cell-avail { white-space: nowrap; }.app-shell .results-table .price-cell { justify-content: flex-end; min-width: 112px; text-align: right; }.app-shell .results-table .price { color: #133d72; font-size: 1.08rem; font-weight: 800; }.app-shell .results-table .cell-link { justify-content: flex-end; white-space: nowrap; }.app-shell .results-table .tbl-link { min-height: 36px; align-items: center; justify-content: center; padding: 7px 12px; border: 1px solid #d6e7fb; }
.app-shell .loading-overlay { backdrop-filter: blur(3px); }

/* Results are normal cards, not table rows: product names always have the full row. */
.app-shell .results-list { display: grid; width: 100%; gap: 10px; }
.app-shell .results-list #non1c-start { display: none; }
.app-shell .results-list .result-card { display: grid; grid-template-columns: minmax(0, 1fr) auto auto minmax(112px, auto) auto; align-items: center; width: 100%; gap: 12px; padding: 14px 16px 14px 18px; box-sizing: border-box; border: 1px solid #e1e8f1; border-radius: 13px; background: #fff; box-shadow: 0 3px 10px rgba(22, 45, 76, .035); transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.app-shell .results-list .result-card:hover { border-color: #a9cef8; background: #fbfdff; box-shadow: 0 8px 18px rgba(30, 81, 143, .09); transform: translateY(-1px); }
.app-shell .results-list .result-card.row-priority { border-color: #c8ead6; background: #f4fcf7; }
.app-shell .results-list .result-card.row-priority:hover { border-color: #91d3ad; background: #eefaf2; }
.app-shell .results-list .cell-name { grid-column: 1 / -1; min-width: 0; max-width: none; padding: 0 0 11px; border-bottom: 1px solid #edf1f6; }
.app-shell .results-list .cell-name-main { color: #142744; font-size: 1rem; font-weight: 700; line-height: 1.35; }
.app-shell .results-list .cell-name-sub { margin-top: 5px; }
.app-shell .results-list .cell-source, .app-shell .results-list .cell-avail { min-width: 0; white-space: nowrap; }
.app-shell .results-list .price-cell { min-width: 112px; color: #133d72; font-size: 1.08rem; font-weight: 800; text-align: left; justify-self: start; white-space: nowrap; }
.app-shell .results-list .cell-link { justify-self: end; white-space: nowrap; }
.app-shell .results-list .tbl-link { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 7px 12px; border: 1px solid #d6e7fb; border-radius: 7px; background: #eff6ff; color: #1768cf; font-weight: 700; text-decoration: none; }
.app-shell .results-list .tbl-link:hover { background: #dcebff; text-decoration: none; }

@media (max-width: 980px) {
    .app-shell .app-layout { grid-template-columns: 76px minmax(0, 1fr); }.app-shell .app-sidebar { padding: 20px 10px; }.app-shell .brand { justify-content: center; padding: 0 0 25px; }.app-shell .brand > span:last-child, .app-shell .app-nav .nav-label { display: none; }.app-shell .app-nav a { justify-content: center; padding: 0; }.app-shell .app-nav .nav-icon { width: auto; font-size: 1.5rem; }.app-shell .sidebar-account { justify-content: center; padding: 14px 0 0; }.app-shell .account-name, .app-shell .sidebar-account a { display: none; }.app-shell .app-main { padding: 28px 24px 55px; }
}
@media (max-width: 700px) {
    .app-shell .app-layout { display: block; }.app-shell .app-sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; }.app-shell .brand { padding: 0; }.app-shell .brand > span:last-child, .app-shell .sidebar-account { display: none; }.app-shell .app-nav { display: flex; margin-left: auto; gap: 3px; }.app-shell .app-nav a { width: 40px; min-height: 40px; }.app-shell .app-main { padding: 22px 14px 45px; }.app-shell .workspace-header { display: block; }.app-shell .workspace-header h1 { font-size: 2rem; }.app-shell .db-health { min-width: 0; margin-top: 18px; }.app-shell .search-row { flex-direction: column; }.app-shell .search-button { min-height: 51px; }.app-shell .filter-toolbar { align-items: flex-start; }.app-shell .sources-inline { flex-basis: 100%; }.app-shell .more-filters { margin-left: auto; }.app-shell .results-table { min-width: 650px; }
}

/* Единый стиль служебных разделов: настройки, журнал, пользователи, справка */
body.legacy-shell { min-height: 100vh; padding-left: 248px; color: #172b45; background: #eef2f7; }
.legacy-shell .topbar { position: fixed; z-index: 20; inset: 0 auto 0 0; display: flex; flex-direction: column; align-items: stretch; width: 248px; padding: 26px 16px 20px; box-sizing: border-box; border: 0; background: #102744; box-shadow: none; }
.legacy-shell .topbar-logo { display: flex; align-items: center; gap: 8px; margin: 0 10px 35px; color: #fff; font-size: .93rem; font-weight: 800; letter-spacing: .055em; }.legacy-shell .topbar-logo span:not(.brand-mark) { color: #dcecff; }.legacy-shell .brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: #fff; background: #2878ee; letter-spacing: 0; }
.legacy-shell .topbar-nav, .legacy-shell .topbar-right { display: flex; flex-direction: column; gap: 4px; }.legacy-shell .topbar-right { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(213,229,250,.14); }.legacy-shell .topbar a { display: flex; align-items: center; gap: 10px; padding: 10px 11px; border-radius: 8px; color: #a9bad1; font-size: .86rem; font-weight: 600; text-decoration: none; transition: .15s ease; }.legacy-shell .topbar a:hover { color: #fff; background: rgba(255,255,255,.07); }.legacy-shell .topbar a.active { color: #fff; background: #256fe0; box-shadow: 0 5px 12px rgba(0,0,0,.16); }.legacy-shell .topbar-right > span { padding: 0 11px 10px; }
.legacy-shell .page-wrap { max-width: 1180px; margin: 0 auto; padding: 40px 42px 56px; box-sizing: border-box; }.legacy-shell .page-card, .legacy-shell .card { margin-bottom: 18px; padding: 25px; border: 1px solid #e0e7ef; border-radius: 13px; background: #fff; box-shadow: 0 3px 13px rgba(26,45,74,.045); }.legacy-shell .page-card h2, .legacy-shell .card h2 { margin: 0 0 18px; padding: 0 0 13px; border-bottom: 1px solid #e9eef4; color: #162c47; font-size: 1.08rem; letter-spacing: -.015em; }.legacy-shell .form-group label { color: #586a80; font-weight: 700; }.legacy-shell input:not([type="checkbox"]), .legacy-shell select, .legacy-shell textarea { border-color: #d5dfeb; border-radius: 8px; background: #fbfcfe; }.legacy-shell .btn { border-radius: 8px; font-weight: 700; }.legacy-shell .btn-primary { background: #2878ee; border-color: #2878ee; box-shadow: 0 5px 12px rgba(40,120,238,.18); }.legacy-shell .btn-primary:hover { background: #1769df; }.legacy-shell .btn-outline { border-color: #d5dfeb; color: #42556c; background: #fff; }.legacy-shell .results-table th, .legacy-shell .log-table th { background: #f5f8fc; color: #64748b; }
.legacy-shell .page-heading { display: flex; align-items: end; justify-content: space-between; margin: 0 0 24px; }.legacy-shell .page-heading h1 { margin: 0 0 7px; color: #162c47; font-size: 2rem; letter-spacing: -.045em; }.legacy-shell .page-heading > div > p:last-child { margin: 0; color: #6e7f95; }.legacy-shell .eyebrow { margin: 0 0 7px; color: #2878ee; font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }.legacy-shell .about-intro { display: flex; align-items: center; gap: 20px; }.legacy-shell .about-intro h2 { margin-bottom: 8px; padding: 0; border: 0; }.legacy-shell .about-intro p { margin: 0; color: #62748b; line-height: 1.6; }.legacy-shell .about-icon { display: grid; flex: 0 0 auto; place-items: center; width: 52px; height: 52px; border-radius: 14px; color: #fff; background: #2878ee; font-size: 1.65rem; }.legacy-shell .about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }.legacy-shell .feature-list { display: grid; gap: 13px; margin: 0; padding: 0; list-style: none; }.legacy-shell .feature-list li { position: relative; padding-left: 20px; }.legacy-shell .feature-list li::before { content: ''; position: absolute; top: .55em; left: 0; width: 7px; height: 7px; border-radius: 50%; background: #2878ee; }.legacy-shell .feature-list strong, .legacy-shell .feature-list span { display: block; }.legacy-shell .feature-list span { margin-top: 3px; color: #718096; font-size: .85rem; }
@media (max-width: 780px) { body.legacy-shell { padding-left: 0; }.legacy-shell .topbar { position: static; width: auto; min-height: auto; padding: 15px; }.legacy-shell .topbar-logo { margin: 0 5px 12px; }.legacy-shell .topbar-nav, .legacy-shell .topbar-right { flex-direction: row; flex-wrap: wrap; margin: 0; padding: 0; border: 0; }.legacy-shell .topbar a { padding: 7px 9px; font-size: .78rem; }.legacy-shell .topbar-right > span { display: none; }.legacy-shell .page-wrap { padding: 25px 16px 40px; }.legacy-shell .about-grid { grid-template-columns: 1fr; } }

/* Служебные страницы в том же каркасе, что и главный экран поиска. */
.app-shell .utility-main { width: min(100%, 1540px); margin: 0 auto; padding: 36px 42px 70px; box-sizing: border-box; }
.app-shell .utility-main .page-wrap { max-width: none; margin: 0; padding: 0; }
.app-shell .utility-main .page-heading { margin: 0 0 25px; }
.app-shell .utility-main .page-heading .eyebrow { margin: 0 0 3px; color: #6b7b93; font-size: .73rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.app-shell .utility-main .page-heading h1 { margin: 0; color: #112545; font-size: clamp(2rem, 3vw, 3.1rem); line-height: 1.04; letter-spacing: -.055em; }
.app-shell .utility-main .page-heading > div > p:last-child { margin: 9px 0 0; color: #68768b; font-size: 1.02rem; }
.app-shell .utility-main .page-card, .app-shell .utility-main .card { margin: 0 0 18px; padding: 24px; border: 1px solid #e0e7f0; border-radius: 14px; background: #fff; box-shadow: 0 8px 25px rgba(26,50,84,.04); }
.app-shell .utility-main .page-card h2, .app-shell .utility-main .card h2 { margin: 0 0 18px; padding: 0 0 13px; border-bottom: 1px solid #e9eef4; color: #142744; font-size: 1.05rem; letter-spacing: -.015em; }
.app-shell .utility-main .form-group label { color: #63748b; font-weight: 700; }
.app-shell .utility-main input:not([type="checkbox"]), .app-shell .utility-main select, .app-shell .utility-main textarea { border-color: #dce4ee; border-radius: 8px; background: #fbfcff; }
.app-shell .utility-main .btn { border-radius: 8px; font-weight: 700; }
.app-shell .utility-main .btn-primary { border-color: #237ae6; background: linear-gradient(135deg, #237ae6, #1665cd); box-shadow: 0 7px 15px rgba(24,102,204,.19); }
.app-shell .utility-main .btn-primary:hover { background: #125ec6; }
.app-shell .utility-main .btn-outline { border-color: #dce4ee; color: #42556c; background: #fff; }
.app-shell .utility-main .results-table, .app-shell .utility-main .log-table { overflow: hidden; border: 1px solid #e0e7f0; border-radius: 11px; }
.app-shell .utility-main .results-table th, .app-shell .utility-main .log-table th { background: #f4f7fb; color: #56667d; }
.app-shell .utility-main .about-intro { display: flex; align-items: center; gap: 20px; }.app-shell .utility-main .about-intro h2 { margin-bottom: 8px; padding: 0; border: 0; }.app-shell .utility-main .about-intro p { margin: 0; color: #62748b; line-height: 1.6; }.app-shell .utility-main .about-icon { display: grid; flex: 0 0 auto; place-items: center; width: 52px; height: 52px; border-radius: 14px; color: #fff; background: #2878ee; font-size: 1.65rem; }.app-shell .utility-main .about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }.app-shell .utility-main .about-grid-single { grid-template-columns: minmax(0, 1fr); }.app-shell .utility-main .feature-list { display: grid; gap: 13px; margin: 0; padding: 0; list-style: none; }.app-shell .utility-main .feature-list li { position: relative; padding-left: 20px; }.app-shell .utility-main .feature-list li::before { content: ''; position: absolute; top: .55em; left: 0; width: 7px; height: 7px; border-radius: 50%; background: #2878ee; }.app-shell .utility-main .feature-list strong, .app-shell .utility-main .feature-list span { display: block; }.app-shell .utility-main .feature-list span { margin-top: 3px; color: #718096; font-size: .85rem; }
.app-shell .utility-main .about-footer { margin: 42px 0 0; color: #8594a8; font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-align: center; text-transform: uppercase; }.app-shell .utility-main .about-footer span { margin-left: 7px; color: #a2afbe; font-weight: 600; }
@media (max-width: 980px) { .app-shell .utility-main { padding: 28px 24px 55px; } }
@media (max-width: 700px) { .app-shell .utility-main { padding: 22px 14px 45px; }.app-shell .utility-main .page-heading h1 { font-size: 2rem; }.app-shell .utility-main .about-grid { grid-template-columns: 1fr; } }

/* Поддержка уже открытых служебных шаблонов до штатного перезапуска Flask. */
body.legacy-shell .topbar {
    height: auto;
    gap: 0;
    padding: 26px 14px 18px;
    background: linear-gradient(160deg, #0c2b51 0%, #06182f 100%);
}
body.legacy-shell .topbar-logo { gap: 13px; margin: 0 14px 27px; font-size: 1.25rem; line-height: 1.08; letter-spacing: -.02em; }
body.legacy-shell .brand-mark { width: 41px; height: 41px; border-radius: 13px; background: linear-gradient(145deg, #48a5ff, #1263c6); font-size: 1.75rem; box-shadow: 0 7px 18px rgba(0,0,0,.23); }
body.legacy-shell .topbar-nav { flex: 0 0 auto; gap: 6px; }
body.legacy-shell .topbar a { min-height: 49px; padding: 0 15px; box-sizing: border-box; border-radius: 9px; font-size: .95rem; }
body.legacy-shell .topbar a.active { background: linear-gradient(90deg, #156fe1, #0d5fc6); box-shadow: 0 8px 18px rgba(2,48,108,.38); }
body.legacy-shell .topbar-right { flex-direction: row; align-items: center; gap: 9px; margin-top: auto; padding: 15px 10px 0; border-top: 1px solid rgba(255,255,255,.12); }
body.legacy-shell .topbar-right > span { padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.legacy-shell .topbar-right > span::before { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 9px; border-radius: 50%; color: #fff; background: #2a6eb7; content: 'A'; font-size: .78rem; font-weight: 700; vertical-align: middle; }
body.legacy-shell .topbar-right > a[href="/admin/users"] { display: none; }
body.legacy-shell .topbar-right a { min-height: 28px; margin-left: auto; padding: 0; color: #a7c6ea; font-size: 1.25rem; }

/* Эти поставщики исключены из поиска: скрываем также в уже кэшированных шаблонах. */
.source-pill:has(input[value="moba"]), .source-pill:has(input[value="taggsm"]),
.source-pill:has(input[value="gsm_salon"]), .source-pill:has(input[value="mematrix_uss"]),
#configSources .source-item:has(input[value="moba"]), #configSources .source-item:has(input[value="taggsm"]),
#configSources .source-item:has(input[value="gsm_salon"]), #configSources .source-item:has(input[value="mematrix_uss"]),
#roleSourcesCard label:has(input[data-src="moba"]), #roleSourcesCard label:has(input[data-src="taggsm"]),
#roleSourcesCard label:has(input[data-src="gsm_salon"]), #roleSourcesCard label:has(input[data-src="mematrix_uss"]) { display: none !important; }

/* Mobile-first workspace: search stays fast, result tables become touch-friendly cards. */
@media (max-width: 700px) {
    html { font-size: 16px; }
    body.app-shell { background: #f4f7fb; }
    .app-shell .app-sidebar { position: sticky; top: 0; z-index: 100; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; min-height: 60px; padding: 8px 10px; box-shadow: 0 5px 16px rgba(4, 25, 51, .23); }
    .app-shell .brand { display: grid; grid-column: 1; place-items: center; width: 44px; height: 44px; padding: 0; }
    .app-shell .brand > span:last-child { display: none; }
    .app-shell .brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; font-size: .74rem; }
    .app-shell .app-nav { grid-column: 2; display: flex; align-items: center; justify-content: flex-start; min-width: 0; max-width: none; margin: 0; overflow-x: auto; scrollbar-width: none; }
    .app-shell .app-nav::-webkit-scrollbar { display: none; }
    .app-shell .app-nav a { display: grid; flex: 0 0 44px; place-items: center; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 11px; line-height: 1; }
    .app-shell .app-nav .nav-icon { display: grid; place-items: center; width: 100%; height: 100%; margin: 0; font-size: 1.35rem; line-height: 1; }
    .app-shell .app-nav .nav-label { display: none; }
    .app-shell .app-nav .nav-icon svg, .app-shell .mobile-logout .nav-icon svg { width: 21px; height: 21px; }
    .app-shell .mobile-logout { display:grid; grid-column:3; flex:0 0 44px; place-items:center; width:44px; height:44px; min-height:44px; margin:0; padding:0; border:1px solid #ef6268; border-radius:11px; color:#fff; background:linear-gradient(135deg,#ef5259,#cf2935); box-shadow:0 5px 12px rgba(178,31,43,.27); font-weight:700; text-decoration:none; line-height:1; }
    .app-shell .mobile-logout:hover { color:#fff; border-color:#ff7b81; background:linear-gradient(135deg,#f35d64,#da303b); }
    .app-shell .mobile-logout span:first-child { font-size:1.45rem; line-height:1; }
    .app-shell .mobile-logout span:last-child { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
    .app-shell .app-main, .app-shell .utility-main { padding: 18px 12px 34px; }
    .app-shell .workspace-header { margin-bottom: 16px; }
    .app-shell .workspace-header h1, .app-shell .utility-main .page-heading h1 { font-size: 1.72rem; letter-spacing: -.045em; }
    .app-shell .workspace-header p:not(.eyebrow), .app-shell .utility-main .page-heading > div > p:last-child { font-size: .91rem; line-height: 1.45; }
    .app-shell .db-health { gap: 10px; width: 100%; margin-top: 14px; padding: 12px 13px; border-radius: 12px; }
    .app-shell .health-icon { width: 34px; height: 34px; font-size: 1.05rem; }
    .app-shell .search-workspace { padding: 12px; border-radius: 14px; }
    .app-shell .search-row { gap: 10px; }
    .app-shell .search-field { min-height: 52px; }
    .app-shell .search-icon { margin-left: 14px; font-size: 1.45rem; }
    .app-shell .search-field input { padding: 14px 39px 14px 10px; font-size: 1rem; }
    .app-shell .search-button { width: 100%; min-height: 52px; border-radius: 10px; }
    .app-shell .filter-toolbar { gap: 10px; padding-top: 12px; }
    .app-shell .sources-inline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .app-shell .source-pill { min-height: 44px; justify-content: center; padding: 0 9px; font-size: .8rem; }
    .app-shell .stock-switch { min-height: 42px; }
    .app-shell .more-filters { margin-left: 0; }
    .app-shell .more-filters summary { min-height: 42px; padding: 11px 12px; }
    .app-shell .filter-popover { position: fixed; right: 12px; left: 12px; width: auto; padding: 14px; }
    .app-shell .results-panel { margin-top: 17px; }
    .app-shell .results-panel .empty-state { min-height: 270px; padding: 24px 18px; text-align: center; }
    .app-shell .results-panel .empty-state p { max-width: 290px; }
    .app-shell .results-bar { gap: 12px; padding-bottom: 12px; }
    .app-shell .sort-bar { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; white-space: nowrap; }
    .app-shell .sort-btn { min-height: 38px; flex: 0 0 auto; padding: 7px 11px; }
    .app-shell .table-wrap { overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
    .app-shell .results-table, .app-shell .results-table tbody { display: block; min-width: 0; width: 100%; }
    .app-shell .results-table thead { display: none; }
    .app-shell .results-table tbody { display: grid; gap: 10px; }
    .app-shell .results-table tbody tr:not(#non1c-start) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; padding: 14px; border: 1px solid #dfe7f1; border-radius: 13px; background: #fff; box-shadow: 0 5px 16px rgba(25, 50, 84, .05); }
    .app-shell .results-table tbody tr#non1c-start { display: none !important; }
    .app-shell .results-table tbody td { display: flex; align-items: center; justify-content: space-between; min-width: 0; padding: 9px 0; border: 0; font-size: .86rem; text-align: right; }
    .app-shell .results-table tbody td::before { margin-right: 12px; color: #748399; font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-align: left; text-transform: uppercase; content: attr(data-label); }
    .app-shell .results-table tbody td.cell-name { display: block; grid-column: 1 / -1; padding: 0 0 12px; margin-bottom: 2px; border-bottom: 1px solid #edf1f6; text-align: left; }
    .app-shell .results-table tbody td.cell-name::before { display: none; }
    .app-shell .cell-name-main { font-size: 1rem; line-height: 1.32; }
    .app-shell .results-table tbody td.cell-link { grid-column: 1 / -1; padding-top: 12px; }
    .app-shell .results-table tbody td.cell-link::before { display: none; }
    .app-shell .results-table tbody td.cell-link .tbl-link { min-width: 100%; justify-content: center; min-height: 42px; align-items: center; }
    .app-shell .results-table tbody tr.result-card.row-priority { border-color: #b9e2c9; background: #f2fbf6; }
    .app-shell .results-table tbody tr.result-card .cell-source { padding-top: 11px; }
    .app-shell .results-table tbody tr.result-card .price-cell { border-top: 1px solid #edf1f6; }
    .app-shell .results-table tbody tr.result-card .price { font-size: 1.12rem; font-weight: 800; }
    .app-shell .export-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; padding: 0; background: transparent; }
    .app-shell .export-row .btn { min-height: 42px; padding: 8px; font-size: .78rem; }
    .app-shell .utility-main .page-card, .app-shell .utility-main .card { padding: 16px; border-radius: 13px; }
    .app-shell .utility-main .page-card h2, .app-shell .utility-main .card h2 { font-size: 1rem; }
    .app-shell .utility-main input:not([type="checkbox"]), .app-shell .utility-main select { min-height: 44px; font-size: 16px; }
    .app-shell .utility-main textarea { font-size: 16px; }
    .app-shell .utility-main .btn { min-height: 44px; }
    .app-shell .utility-main .about-intro { align-items: flex-start; gap: 13px; }
    .app-shell .utility-main .about-icon { width: 44px; height: 44px; border-radius: 12px; font-size: 1.35rem; }
    #syncCard > div[style*="display:flex"], #crmApiCard .form-group > div[style*="display:flex"] { align-items: stretch !important; }
    #syncCard > div[style*="display:flex"] > div[style*="display:flex"] { flex-direction: column !important; gap: 10px !important; }
    #syncCard > div[style*="display:flex"] .form-group, #crmApiCard .form-group > div[style*="display:flex"] > input { width: 100%; }
    #syncCard #syncBtn { width: 100%; }
}

@media (max-width: 390px) {
    .app-shell .sources-inline { grid-template-columns: 1fr; }
    .app-shell .export-row { grid-template-columns: 1fr; }
    .app-shell .results-table tbody tr:not(#non1c-start) { grid-template-columns: 1fr; }
}

/* Full-width result cards on phones. Kept separate from legacy table styles. */
@media (max-width: 700px) {
    .app-shell .results-list { gap: 10px; }
    .app-shell .results-list .result-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; padding: 14px; border-color: #dfe7f1; box-shadow: 0 5px 16px rgba(25, 50, 84, .05); }
    .app-shell .results-list .cell-name { grid-column: 1 / -1; padding: 0 0 12px; margin-bottom: 2px; text-align: left; }
    .app-shell .results-list .cell-source, .app-shell .results-list .cell-avail, .app-shell .results-list .price-cell { display: flex; align-items: center; justify-content: space-between; min-width: 0; padding: 9px 0; color: inherit; font-size: .86rem; text-align: right; white-space: normal; }
    .app-shell .results-list .cell-source::before, .app-shell .results-list .cell-avail::before, .app-shell .results-list .price-cell::before { margin-right: 12px; color: #748399; font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-align: left; text-transform: uppercase; content: attr(data-label); }
    .app-shell .results-list .cell-source { grid-column: 1; padding-top: 11px; }
    .app-shell .results-list .cell-source::before, .app-shell .results-list .cell-avail::before { display: none; }
    .app-shell .results-list .cell-avail { grid-column: 2; justify-content: flex-end; padding-top: 11px; }
    .app-shell .results-list .cell-avail .stock-badge, .app-shell .results-list .cell-avail .branch-badge { width: auto; text-align: center; }
    .app-shell .results-list .price-cell { grid-column: 1; justify-content: flex-start; gap: 8px; border-top: 1px solid #edf1f6; }
    .app-shell .results-list .price-cell::before { display: none; }
    .app-shell .results-list .price { font-size: 1.12rem; font-weight: 800; }
    .app-shell .results-list .cell-link { display: flex; grid-column: 2; align-items: center; justify-self: end; padding-top: 9px; border-top: 1px solid #edf1f6; }
    .app-shell .results-list .cell-link .tbl-link { display: inline-flex; width: auto; min-width: 94px; min-height: 38px; }
    .app-shell .results-list .result-card.row-priority { border-color: #b9e2c9; background: #f2fbf6; }
}

@media (max-width: 390px) {
    .app-shell .results-list .result-card { grid-template-columns: minmax(0, 1fr) auto; }
}
