:root {
    --sidebar: #111827;
    --sidebar-muted: #94a3b8;
    --primary: #2563eb;
    --page: #f1f5f9;
    --border: #e2e8f0;
    --text: #0f172a;
    --sidebar-width: 248px;
    --topbar-height: 76px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--text); background: var(--page); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; font-size: 14px; }

.app-shell { min-height: 100vh; }
.app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 1030; width: var(--sidebar-width);
    display: flex; flex-direction: column; padding: 24px 16px 18px; color: #fff; background: var(--sidebar); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 26px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 9px; background: linear-gradient(135deg, #60a5fa, #2563eb); font-size: 11px; font-weight: 700; letter-spacing: 0; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.sidebar-label { margin: 0 10px 8px; color: var(--sidebar-muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-nav { display: grid; gap: 4px; margin-bottom: 24px; }
.side-link, .sidebar-logout button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 7px; color: #cbd5e1; background: transparent; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer; transition: background .15s ease, color .15s ease; }
.side-icon { width: 16px; color: #93c5fd; text-align: center; flex: 0 0 auto; }
.side-link:hover, .side-link.active, .sidebar-logout button:hover { color: #fff; background: #1e293b; }
.side-link.active { background: #1d4ed8; }
.side-link.active .side-icon { color: #fff; }
.sidebar-logout { margin-top: auto; }

.app-main { min-width: 0; min-height: 100vh; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.app-topbar {
    position: fixed; top: 0; left: var(--sidebar-width); right: 0; z-index: 1020; height: var(--topbar-height);
    display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--border); background: #fff;
}
.eyebrow { margin: 0 0 3px; color: #64748b; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.page-title { margin: 0; font-size: 20px; font-weight: 700; }
.account { display: flex; align-items: center; gap: 9px; color: #475569; }
.account-avatar { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: #1d4ed8; background: #dbeafe; font-size: 13px; font-weight: 700; }
.account-name { font-size: 14px; }

.app-content { flex: 1; width: 100%; padding: calc(var(--topbar-height) + 26px) 28px 32px; }
.page-card { padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 4%); }
.page-card + .page-card { margin-top: 20px; }
.reviews-page {
    display: flex; flex-direction: column;
    padding-top: 0;
    height: calc(100vh - var(--topbar-height) - 58px);
}
.sticky-toolbar {
    position: static; z-index: 1;
    margin: 0 -24px 8px; padding: 24px 24px 16px; border-bottom: 1px solid var(--border);
    border-radius: 12px 12px 0 0; background: #fff; box-shadow: 0 4px 12px rgb(15 23 42 / 4%);
}
.sticky-toolbar .section-header { margin-bottom: 16px; }
.sticky-toolbar .filter-form { margin-bottom: 0; }
.reviews-page .table-scroll { flex: 1 1 auto; min-height: 0; max-height: none; }
.reviews-page .pagination-actions { flex: none; margin-top: 16px; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-title { margin: 0; font-size: 17px; font-weight: 700; }
.section-description { margin: 5px 0 0; color: #64748b; font-size: 14px; }

.table { margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 13px 14px; border-bottom-color: var(--border); vertical-align: middle; }
.table thead th { border-bottom-width: 1px; color: #64748b; background: #f8fafc; font-size: 12px; font-weight: 700; white-space: nowrap; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table-responsive { border: 1px solid var(--border); border-radius: 9px; }
.table-scroll { max-height: clamp(320px, 62vh, 720px); overflow: auto; border: 1px solid var(--border); border-radius: 9px; }
.table-scroll .table { margin-bottom: 0; }
.table-scroll thead th { position: sticky; top: 0; z-index: 2; background: #f8fafc; }

.products-table { table-layout: fixed; min-width: 1380px; }
.products-table .col-product { width: 260px; }
.products-table .col-company { width: 220px; }
.products-table .col-type { width: 120px; }
.products-table .col-appid { width: 150px; }
.products-table .col-storefront { width: 80px; }
.products-table .col-status { width: 140px; }
.products-table .col-next { width: 170px; }
.products-table .col-actions { width: 240px; }
.products-table .col-product,
.products-table .col-company { word-break: break-word; white-space: normal; }
.products-table th.col-actions,
.products-table td.col-actions {
    position: sticky; right: 0; background: #fff;
    box-shadow: -8px 0 10px -8px rgb(15 23 42 / 14%);
}
.products-table th.col-actions { top: 0; z-index: 3; background: #f8fafc; }
.products-table td.col-actions { z-index: 1; }
.products-table .actions-cell { display: flex; gap: 8px; flex-wrap: nowrap; }

.products-page {
    display: flex; flex-direction: column;
    height: calc(100vh - var(--topbar-height) - 58px);
}
.products-page .section-header { flex: none; }
.products-page .table-scroll { flex: 1 1 auto; min-height: 0; max-height: none; }


.empty-state { padding: 44px 20px; color: #64748b; text-align: center; }

.status-badge { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-success { color: #047857; background: #d1fae5; }
.status-running { color: #1d4ed8; background: #dbeafe; }
.status-pending { color: #a16207; background: #fef3c7; }
.status-failed { color: #b91c1c; background: #fee2e2; }
.status-disabled { color: #64748b; background: #e2e8f0; }

.rating { color: #d97706; letter-spacing: 1px; white-space: nowrap; }
.review-body { min-width: 250px; max-width: 480px; color: #475569; white-space: normal; word-break: break-word; }
.text-muted-small { color: #64748b; font-size: 12px; }
.form-label { font-size: 14px; font-weight: 600; }
.form-control, .form-select { min-height: 42px; border-color: #cbd5e1; }
.form-control:focus, .form-select:focus { border-color: #60a5fa; box-shadow: 0 0 0 .2rem rgb(37 99 235 / 12%); }
.btn { min-height: 40px; font-weight: 600; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.pagination-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.pagination-info { color: #64748b; font-size: 13px; }
.page-link-nav, .page-number { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 12px; border: 1px solid #cbd5e1; border-radius: 7px; color: #334155; background: #fff; font-size: 14px; font-weight: 600; text-decoration: none; }
.page-link-nav:hover, .page-number:hover { border-color: #94a3b8; background: #f8fafc; color: var(--text); }
.page-number.active { color: #fff; background: var(--primary); border-color: var(--primary); }
.page-link-nav.disabled, .page-number.disabled { color: #94a3b8; cursor: not-allowed; background: #f8fafc; }
.alert { border: 0; }

.filter-form { padding: 16px; border-radius: 9px; background: #f8fafc; }

.collect-form { padding: 16px; border-radius: 9px; background: #f8fafc; }
.collect-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.collect-check-all { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: #334155; font-weight: 600; cursor: pointer; }
.collect-check-all input[type="checkbox"] { width: 16px; height: 16px; }
.collect-list { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; background: #fff; }
.collect-item { display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.collect-item:last-child { border-bottom: 0; }
.collect-item:hover { background: #f8fafc; }
.collect-item input[type="checkbox"] { flex: 0 0 auto; width: 16px; height: 16px; margin-top: 3px; }
.collect-item-main { display: grid; gap: 2px; }
.collect-item-name { color: var(--text); font-weight: 600; }
.collect-item-meta { color: #64748b; font-size: 12px; }
.collect-actions { display: flex; gap: 10px; margin-top: 14px; }


.auth-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #dbeafe, transparent 38%), var(--page); }
.auth-card { width: min(100%, 430px); padding: 34px; border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: 0 18px 45px rgb(15 23 42 / 12%); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-size: 21px; font-weight: 700; }
.auth-card h1 { margin-bottom: 8px; font-size: 24px; }
.auth-card .subtitle { margin-bottom: 26px; color: #64748b; font-size: 14px; }

@media (max-width: 992px) {
    .app-sidebar { position: static; top: auto; left: auto; bottom: auto; width: 100%; padding: 14px; }
    .sidebar-label, .sidebar-logout { display: none; }
    .sidebar-nav { display: flex; overflow-x: auto; gap: 4px; margin-bottom: 8px; }
    .side-link { flex: 0 0 auto; width: auto; }
    .app-main { margin-left: 0; }
    .app-topbar { position: static; height: auto; padding: 16px 20px; }
    .app-content { padding: 20px 16px 28px; }
    .account-name { display: none; }
    .section-header { align-items: flex-start; flex-direction: column; }
    .section-header .btn { width: 100%; }
    .products-page { height: auto; }
    .reviews-page { height: auto; }
}
