:root,
body[data-theme="dark"] {
    --bg: #071018;
    --surface: rgba(12, 22, 40, 0.88);
    --surface-strong: #0d1729;
    --surface2: rgba(18, 30, 52, 0.92);
    --surface3: #1e3358;
    --surface-accent: rgba(50, 92, 184, 0.14);
    --border: rgba(115, 144, 196, 0.2);
    --border2: rgba(115, 144, 196, 0.32);
    --blue: #6eb5ff;
    --blue-strong: #3d82f6;
    --cyan: #3ee0d0;
    --blue-glow: rgba(79, 134, 247, 0.28);
    --green: #3dd9a0;
    --amber: #ffbe4a;
    --red: #ff7b8a;
    --purple: #c084fc;
    --violet: #a78bfa;
    --emerald: #34d399;
    --text: #f5f7fb;
    --text2: #9eb0c9;
    --text3: #63748f;
    --shadow: 0 24px 60px rgba(2, 8, 23, 0.42);
    --page-gradient:
        radial-gradient(ellipse 80% 50% at 0% -10%, rgba(110, 181, 255, 0.22), transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(62, 224, 208, 0.14), transparent 50%),
        radial-gradient(ellipse 50% 35% at 70% 100%, rgba(192, 132, 252, 0.12), transparent 45%),
        linear-gradient(180deg, #071018 0%, #050a12 100%);
}

body[data-theme="light"] {
    --bg: #edf3fb;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: #ffffff;
    --surface2: rgba(243, 247, 253, 0.96);
    --surface3: #dfeafb;
    --surface-accent: rgba(72, 112, 191, 0.1);
    --border: rgba(74, 101, 147, 0.16);
    --border2: rgba(74, 101, 147, 0.26);
    --blue: #1d5fd4;
    --blue-strong: #164fb3;
    --cyan: #0d9488;
    --blue-glow: rgba(36, 87, 197, 0.2);
    --green: #15803d;
    --amber: #b45309;
    --red: #be123c;
    --purple: #7e22ce;
    --violet: #6d28d9;
    --emerald: #047857;
    --text: #142033;
    --text2: #52627a;
    --text3: #7a889b;
    --shadow: 0 18px 48px rgba(81, 108, 149, 0.2);
    --page-gradient:
        radial-gradient(ellipse 80% 50% at 0% -10%, rgba(59, 130, 246, 0.2), transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(13, 148, 136, 0.12), transparent 50%),
        radial-gradient(ellipse 50% 35% at 80% 100%, rgba(124, 58, 237, 0.1), transparent 45%),
        linear-gradient(180deg, #f4f8ff 0%, #e8f0fc 100%);
}

html,
body {
    background: var(--page-gradient);
    min-height: 100dvh;
}

body {
    position: relative;
    color: var(--text);
    transition: background 180ms ease, color 180ms ease;
    overscroll-behavior: none;
    touch-action: manipulation;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    width: 22rem;
    height: 22rem;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(48px);
    opacity: 0.55;
    z-index: 0;
}

body::before {
    top: -8rem;
    right: -4rem;
    background: rgba(110, 181, 255, 0.22);
}

body::after {
    bottom: -10rem;
    left: -6rem;
    background: rgba(192, 132, 252, 0.16);
}

#auth-screen,
#app {
    position: relative;
    z-index: 1;
}

.app-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.setup-banner {
    margin-bottom: 0.25rem;
    align-items: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.16), rgba(62, 224, 208, 0.1));
    border-color: rgba(110, 181, 255, 0.35);
}

.setup-banner-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(110, 181, 255, 0.35), rgba(62, 224, 208, 0.25));
    color: var(--cyan);
}

.setup-banner-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.topbar,
.sidebar,
.card,
.modal,
.mobile-nav,
.auth-card {
    backdrop-filter: blur(22px);
}

