* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Segoe UI", Arial, sans-serif; background: #f5f7fb; color: #1f2937; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #151923; color: #fff; padding: 22px 0; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 20px; font-weight: 800; color: #ffcc00; text-align: center; margin-bottom: 28px; }
.nav-menu { list-style: none; }
.nav-menu li { padding: 14px 24px; color: #b8beca; cursor: pointer; border-left: 4px solid transparent; }
.nav-menu li:hover { background: #242b38; color: #fff; }
.nav-menu li.active { background: #ffcc00; color: #111827; border-left-color: #0f766e; font-weight: 800; }
.side-subnav { display: none; margin: 18px 10px 0; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.side-subnav.visible { display: grid; gap: 6px; }
.side-subnav-title { color: #8f98a8; font-size: 12px; font-weight: 800; padding: 0 14px 4px; }
.side-subnav button { width: 100%; min-height: 36px; padding: 8px 14px; border-radius: 4px; background: transparent; color: #b8beca; text-align: left; font-size: 13px; font-weight: 700; }
.side-subnav button:hover { background: #242b38; color: #fff; }
.side-subnav button.active { background: #173657; color: #fff; }
.main-content { flex: 1; padding: 26px; overflow: auto; }
.view-section { display: none; }
.view-section.active { display: block; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
h1 { font-size: 24px; letter-spacing: 0; }
button { border: 0; border-radius: 6px; background: #1f2937; color: #fff; padding: 9px 13px; cursor: pointer; font-weight: 700; }
button:hover { filter: brightness(1.05); }
button:disabled { opacity: .6; cursor: wait; }
.icon-button, .mini-button { background: #0f766e; }
.mini-button { padding: 5px 8px; margin-top: 6px; font-size: 12px; display: block; }
.mini-button.secondary { background: #1f2937; }
.danger-button, .text-danger { background: #dc2626; }
.text-danger { padding: 6px 8px; font-size: 12px; }
.link-button { color: #1d4ed8; background: transparent; padding: 0; text-align: left; font-weight: 800; }
.sku-link, .keyword-link { color: #1d4ed8; font-weight: 800; text-decoration: none; }
.sku-link:hover, .keyword-link:hover { text-decoration: underline; }
.rank-number { font-size: 16px; color: #111827; }
.button-row { display: flex; align-items: center; gap: 10px; }
.button-row.tight { gap: 6px; align-items: flex-start; }
.button-row.tight .mini-button { margin-top: 0; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.toolbar input { width: min(520px, 100%); padding: 10px 12px; border: 1px solid #d7dce5; border-radius: 6px; font-size: 14px; }
.sort-select { min-height: 38px; padding: 8px 10px; border: 1px solid #d7dce5; border-radius: 6px; background: #fff; color: #111827; font-weight: 700; }
.backend-status { display: inline-flex; align-items: center; min-height: 34px; padding: 0 10px; border-radius: 999px; background: #eef2f7; color: #475569; font-size: 12px; font-weight: 800; white-space: nowrap; }
.backend-status.ok { background: #dcfce7; color: #166534; }
.backend-status.danger { background: #fee2e2; color: #991b1b; }
.sync-status { display: inline-flex; align-items: center; min-height: 38px; color: #596273; font-size: 13px; white-space: nowrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 18px; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05); }
.metric-card span { display: block; color: #687385; font-size: 13px; margin-bottom: 8px; }
.metric-card strong { font-size: 25px; color: #111827; }
.metric-note { color: #475569; font-size: 13px; line-height: 1.7; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; }
.score-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 42px; height: 26px; padding: 0 8px; border-radius: 999px; background: #111827; color: #fff; font-weight: 800; font-size: 12px; }
.score-pill.good { background: #0f766e; }
.score-pill.warn { background: #b45309; }
.score-pill.bad { background: #b91c1c; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.panel, .table-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05); }
.analysis-list-panel { min-height: 620px; }
.analysis-note { margin-top: 14px; }
.product-table-card { overflow-x: auto; }
.panel.inner, .table-card.inner { box-shadow: none; margin-top: 14px; }
.panel-title { font-weight: 800; margin-bottom: 12px; color: #111827; }
.stack-list, .log-list { display: grid; gap: 8px; }
.list-row { display: flex; align-items: center; gap: 10px; border: 1px solid #edf0f5; border-radius: 8px; padding: 10px; background: #fbfcfe; min-height: 58px; }
.clickable, .clickable-row { cursor: pointer; }
.clickable:hover, .clickable-row:hover { background: #f0f7ff; }
.list-main { flex: 1; min-width: 0; }
.list-main b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main span, .subtle { display: block; color: #6b7280; font-size: 12px; margin-top: 3px; }
.subtle.compact { max-width: 95px; line-height: 1.25; }
.list-side { font-size: 13px; color: #111827; text-align: right; white-space: nowrap; }
.metric-label { display: block; color: #64748b; font-size: 11px; font-weight: 800; margin-bottom: 2px; }
.inline-subtle { display: block; margin-top: 2px; }
.thumb { width: 46px; height: 46px; object-fit: contain; border: 1px solid #e5e7eb; border-radius: 6px; background: #fff; }
.empty-state { color: #7b8494; padding: 18px; text-align: center; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 10px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
th { color: #596273; background: #f8fafc; font-weight: 800; text-align: left; }
.product-table-card table { min-width: 1050px; }
.product-cell { display: flex; gap: 10px; align-items: center; min-width: 280px; }
.product-cell span { display: block; color: #6b7280; font-size: 12px; margin-top: 4px; }
.api-cell { min-width: 96px; }
.api-error { color: #991b1b; max-width: 140px; white-space: normal; line-height: 1.25; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-height: 22px; padding: 3px 8px; border-radius: 999px; font-size: 12px; background: #e5e7eb; color: #374151; margin-right: 4px; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.muted { background: #eef2f7; color: #64748b; }
.log-row { display: grid; grid-template-columns: 150px 1fr auto 2fr; gap: 10px; align-items: center; padding: 9px 10px; border-bottom: 1px solid #eef1f6; font-size: 12px; }
.log-row em { color: #7b8494; font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.62); display: flex; align-items: center; justify-content: center; z-index: 99999; padding: 20px; }
.modal-card { width: min(720px, 96vw); max-height: 92vh; overflow: auto; background: #fff; border-radius: 8px; padding: 18px; box-shadow: 0 24px 70px rgba(15, 23, 42, 0.35); }
.modal-wide { width: min(1180px, 96vw); }
.modal-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e5e7eb; padding-bottom: 12px; margin-bottom: 16px; }
.modal-header h2 { font-size: 20px; }
.modal-header button { background: transparent; color: #111827; font-size: 24px; padding: 0 6px; }
.detail-grid { display: grid; grid-template-columns: 120px 1fr 220px; gap: 18px; align-items: start; }
.detail-grid .thumb { width: 120px; height: 120px; }
.detail-grid h3 { margin-bottom: 8px; }
.detail-side { display: grid; gap: 8px; justify-items: start; }
.detail-side strong { font-size: 24px; color: #dc2626; }
.detail-side a { color: #1d4ed8; font-weight: 800; text-decoration: none; }
.chips { margin-top: 12px; }
.analytics-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.analytics-strip div { border: 1px solid #e5e7eb; background: #f8fafc; border-radius: 8px; padding: 12px; }
.analytics-strip span { display: block; color: #6b7280; font-size: 12px; margin-bottom: 6px; }
.analytics-strip b { font-size: 20px; }
.chart-box { height: 270px; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; margin-bottom: 14px; }
.settings-list { display: grid; gap: 10px; }
.settings-row { display: grid; grid-template-columns: 1fr 180px 160px; gap: 14px; align-items: center; border: 1px solid #edf0f5; border-radius: 8px; padding: 12px; background: #fbfcfe; }
.settings-row label { display: grid; gap: 6px; color: #596273; font-size: 12px; font-weight: 700; }
.settings-row input, .settings-row select { padding: 9px 10px; border: 1px solid #d7dce5; border-radius: 6px; background: #fff; color: #111827; }
.loading { padding: 30px; text-align: center; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; color: #596273; font-size: 13px; }
.pagination button { padding: 7px 10px; min-width: 72px; background: #1f2937; }
.pagination button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.stack-list .pagination { justify-content: center; margin-top: 8px; }
@media (max-width: 980px) {
    .app-shell { display: block; }
    .sidebar { width: 100%; height: auto; position: static; }
    .nav-menu { display: flex; overflow-x: auto; }
    .nav-menu li { white-space: nowrap; }
    .side-subnav.visible { display: flex; overflow-x: auto; margin: 8px 10px 0; padding: 8px 0 0; }
    .side-subnav-title { display: none; }
    .side-subnav button { width: auto; white-space: nowrap; }
    .page-heading { align-items: flex-start; flex-wrap: wrap; }
    .page-heading h1 { width: 100%; }
    .page-heading .button-row { width: 100%; flex-wrap: wrap; }
    .toolbar { flex-wrap: wrap; }
    .toolbar input, .toolbar .sort-select { width: 100%; flex: 1 1 100%; }
    .sync-status { white-space: normal; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-two, .detail-grid, .analytics-strip { grid-template-columns: 1fr; }
    .main-content { padding: 16px; }
    .table-card { overflow-x: auto; }
    .pagination { justify-content: center; flex-wrap: wrap; }
}
