:root {
  color-scheme: light;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #16233d;
  background: #f2f5fa;
  font-synthesis: none;
  --muted: #52617a;
  --line: #dce4ef;
  --accent: #3b4fc2;
  --ink: #101b34;
  --radius: 15px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 15px; line-height: 1.5; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #7b8cf5; outline-offset: 3px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.topbar { color: #eef2ff; background: #131e39; border-bottom: 1px solid #263450; }
.topbar-content { display: flex; align-items: center; gap: 44px; max-width: 1320px; min-height: 64px; margin: auto; padding: 0 32px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; white-space: nowrap; flex: none; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.ui-icon { width: 16px; height: 16px; flex: none; }
.brand-name { color: #fff; font-size: 20px; font-weight: 750; letter-spacing: -.025em; }
.navigation { display: flex; gap: 5px; align-items: stretch; align-self: stretch; }
.navigation a { position: relative; display: flex; align-items: center; gap: 7px; padding: 0 15px; color: #c5cee4; text-decoration: none; font-size: 14px; font-weight: 650; white-space: nowrap; }
.navigation .ui-icon { color: #a5b3df; }
.navigation a[aria-current="page"] .ui-icon { color: #c4cdff; }
.navigation a:hover, .navigation a[aria-current="page"] { color: #fff; background: #202d4b; }
.navigation a[aria-current="page"]::after { position: absolute; inset: auto 14px 0; height: 3px; border-radius: 3px 3px 0 0; background: #a3b0ff; content: ""; }
.topbar-actions { display: flex; align-items: center; gap: 13px; margin-left: auto; }
.sign-out { background: transparent; color: #d5def5; border: 1px solid transparent; border-radius: 7px; padding: 5px 9px; font-size: 13px; font-weight: 650; white-space: nowrap; }
.sign-out:hover { background: #202d4b; border-color: #364665; color: #fff; }

.main { max-width: 1320px; margin: auto; padding: 28px 32px 52px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 19px; flex-wrap: wrap; }
.page-heading h1 { color: var(--ink); font-size: 34px; letter-spacing: -.035em; line-height: 1.22; font-weight: 760; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.scope-switch { display: inline-flex; align-items: center; gap: 9px; min-height: 36px; padding: 0 11px; border: 1px solid #cdd7e6; border-radius: 8px; background: #fff; color: #2e3d57; font-size: 13px; font-weight: 660; cursor: pointer; user-select: none; }
.scope-switch:hover { border-color: #9ba9c6; background: #f8faff; }
.scope-switch:has(input:checked) { border-color: #a3afea; background: #edf1ff; color: #33449e; }
.scope-switch-label { white-space: nowrap; }
.scope-switch .switch-control { width: 36px; height: 21px; }
.scope-switch .switch-control::before { top: 2px; left: 2px; width: 15px; height: 15px; }
.scope-switch input:checked + .switch-control::before { left: 17px; }
.scope-notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; background: #eef1ff; color: #2d3e8f; border: 1px solid #d5ddf8; }
.scope-notice-actions { display: inline-flex; align-items: center; gap: 10px; }
.notice-link, .notice-action { border: 0; background: transparent; padding: 0; color: var(--accent); font-size: 13px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.notice-action:hover, .notice-link:hover { color: #233391; }
#overview-stats { margin-top: 5px; font-size: 14px; color: var(--muted); }
.health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; overflow: hidden; margin: 0 0 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.health-card { background: white; padding: 11px 17px 10px; min-width: 0; }
.health-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.health-heading h2 { font-size: 14px; font-weight: 690; }
.health-title-short { display: none; }
.health-time { margin-top: 3px; color: var(--muted); font-size: 12px; }
.health-error { margin-top: 4px; color: #a22743; font-size: 13px; overflow-wrap: anywhere; }
.health-status { white-space: nowrap; }
.health-status::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.badge { display: inline-flex; align-items: center; gap: 6px; width: fit-content; white-space: nowrap; border-radius: 6px; font-size: 13px; line-height: 1.3; font-weight: 720; padding: 4px 8px; }
.badge.is-good { color: #086044; background: #e4f7ed; }
.badge.is-warn { color: #865310; background: #fff1d6; }
.badge.is-error { color: #9e2040; background: #fae6ec; }
.badge.is-muted { color: #4c5c7a; background: #edf1f8; }

.stock-in { --stock-ink: #086348; --stock-line: #15936b; --stock-card: #ecf8f2; --stock-border: #c8e8d9; --stock-label: #d7f2e6; --row-wash: #f7fcf9; }
.stock-out { --stock-ink: #a22645; --stock-line: #d44868; --stock-card: #fff0f2; --stock-border: #f3ced7; --stock-label: #fbe0e7; --row-wash: #fff9fa; }
.stock-preorder { --stock-ink: #87520f; --stock-line: #c38a39; --stock-card: #fff6e6; --stock-border: #f1dfbc; --stock-label: #ffedca; --row-wash: #fffcf6; }
.stock-unknown { --stock-ink: #4a5b7a; --stock-line: #8292ad; --stock-card: #edf1f8; --stock-border: #d8e1ef; --stock-label: #e4ebf7; --row-wash: #f8faff; }
.stock-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 21px; }
.stock-tile { display: grid; justify-items: start; row-gap: 2px; min-width: 0; position: relative; min-height: 99px; padding: 12px 16px 11px; text-align: left; border: 1px solid var(--stock-border); border-radius: var(--radius); background: var(--stock-card); color: var(--stock-ink); transition: box-shadow 150ms ease, border-color 150ms ease; }
.stock-tile:hover { border-color: var(--stock-line); }
.stock-tile[aria-pressed="true"] { border-color: var(--stock-line); box-shadow: inset 0 0 0 1px var(--stock-line), 0 2px 7px #18274816; }
.stock-tile[aria-pressed="true"]::after { content: ""; position: absolute; top: 15px; right: 15px; width: 9px; height: 9px; border-radius: 50%; background: var(--stock-line); }
.tile-label { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 720; }
.stock-tile strong { font-size: 32px; line-height: 1.05; letter-spacing: -.04em; font-weight: 760; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 12px; }
.stock-mark { position: relative; display: inline-grid; place-items: center; flex: none; width: 13px; height: 13px; border: 1.5px solid currentColor; border-radius: 50%; }
.stock-mark::before, .stock-mark::after { content: ""; position: absolute; }
.stock-in .stock-mark::before { width: 6px; height: 4px; border-left: 1.5px solid; border-bottom: 1.5px solid; transform: translateY(-.7px) rotate(-45deg); }
.stock-out .stock-mark::before, .stock-out .stock-mark::after { width: 6px; height: 1.4px; background: currentColor; transform: rotate(45deg); }
.stock-out .stock-mark::after { transform: rotate(-45deg); }
.stock-preorder .stock-mark::before { width: 4px; height: 4px; margin: 0 0 2px 2px; border-left: 1.5px solid; border-bottom: 1.5px solid; }
.stock-unknown .stock-mark::before { width: 5px; height: 1.5px; background: currentColor; }
.stock-badge { color: var(--stock-ink); background: var(--stock-label); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 2px 8px #18314a08; overflow: hidden; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px 18px; padding: 15px 19px; }
.panel-title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 11px; }
.panel-title { color: var(--ink); font-size: 19px; line-height: 1.3; font-weight: 740; }
.panel-description { margin-top: 5px; color: var(--muted); font-size: 14px; }
.price-note { margin-top: 4px; color: var(--muted); font-size: 12px; }
.scope-label, .merchant-count { background: #eef1ff; color: #4251a8; border-radius: 6px; padding: 3px 8px; white-space: nowrap; font-size: 12px; font-weight: 680; }
.toolbar { display: flex; align-items: center; gap: 8px; margin: 0; }
.field { display: flex; min-width: 0; }
.field-search { width: clamp(174px, 22vw, 262px); }
.field-with-icon { position: relative; }
.field-with-icon > .field-icon { position: absolute; z-index: 1; inset: 10px auto auto 10px; color: #52617a; pointer-events: none; }
.field > input, .field > select { width: 100%; height: 36px; border: 1px solid #cdd7e6; border-radius: 8px; background: #fff; color: #23334f; font-size: 13px; padding: 0 10px; }
.field > select { padding-right: 28px; }
.field-with-icon > input, .field-with-icon > select { padding-left: 32px; }
.field input::placeholder { color: #65728a; }
.panel:has(.sp-select-menu:not([hidden])) { overflow: visible; }
.sp-select { position: relative; width: 100%; min-width: 0; }
.sp-select-trigger { width: 100%; min-width: 0; height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 9px; border: 1px solid #cdd7e6; border-radius: 8px; padding: 0 10px; background: #fff; color: #23334f; font-size: 13px; text-align: left; }
.sp-select-trigger:hover { border-color: #a7b5ce; background: #f9fbff; }
.sp-select-trigger[aria-expanded="true"] { border-color: #687cda; box-shadow: 0 0 0 2px #e3e9fd; }
.sp-select-trigger[aria-expanded="true"]:focus-visible { outline: 2px solid #687cda; outline-offset: 2px; }
.field-with-icon .sp-select-trigger { padding-left: 32px; }
.sp-select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-select-chevron { width: 7px; height: 7px; border-right: 1.5px solid #5c6e8e; border-bottom: 1.5px solid #5c6e8e; flex: none; transform: translateY(-2px) rotate(45deg); }
.sp-select-trigger[aria-expanded="true"] .sp-select-chevron { transform: translateY(2px) rotate(225deg); }
.sp-select-menu { position: absolute; z-index: 5; top: calc(100% + 7px); left: 0; min-width: max(100%, 146px); width: max-content; max-width: min(260px, 80vw); max-height: min(18rem, var(--sp-menu-height, 18rem)); overflow: auto; overscroll-behavior: contain; padding: 5px; background: #fff; border: 1px solid #d6dff0; border-radius: 11px; box-shadow: 0 12px 25px #15234824, 0 2px 7px #15234812; }
.sp-select.opens-up .sp-select-menu { top: auto; bottom: calc(100% + 7px); }
.merchant-filter .sp-select-menu, #event-filters > .field:last-child .sp-select-menu { left: auto; right: 0; }
.sp-select-option { display: flex; justify-content: space-between; align-items: center; gap: 13px; min-height: 34px; border-radius: 6px; padding: 6px 9px; color: #23334f; font-size: 14px; cursor: pointer; }
.sp-select-option-label { overflow-wrap: anywhere; }
.sp-select-option[aria-selected="true"] { font-weight: 690; color: #3349af; background: #edf1ff; }
.sp-select-option.is-active, .sp-select-option:hover { background: #f1f5ff; }
.sp-select-option.is-active { box-shadow: inset 0 0 0 1px #afbcf3; }
.sp-select-option[aria-selected="true"].is-active, .sp-select-option[aria-selected="true"]:hover { background: #e5ebff; }
.sp-select-option[aria-disabled="true"] { opacity: .55; cursor: default; }
.sp-select-check { width: 10px; height: 6px; flex: none; border: solid #3b4fc2; border-width: 0 0 2px 2px; visibility: hidden; transform: translateY(-1px) rotate(-45deg); }
.sp-select-option[aria-selected="true"] .sp-select-check { visibility: visible; }
.region-field .sp-select { min-width: 144px; }
.merchant-filter .sp-select { min-width: 120px; }
#event-filters .sp-select { min-width: 132px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 8px; font-size: 13px; font-weight: 680; white-space: nowrap; text-decoration: none; }
.button-secondary { background: #fff; border: 1px solid #cdd7e6; color: #2e3d57; }
.button-secondary:not(:disabled):hover { background: #edf1fb; border-color: #9ba9c6; }
.button-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.button-primary:not(:disabled):hover { background: #2d3eab; }
.button-ghost { min-height: 30px; padding: 0 9px; background: #fff; border: 1px solid #d7e0ee; color: #364768; font-size: 12px; }
.button-ghost:not(:disabled):hover { background: #eef2ff; border-color: #9faee8; color: #2a3b96; }
.button-compact { min-height: 30px; padding: 0 10px; font-size: 12px; }
.button-push[aria-pressed="true"] { background: #e8edff; border-color: #8f9ee7; color: #283a9e; }
.button-push[aria-pressed="true"]:not(:disabled):hover { background: #dce4ff; border-color: #6f82df; }
.button-danger-ghost { background: #fff; border: 1px solid #ecc6d0; color: #9e2040; }
.button-danger-ghost:not(:disabled):hover { background: #fff0f3; border-color: #d98fa2; }
.button:disabled { opacity: .56; }
.clear-filters { color: #4e5e78; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border: 1px solid #cdd7e6; border-radius: 8px; background: #fff; color: #2e3d57; font-size: 13px; font-weight: 640; white-space: nowrap; cursor: pointer; user-select: none; }
.filter-chip:hover { border-color: #9ba9c6; background: #f8faff; }
.filter-chip:has(input:checked) { background: #edf1ff; border-color: #9ba8e8; color: #2d3e9b; }
.filter-chip input { margin: 0; accent-color: var(--accent); }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.data-table th { background: #f5f7fc; color: #52617c; border-top: 1px solid #e7edf6; border-bottom: 1px solid #e7edf6; font-size: 12px; text-align: left; white-space: nowrap; padding: 9px 14px; font-weight: 690; }
.data-table th:first-child { padding-left: 19px; }
.data-table th:last-child { padding-right: 19px; }
.status-column { width: 128px; }
.time-column { width: 112px; }
.price-column { width: 134px; }
.action-column { width: 152px; text-align: right; }
.column-heading { display: inline-flex; align-items: center; gap: 5px; }
.column-heading .ui-icon { width: 14px; height: 14px; }
.data-table td { padding: 9px 14px; border-bottom: 1px solid #e8edf4; vertical-align: middle; overflow-wrap: anywhere; }
.data-table td:last-child { padding-right: 19px; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.inventory-table td { background: var(--row-wash, #fff); }
.inventory-table tr[data-stock]:hover td { background: var(--stock-card); }
.inventory-table td.status-cell { border-left: 3px solid var(--stock-line); padding-left: 16px; }
.history-table td:first-child { padding-left: 19px; }
.product-name { min-width: 125px; }
.product-name-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; }
.product-name a, .product-name span { color: #182541; font-weight: 720; }
.product-name a { text-decoration-color: #9da9e7; text-underline-offset: 3px; }
.product-name .override-tag { display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 5px; background: #e8edff; color: #3648a6; font-size: 11px; font-weight: 680; white-space: nowrap; }
.product-name .table-detail { color: var(--muted); font-weight: 400; }
.action-cell { text-align: right; white-space: nowrap; }
.action-group { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; }
.action-cell .ui-icon { width: 13px; height: 13px; }
.event-meta-line { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 3px; font-size: 12px; color: #3a4c7a; }
.table-detail { display: block; font-size: 12px; line-height: 1.4; margin-top: 2px; }
.merchant-cell { font-weight: 650; }
.merchant-cell .table-detail { font-weight: 400; }
.region-label { display: inline-block; width: fit-content; border: 1px solid #dce3ee; border-radius: 6px; padding: 2px 7px; background: #f2f5fa; color: #425474; font-size: 12px; white-space: nowrap; }
.price-cell { font-variant-numeric: tabular-nums; }
.plan-price { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 2px 5px; color: #253776; }
.plan-price strong { font-size: 14px; font-weight: 720; white-space: nowrap; }
.price-period, .price-unavailable { color: #52617a; font-size: 12px; white-space: nowrap; }
.spec-cell { color: #4f607a; font-size: 13px; }
.time-cell { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .empty-cell { padding: 25px 19px; color: var(--muted); text-align: center; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 11px 19px; gap: 8px; border-top: 1px solid #e7edf6; }
.pagination-status { color: var(--muted); font-size: 13px; }
.pagination-actions { display: flex; gap: 7px; }
.pagination-actions .button { min-height: 31px; }
.banner { margin: 11px 0; border-radius: 8px; padding: 8px 11px; font-size: 14px; color: #374765; background: #eef2fa; }
.banner.is-error { color: #8a2437; background: #fff0f3; }
.banner.is-good { color: #086044; background: #e6f7ee; }
.panel-banner, #settings-feedback { margin: 0 19px 13px; }

.settings-panel { max-width: 980px; }
.settings-grid { margin: 0; border: 0; padding: 0 19px; min-width: 0; }
.setting-field { padding: 17px 0; border-top: 1px solid #e5ebf5; }
.setting-field h3 { font-size: 15px; font-weight: 730; }
.switch-field, .merchant-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.setting-note { font-size: 13px; margin-top: 4px; }
.switch-label { display: inline-flex; align-items: center; cursor: pointer; }
.switch-label input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-control { width: 43px; height: 25px; border: 1px solid #919eb6; border-radius: 99px; background: #c7d1e3; position: relative; }
.switch-control::before { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #101b3455; }
.switch-label input:checked + .switch-control { background: #3b4fc2; border-color: #3b4fc2; }
.switch-label input:checked + .switch-control::before { left: 21px; }
.switch-label input:focus-visible + .switch-control { outline: 3px solid #7b8cf5; outline-offset: 3px; }
.merchant-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 11px; }
.merchant-option { display: flex; align-items: center; gap: 8px; min-width: 0; border: 1px solid #dce4ef; border-radius: 8px; padding: 8px 9px; overflow-wrap: anywhere; cursor: pointer; }
.merchant-option:has(input:checked) { background: #edf1ff; border-color: #a3afea; color: #33449e; }
.merchant-option input { margin: 0; accent-color: var(--accent); flex: none; }
.merchant-option-badge { margin-left: auto; padding: 1px 6px; border-radius: 99px; background: #dce3ff; color: #2b3c99; font-size: 11px; font-weight: 700; white-space: nowrap; }
.picker-heading-actions { display: flex; align-items: center; gap: 8px; }
.picker-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.picker-search { flex: 1 1 260px; width: auto; }
.merchant-accordion { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.merchant-group { border: 1px solid #dce4ef; border-radius: 10px; background: #fff; overflow: hidden; }
.merchant-group[open] { border-color: #bcc8ec; }
.merchant-group-summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 13px; background: #f8faff; cursor: pointer; user-select: none; }
.merchant-group-summary::-webkit-details-marker { display: none; }
.merchant-group-summary::before { content: ""; width: 7px; height: 7px; flex: none; border-right: 1.8px solid #52617a; border-bottom: 1.8px solid #52617a; transform: rotate(-45deg); margin-right: 2px; }
.merchant-group[open] > .merchant-group-summary::before { transform: rotate(45deg); }
@media (prefers-reduced-motion: no-preference) {
  .merchant-group-summary::before { transition: transform 150ms ease; }
}
.merchant-group-summary:hover { background: #f0f4ff; }
.merchant-group-name { font-size: 14px; font-weight: 720; color: var(--ink); }
.merchant-group-count { margin-left: auto; font-size: 12px; font-weight: 660; color: var(--muted); white-space: nowrap; }
.merchant-group-count.has-picked { color: #2e40a3; }
.merchant-group-body { padding: 10px 13px 13px; border-top: 1px solid #e6ecf5; }
.merchant-group-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.merchant-group-note { font-size: 12px; color: var(--muted); margin-left: auto; }
.product-pick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.product-pick-item { display: flex; align-items: flex-start; gap: 8px; min-width: 0; padding: 8px 10px; border: 1px solid #e0e7f2; border-radius: 8px; background: #fff; cursor: pointer; }
.product-pick-item:hover { border-color: #b7c4e8; background: #fafcff; }
.product-pick-item:has(input:checked) { background: #eef2ff; border-color: #9ba8e8; }
.product-pick-item input { margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.product-pick-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.product-pick-name { font-size: 13px; font-weight: 680; color: #182541; overflow-wrap: anywhere; line-height: 1.35; }
.product-pick-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; font-size: 11px; color: var(--muted); }
.product-pick-status { font-weight: 700; }
.product-pick-status.is-in { color: #086348; }
.product-pick-status.is-out { color: #a22645; }
.product-pick-status.is-preorder { color: #87520f; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 3px 19px 15px; }

/* Modal dialogs */
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: #101b347a; backdrop-filter: blur(2px); overflow: hidden; overscroll-behavior: contain; }
.modal-dialog { width: min(560px, calc(100vw - 24px)); max-height: min(90dvh, 820px); margin: auto; padding: 0; border: 1px solid #cfd9eb; border-radius: 16px; background: #fff; color: #16233d; box-shadow: 0 22px 48px #0f1a3638, 0 4px 14px #0f1a361a; }
.modal-dialog-wide { width: min(720px, calc(100vw - 24px)); }
.modal-dialog[open] { display: flex; flex-direction: column; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 17px 20px 14px; border-bottom: 1px solid #e6ecf5; }
.dialog-title { color: var(--ink); font-size: 19px; line-height: 1.3; font-weight: 750; }
.dialog-subtitle { margin-top: 4px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.dialog-close { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #52617a; }
.dialog-close:hover { background: #eef2fa; color: #16233d; }
.dialog-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.dialog-body { padding: 16px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.dialog-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; padding: 13px 20px 16px; border-top: 1px solid #e6ecf5; background: #f8faff; }
.dialog-footer-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.dialog-footer-note { font-size: 12px; }
.form-row { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.form-row > label, .label-row > label { color: #243352; font-size: 13px; font-weight: 680; }
.label-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; }
.form-row > input, .form-row > select, .form-row > textarea { width: 100%; border: 1px solid #c3cfe2; border-radius: 8px; background: #fff; color: #182541; font-size: 14px; padding: 8px 10px; }
.form-row > input, .form-row > select { min-height: 38px; }
.form-row > textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; resize: vertical; min-height: 168px; }
.form-row > input[aria-invalid="true"], .form-row > textarea[aria-invalid="true"], .form-row > input:user-invalid { border-color: #c83355; background: #fff8fa; }
.form-hint { color: var(--muted); font-size: 12px; line-height: 1.45; }
.form-hint code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; background: #eef2fa; padding: 1px 4px; border-radius: 4px; }
.form-fieldset { margin: 0; padding: 12px 13px; border: 1px solid #dce4f2; border-radius: 10px; background: #fafcff; display: flex; flex-direction: column; gap: 10px; }
.form-fieldset > legend { padding: 0 4px; color: #243352; font-size: 13px; font-weight: 700; }
.price-input-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
#edit-dialog { --edit-field-inset: 12px; --edit-field-font: 14px; --edit-field-height: 40px; }
#edit-dialog .form-row > input,
#edit-dialog .form-row > select,
#edit-dialog .sp-select-trigger { min-height: var(--edit-field-height); padding-inline-start: var(--edit-field-inset); font-size: var(--edit-field-font); }
#edit-dialog .form-row > input { padding-inline-end: var(--edit-field-inset); }
#edit-dialog .form-row > input::placeholder { color: #65728a; opacity: 1; }
#edit-dialog .sp-select-trigger { padding-inline-end: 14px; border-color: #c3cfe2; color: #182541; }
#edit-dialog .sp-select-trigger:hover { border-color: #a7b5ce; }
#edit-dialog .sp-select-trigger[aria-expanded="true"] { border-color: #687cda; }
#edit-dialog .sp-select-menu { width: 100%; min-width: 0; max-width: none; }
#edit-dialog .sp-select-menu:focus-visible { outline: 1px solid #afbcf3; outline-offset: 1px; }
#edit-dialog .sp-select-option { padding-inline-start: calc(var(--edit-field-inset) - 5px); }
#edit-dialog .form-hint { padding-inline: calc(var(--edit-field-inset) + 1px); }
.export-box { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 1px solid #dce4f2; border-radius: 10px; background: #f6f8fe; }
.export-box h2 { font-size: 14px; font-weight: 720; color: var(--ink); margin-bottom: 2px; }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.price-sync-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.price-sync-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 9px; border: 1px solid #dce4f0; border-radius: 8px; background: #fff; font-size: 12px; }
.price-sync-name { font-weight: 680; color: var(--ink); overflow-wrap: anywhere; }
.price-sync-badge { padding: 2px 6px; border-radius: 5px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.price-sync-badge.is-good { color: #086044; background: #e4f7ed; }
.price-sync-badge.is-info { color: #2e40a3; background: #e8edff; }
.price-sync-badge.is-warn { color: #865310; background: #fff1d6; }
.price-sync-badge.is-muted { color: #4c5c7a; background: #edf1f8; }
.file-picker { display: inline-flex; align-items: center; }
.file-picker-label { display: inline-flex; align-items: center; padding: 4px 9px; border: 1px solid #cdd7e6; border-radius: 7px; background: #fff; color: #2d3e8f; font-size: 12px; font-weight: 660; cursor: pointer; }
.file-picker-label:hover { background: #eef1ff; border-color: #9faee8; }
.file-picker input:focus-visible + .file-picker-label { outline: 3px solid #7b8cf5; outline-offset: 2px; }
.checkbox-inline, .radio-inline { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: #22314f; cursor: pointer; line-height: 1.45; }
.checkbox-inline input, .radio-inline input { margin-top: 3px; accent-color: var(--accent); flex: none; }
.radio-group { display: flex; flex-direction: column; gap: 7px; }

@media (max-width: 880px) {
  .main, .topbar-content { padding-left: 21px; padding-right: 21px; }
  .topbar-content { gap: 20px; }
  .data-table td, .data-table th { padding-left: 10px; padding-right: 10px; }
  .time-column { width: 103px; }
  .status-column { width: 105px; }
  .price-column { width: auto; }
  .inventory-heading { flex-wrap: wrap; }
  .inventory-filters { width: 100%; }
  .inventory-filters .field-search { flex: 1 1 175px; }
}

@media (max-width: 660px) {
  .topbar-content { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "brand actions" "nav nav"; gap: 0; padding: 10px 15px 0; min-height: auto; }
  .brand { grid-area: brand; }
  .brand-mark { width: 27px; height: 27px; }
  .brand-name { font-size: 18px; }
  .navigation { grid-area: nav; margin-top: 6px; margin-left: -5px; gap: 3px; }
  .navigation a { min-height: 38px; padding: 0 8px; gap: 5px; font-size: 13px; }
  .navigation .ui-icon { width: 14px; height: 14px; }
  .navigation a[aria-current="page"]::after { inset-inline: 7px; }
  .topbar-actions { grid-area: actions; gap: 4px; }
  .sign-out { padding-inline: 6px; }
  .main { padding: 16px 13px 35px; }
  .page-heading { margin-bottom: 12px; }
  .page-heading h1 { font-size: 26px; }
  #overview-stats { font-size: 13px; margin-top: 3px; }
  .health-grid { margin-bottom: 13px; border-radius: 10px; }
  .health-card { padding: 8px 7px 7px; }
  .health-heading { flex-wrap: wrap; gap: 2px 5px; }
  .health-heading h2 { font-size: 12px; }
  .health-title-full { display: none; }
  .health-title-short { display: inline; }
  .health-status { font-size: 11px; gap: 3px; padding: 3px 4px; }
  .health-status::before { width: 4px; height: 4px; }
  .health-time { font-size: 10px; }
  .stock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-bottom: 13px; }
  .stock-tile { min-height: 62px; grid-template-columns: 1fr auto; align-items: center; column-gap: 4px; border-radius: 11px; padding: 7px 10px; }
  .stock-tile strong { font-size: 25px; grid-column: 2; grid-row: 1 / 3; }
  .tile-label { font-size: 13px; gap: 5px; }
  .tile-note { font-size: 11px; }
  .stock-tile[aria-pressed="true"]::after { display: none; }
  .panel-heading { flex-wrap: wrap; padding: 11px; gap: 8px; }
  .panel-title { font-size: 17px; }
  .toolbar { width: 100%; }
  .field-search { flex: 1 1 120px; width: auto; }
  .field select { max-width: 25vw; padding-right: 6px; }
  .toolbar .button { padding: 0 7px; font-size: 12px; }
  .inventory-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr) auto; gap: 6px; }
  .inventory-filters .field-search { grid-column: 1 / -1; width: 100%; }
  .inventory-filters .field select { max-width: none; padding-right: 6px; }
  .inventory-filters .region-field select { padding-left: 27px; }
  .inventory-filters .field-icon { left: 8px; }
  .inventory-filters .region-field .sp-select-trigger { padding-left: 27px; }
  .inventory-filters .sp-select, #event-filters .sp-select { min-width: 0; }
  #event-filters > .field { flex: 1; }
  .sp-select-trigger { gap: 5px; padding-right: 9px; }
  .sp-select-option { min-height: 38px; }
  .clear-filters .ui-icon { width: 13px; height: 13px; }
  .data-table { display: block; border-top: 1px solid #e7edf6; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .data-table tbody { display: block; }
  .data-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 2px 8px; padding: 8px 11px; border-bottom: 1px solid #e8edf4; background: var(--row-wash, #fff); }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .inventory-table tr[data-stock] { border-left: 3px solid var(--stock-line); padding-left: 8px; }
  .data-table td, .data-table td:first-child, .data-table td:last-child, .data-table td.status-cell { padding: 0; border: 0; line-height: 1.3; }
  .inventory-table td.status-cell, .history-table td.status-cell { grid-area: 1 / 2; justify-self: end; }
  .data-table td.product-name { min-width: 0; grid-area: 1 / 1; align-self: center; }
  .data-table td.merchant-cell { grid-column: 1 / -1; }
  .data-table td.merchant-cell .table-detail { display: inline; margin: 0 0 0 6px; }
  .data-table td.spec-cell { grid-column: 1; }
  .data-table td.time-cell { grid-column: 2; justify-self: end; align-self: end; font-size: 11px; }
  .inventory-table td.merchant-cell { grid-area: 2 / 1; }
  .inventory-table td.region-cell { grid-area: 2 / 2; justify-self: end; }
  .inventory-table td.spec-cell { grid-area: 3 / 1; align-self: center; }
  .inventory-table td.price-cell { grid-area: 3 / 2; justify-self: end; }
  .inventory-table td.action-cell { grid-area: 4 / 1; justify-self: start; text-align: left; padding-top: 3px; }
  .inventory-table td.time-cell { grid-area: 4 / 2; }
  .page-actions { width: 100%; }
  .page-actions .button, .scope-switch { min-height: 36px; font-size: 12px; }
  .price-input-grid { grid-template-columns: 1fr; }
  #edit-dialog { --edit-field-font: 1rem; --edit-field-height: 44px; }
  .form-row > input, .form-row > select, .form-row > textarea { font-size: max(1rem, 1em); }
  .modal-dialog { width: calc(100vw - 16px); max-height: 92dvh; }
  .dialog-header, .dialog-body, .dialog-footer { padding-inline: 14px; }
  .region-label { font-size: 11px; padding: 2px 5px; }
  .plan-price { justify-content: flex-end; }
  .plan-price strong { font-size: 13px; }
  .data-table .badge { font-size: 12px; padding: 3px 6px; gap: 4px; }
  .data-table tr:has(.empty-cell) { display: block; }
  .data-table .empty-cell { padding: 14px 5px; }
  .pagination { padding: 8px 10px; }
  .pagination-status { font-size: 12px; }
  .pagination-actions .button { padding: 0 8px; }
  .merchant-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-pick-grid { grid-template-columns: 1fr; }
  .price-sync-list { grid-template-columns: 1fr; }
  .inventory-filters .filter-chip { grid-column: 1 / 3; justify-content: center; }
  .action-group { justify-content: flex-start; }
}

@media (max-width: 365px) {
  .field-search input { font-size: 12px; }
  .health-heading h2 { font-size: 11px; }
  .health-time { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .stock-tile { transition: none; }
}