.topbar,
.sidebar,
.mobile-nav,
.card,
.modal,
.auth-card,
.tbl-wrap,
.stat,
.qa-card,
.conn-status {
    box-shadow: var(--shadow);
}

.topbar,
.sidebar,
.mobile-nav,
.card,
.modal,
.auth-card,
.tbl-wrap,
.stat,
.qa-card,
.conn-status {
    background: var(--surface);
    border-color: var(--border);
}

.topbar,
.mobile-nav {
    background: rgba(10, 19, 34, 0.74);
}

body[data-theme="light"] .topbar,
body[data-theme="light"] .mobile-nav {
    background: rgba(255, 255, 255, 0.9);
}

.sidebar {
    background: linear-gradient(180deg, rgba(10, 19, 34, 0.9), rgba(10, 19, 34, 0.78));
}

body[data-theme="light"] .sidebar {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 249, 255, 0.88));
}

.logo,
.sidebar-logo {
    font-family: "Fraunces", serif;
    font-size: 1.18rem;
    letter-spacing: -0.04em;
}

.logo span,
.sidebar-logo span {
    background: linear-gradient(135deg, var(--blue) 0%, var(--cyan) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.screen-head,
.setup-intro {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.screen-copy,
.setup-copy {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 42rem;
}

.page-kicker,
.section-label {
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.68rem;
    font-weight: 700;
}

.page-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: fit-content;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: var(--surface-accent);
    border: 1px solid var(--border);
    color: var(--text2);
}

.page-eyebrow.accent-sky {
    color: var(--blue);
    background: rgba(110, 181, 255, 0.14);
    border-color: rgba(110, 181, 255, 0.28);
}

.page-eyebrow.accent-violet {
    color: var(--violet);
    background: rgba(167, 139, 250, 0.14);
    border-color: rgba(167, 139, 250, 0.28);
}

.page-eyebrow.accent-emerald {
    color: var(--emerald);
    background: rgba(52, 211, 153, 0.14);
    border-color: rgba(52, 211, 153, 0.28);
}

.page-eyebrow.accent-amber {
    color: var(--amber);
    background: rgba(255, 190, 74, 0.14);
    border-color: rgba(255, 190, 74, 0.28);
}

.section-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-label::before {
    content: "";
    width: 3px;
    height: 0.85rem;
    border-radius: 99px;
    background: linear-gradient(180deg, var(--blue), var(--cyan));
    flex-shrink: 0;
}

.card-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title-icon,
.card-title [data-lucide] {
    width: 1rem;
    height: 1rem;
    color: var(--blue);
}

.page-title {
    font-family: "Fraunces", serif;
    font-size: clamp(1.5rem, 3.2vw, 2.2rem);
    line-height: 1.02;
    letter-spacing: -0.045em;
}

.page-subtitle {
    font-size: 0.96rem;
    color: var(--text2);
    max-width: 40rem;
}

.icon-badge,
.theme-toggle,
.surface-pill,
.summary-chip,
.catalog-pill,
.inline-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.icon-badge {
    width: 3.25rem;
    height: 3.25rem;
    justify-content: center;
    border-radius: 1rem;
    background: linear-gradient(135deg, rgba(123, 176, 255, 0.24), rgba(56, 199, 147, 0.16));
    color: var(--blue);
    border: 1px solid rgba(123, 176, 255, 0.22);
}

.theme-toggle {
    min-width: 8.75rem;
}

.theme-toggle .theme-label {
    white-space: nowrap;
}

.surface-pill,
.summary-chip,
.catalog-pill {
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    background: var(--surface-accent);
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 0.78rem;
}

.product-summary .summary-chip:nth-child(1) {
    background: rgba(110, 181, 255, 0.14);
    border-color: rgba(110, 181, 255, 0.28);
    color: var(--blue);
}

.product-summary .summary-chip:nth-child(2) {
    background: rgba(62, 224, 208, 0.12);
    border-color: rgba(62, 224, 208, 0.26);
    color: var(--cyan);
}

.product-summary .summary-chip:nth-child(3) {
    background: rgba(52, 211, 153, 0.12);
    border-color: rgba(52, 211, 153, 0.26);
    color: var(--emerald);
}

.product-summary .summary-chip:nth-child(4) {
    background: rgba(255, 190, 74, 0.12);
    border-color: rgba(255, 190, 74, 0.26);
    color: var(--amber);
}

.product-summary .summary-chip strong {
    color: var(--text);
}

.summary-chip strong,
.catalog-pill strong {
    color: var(--text);
    font-size: 0.86rem;
}

.product-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.toolbar-stack {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.toolbar-actions,
.button-cluster {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.product-layout {
    display: grid;
    gap: 1rem;
}

.product-cards {
    display: none;
    gap: 0.9rem;
}

.product-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.product-card-top,
.product-card-bottom,
.meta-grid {
    display: flex;
    justify-content: space-between;
    gap: 0.9rem;
    flex-wrap: wrap;
}

.product-name {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text);
}

.product-subline,
.muted-copy,
.meta-label {
    color: var(--text2);
    font-size: 0.8rem;
}

.price-value {
    font-family: "JetBrains Mono", monospace;
    font-weight: 700;
    color: var(--blue);
}

.source-badge[data-source="zk"] {
    background: rgba(123, 176, 255, 0.18);
    color: var(--blue);
}

.source-badge[data-source="merged"] {
    background: rgba(56, 199, 147, 0.18);
    color: var(--green);
}

.source-badge[data-source="local"] {
    background: rgba(246, 180, 79, 0.16);
    color: var(--amber);
}

.table-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0;
    gap: 1rem;
    flex-wrap: wrap;
}

.action-cell,
.action-cluster {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.btn,
.btn-icon,
.nav-tab,
.sidebar-btn,
.qa-card,
.btn-secondary,
.btn-primary,
.btn-success,
.btn-danger {
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

.btn:hover,
.btn-icon:hover,
.nav-tab:hover,
.sidebar-btn:hover,
.qa-card:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue-strong) 0%, var(--cyan) 120%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 24px rgba(61, 130, 246, 0.35);
    color: #fff;
}

.btn-primary:hover {
    box-shadow: 0 10px 28px rgba(61, 130, 246, 0.45);
}

.btn-success {
    background: linear-gradient(135deg, var(--emerald), var(--green));
    color: #fff;
    border: none;
}

.btn-secondary,
.btn-icon,
.nav-tab,
.sidebar-btn,
.inp,
.tbl-wrap,
.stat,
.qa-card,
.conn-status {
    background: var(--surface2);
}

.stats {
    gap: 0.9rem;
}

.stat {
    position: relative;
    border-radius: 1rem;
    padding: 1rem 1rem 1rem 1.1rem;
    overflow: hidden;
    border-left: 3px solid var(--border2);
}

.stat::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    opacity: 0.35;
    transform: translate(30%, -30%);
    pointer-events: none;
}

.stat.blue {
    border-left-color: var(--blue);
    background: linear-gradient(145deg, rgba(110, 181, 255, 0.12), var(--surface2) 55%);
}

.stat.blue::after {
    background: var(--blue);
}

.stat.green {
    border-left-color: var(--green);
    background: linear-gradient(145deg, rgba(52, 211, 153, 0.12), var(--surface2) 55%);
}

.stat.green::after {
    background: var(--green);
}

.stat.amber {
    border-left-color: var(--amber);
    background: linear-gradient(145deg, rgba(255, 190, 74, 0.12), var(--surface2) 55%);
}

.stat.amber::after {
    background: var(--amber);
}

.stat.purple {
    border-left-color: var(--purple);
    background: linear-gradient(145deg, rgba(192, 132, 252, 0.12), var(--surface2) 55%);
}

.stat.purple::after {
    background: var(--purple);
}

.stat.purple .stat-val {
    color: var(--purple);
}

.stat-icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.55rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.35rem;
    background: rgba(255, 255, 255, 0.06);
}

.stat.blue .stat-icon {
    color: var(--blue);
    background: rgba(110, 181, 255, 0.18);
}

.stat.green .stat-icon {
    color: var(--green);
    background: rgba(52, 211, 153, 0.18);
}

.stat.amber .stat-icon {
    color: var(--amber);
    background: rgba(255, 190, 74, 0.18);
}

.stat.purple .stat-icon {
    color: var(--purple);
    background: rgba(192, 132, 252, 0.18);
}

.stat-icon svg {
    width: 1rem;
    height: 1rem;
}

.stat-lbl {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
}

.qa-card {
    min-height: 9.4rem;
    justify-content: space-between;
    border-width: 1px;
    border-style: solid;
}

.qa-card .qa-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qa-emerald {
    border-color: rgba(52, 211, 153, 0.35);
    background: linear-gradient(160deg, rgba(52, 211, 153, 0.14), var(--surface2) 70%);
}

.qa-emerald .qa-icon {
    color: var(--emerald);
    background: rgba(52, 211, 153, 0.2);
}

.qa-emerald:hover {
    border-color: var(--emerald);
    box-shadow: 0 8px 24px rgba(52, 211, 153, 0.2);
}

.qa-sky {
    border-color: rgba(110, 181, 255, 0.35);
    background: linear-gradient(160deg, rgba(110, 181, 255, 0.14), var(--surface2) 70%);
}

.qa-sky .qa-icon {
    color: var(--blue);
    background: rgba(110, 181, 255, 0.2);
}

.qa-sky:hover {
    border-color: var(--blue);
    box-shadow: 0 8px 24px rgba(110, 181, 255, 0.2);
}

.qa-amber {
    border-color: rgba(255, 190, 74, 0.35);
    background: linear-gradient(160deg, rgba(255, 190, 74, 0.14), var(--surface2) 70%);
}

.qa-amber .qa-icon {
    color: var(--amber);
    background: rgba(255, 190, 74, 0.2);
}

.qa-amber:hover {
    border-color: var(--amber);
    box-shadow: 0 8px 24px rgba(255, 190, 74, 0.2);
}

.qa-violet {
    border-color: rgba(167, 139, 250, 0.35);
    background: linear-gradient(160deg, rgba(167, 139, 250, 0.14), var(--surface2) 70%);
}

.qa-violet .qa-icon {
    color: var(--violet);
    background: rgba(167, 139, 250, 0.2);
}

.qa-violet:hover {
    border-color: var(--violet);
    box-shadow: 0 8px 24px rgba(167, 139, 250, 0.2);
}

.qa-icon,
.s-icon,
.icon-btn i,
.btn i,
.btn-icon i,
.nav-tab i,
.theme-toggle i,
.empty-icon i,
.inline-icon i,
.icon-badge i {
    width: 1rem;
    height: 1rem;
    stroke-width: 2;
}

.qa-icon i,
.s-icon i,
.icon-badge i {
    width: 1.2rem;
    height: 1.2rem;
}

.mobile-nav-btn {
    background: transparent;
    border: none;
    transform: none;
}

.mobile-nav-btn:hover,
.mobile-nav-btn:active {
    transform: none;
}

.mnav-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.mnav-icon svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
    display: block;
}

.sidebar-btn.active {
    font-weight: 600;
}

.sidebar-btn.active[data-nav="dashboard"] {
    background: rgba(110, 181, 255, 0.16);
    color: var(--blue);
    box-shadow: inset 3px 0 0 var(--blue);
}

.sidebar-btn.active[data-nav="products"] {
    background: rgba(167, 139, 250, 0.16);
    color: var(--violet);
    box-shadow: inset 3px 0 0 var(--violet);
}

.sidebar-btn.active[data-nav="bind"] {
    background: rgba(62, 224, 208, 0.14);
    color: var(--cyan);
    box-shadow: inset 3px 0 0 var(--cyan);
}

.sidebar-btn.active[data-nav="quick"] {
    background: rgba(52, 211, 153, 0.14);
    color: var(--emerald);
    box-shadow: inset 3px 0 0 var(--emerald);
}

.sidebar-btn.active[data-nav="settings"] {
    background: rgba(255, 190, 74, 0.14);
    color: var(--amber);
    box-shadow: inset 3px 0 0 var(--amber);
}

.mobile-nav-btn.active[data-nav="dashboard"] {
    color: var(--blue);
    background: rgba(110, 181, 255, 0.16);
}

.mobile-nav-btn.active[data-nav="products"] {
    color: var(--violet);
    background: rgba(167, 139, 250, 0.16);
}

.mobile-nav-btn.active[data-nav="bind"] {
    color: var(--cyan);
    background: rgba(62, 224, 208, 0.14);
}

.mobile-nav-btn.active[data-nav="quick"] {
    color: var(--emerald);
    background: rgba(52, 211, 153, 0.14);
}

.mobile-nav-btn.active[data-nav="settings"] {
    color: var(--amber);
    background: rgba(255, 190, 74, 0.14);
}

.mobile-nav-btn.active .mnav-label {
    color: inherit;
}

.auth-card {
    border-color: rgba(110, 181, 255, 0.25);
    background: linear-gradient(165deg, rgba(110, 181, 255, 0.08), var(--surface) 45%);
}

.auth-badge {
    background: linear-gradient(135deg, rgba(110, 181, 255, 0.2), rgba(62, 224, 208, 0.15));
    color: var(--cyan);
    border: 1px solid rgba(110, 181, 255, 0.25);
}

.card {
    border-color: var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%), var(--surface);
}

body[data-theme="light"] .card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.85));
}

.product-card {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.product-card:hover {
    border-color: rgba(110, 181, 255, 0.4);
    box-shadow: 0 8px 20px rgba(61, 130, 246, 0.12);
}

.conn-status {
    border: 1px solid var(--border);
}

.log-item .log-dot.ok,
.log-dot.ok {
    background: var(--green);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.inp:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

.empty {
    padding: 3rem 1.2rem;
}

.empty-icon {
    width: 3rem;
    height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    background: var(--surface-accent);
    color: var(--blue);
    opacity: 1;
}

.toast-item i {
    width: 1rem;
    height: 1rem;
}

.catalog-note {
    font-size: 0.82rem;
    color: var(--text2);
}

.search-row {
    flex-wrap: wrap;
}

.search-wrap {
    min-width: min(26rem, 100%);
}

.setting-actions,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.table-secondary {
    color: var(--text2);
    font-size: 0.78rem;
}

.table-name {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 13rem;
}

.bind-result,
.quick-result {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 0.85rem;
}

.battery-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
}

@media (max-width: 900px) {
    .tbl-wrap {
        display: none;
    }

    .product-cards,
    .products-mobile {
        display: grid;
    }

    .table-shell {
        display: none;
    }

    .screen-head,
    .setup-intro {
        flex-direction: column;
    }
}

@media (max-width: 1023px) {
    .qa-card:active,
    .mobile-nav-btn:active,
    .btn:active {
        transform: scale(0.98);
    }
}

@media (max-width: 600px) {
    .page-title {
        font-size: 1.38rem;
    }

    .theme-toggle .theme-label,
    .auth-user {
        display: none;
    }

    .toolbar-actions,
    .button-cluster,
    .topbar-actions {
        width: 100%;
    }

    .toolbar-actions .btn,
    .button-cluster .btn,
    .topbar-actions .btn {
        flex: 1 1 10rem;
    }

    .btn,
    .btn-icon,
    .inp {
        min-height: 44px;
    }

    .btn-sm,
    .btn-icon {
        min-height: 40px;
    }
}