:root {
  --ink: #192537;
  --muted: #657487;
  --line: #e1e8ef;
  --panel: #fff;
  --bg: #f4f7fa;
  --nav: #14283d;
  --accent: #2869d8;
  --good: #147a54;
  --good-bg: #e7f5ee;
  --warn: #9b6100;
  --warn-bg: #fff3db;
  --bad: #af2f28;
  --bad-bg: #fdebea;
  --neutral: #536477;
  --neutral-bg: #eef2f6;
  --promo: #7053b6;
  --promo-bg: #f0ebff;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, "Segoe UI", Arial, sans-serif; }
button, input, select { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, .nav-link:focus-visible { outline: 3px solid #8bb6ff; outline-offset: 2px; }

.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; padding: 28px 16px; background: var(--nav); color: #e5eef7; }
.brand { margin-bottom: 20px; padding: 0 12px 25px; border-bottom: 1px solid #2d455d; }
.brand span { display: block; font-size: 20px; font-weight: 800; letter-spacing: .06em; }
.brand small, .local-only { color: #a8b9cb; font-size: 12px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: #bdcddd; text-align: left; cursor: pointer; }
.nav-link:hover, .nav-link.active { background: #213d5b; color: #fff; }
.local-only { margin-top: auto; padding: 12px; }

.main-content { width: 100%; min-width: 0; max-width: 1500px; margin: 0 auto; padding: 28px 42px; }
header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
h1 { margin: 0; font-size: 30px; letter-spacing: -.03em; }
h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
header > p { margin: 5px 0; color: var(--muted); font-size: 13px; }
.operational-week { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 13px; color: var(--ink); }
.operational-week strong { padding: 6px 2px; font-size: 13px; }
.operational-week button { padding: 6px 9px; font-size: 12px; }
.week-date-picker { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.week-date-picker input { padding: 5px 7px; font-size: 12px; }
.view { display: none; }
.view.active { display: block; }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 13px; }
.card, .panel { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 2px 9px #16283b08; }
.metric { min-height: 108px; padding: 15px 17px; }
.metric p { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.metric strong { display: block; margin-top: 8px; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.panel { min-width: 0; margin-top: 20px; padding: 20px; }
.panel h2 { margin-bottom: 14px; }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.full-width { grid-column: 1 / -1; }
.fallback-note { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.strategy-details { margin-bottom: 18px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.comparison-section { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.comparison-section h3 { margin: 0 0 12px; font-size: 16px; }
.comparison-preview { margin-top: 14px; color: var(--muted); font-size: 13px; }
.comparison-preview b { display: block; color: var(--ink); margin-bottom: 7px; }
.comparison-preview ul { margin: 0; padding-left: 20px; }
.comparison-rule-list { display: grid; gap: 7px; max-height: 270px; overflow: auto; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; }
.comparison-rule { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink); font-size: 13px; }
.comparison-rule span { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.comparison-rule input[type="number"] { width: 72px; padding: 5px 7px; }
.comparison-group-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 13px; }
.comparison-group-card { display: grid; gap: 12px; }
.comparison-group-card h2 { margin: 0; font-size: 17px; }
.comparison-group-card p { margin: 4px 0 0; }
.compact-field { min-width: 220px; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 14px; }
.filter-tabs .selected { background: #1c3955; color: #fff; }
.comparison-members { display: flex; flex-wrap: wrap; gap: 6px; min-height: 22px; }
.toolbar, .actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.field { display: grid; min-width: 185px; gap: 5px; }
.field label { color: var(--muted); font-size: 12px; font-weight: 700; }
input, select { border: 1px solid #cbd6e1; border-radius: 8px; background: #fff; color: var(--ink); padding: 9px 10px; }
button, .button { border: 0; border-radius: 8px; background: var(--accent); color: #fff; padding: 9px 13px; font-weight: 700; cursor: pointer; }
button.secondary, .button.secondary { background: #e8eef5; color: #1c3955; }
.compact-action { margin-left: 6px; padding: 3px 7px; border-radius: 6px; font-size: 11px; }
button.danger { background: var(--bad); }
button:disabled { cursor: not-allowed; opacity: .55; }

.table-wrap { max-width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f8fafc; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-align: left; text-transform: uppercase; }
th, td { padding: 9px 11px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f5f8fc; }
.primary-cell { min-width: 205px; }
.primary-cell b { display: block; color: var(--ink); font-size: 13px; }
.primary-cell small, td small { color: var(--muted); font-size: 11px; }
.meta-cell { color: var(--muted); font-size: 12px; }
.provider-items-table { table-layout: fixed; }
.provider-items-table th:nth-child(1), .provider-items-table .selection-cell { width: 42px; }
.provider-items-table th:nth-child(2) { width: 13%; }
.provider-items-table th:nth-child(3) { width: 27%; }
.provider-items-table th:nth-child(4) { width: 16%; }
.provider-items-table th:nth-child(5) { width: 21%; }
.provider-items-table th:nth-child(6) { width: 23%; }
.provider-cell b, .provider-item-cell b, .comparable-name { display: block; color: var(--ink); }
.provider-item-cell b { font-size: 14px; }
.provider-item-cell small, .pack-cell small { display: block; margin-top: 3px; }
.provider-item-cell .price-meta { margin-top: 6px; color: var(--muted); font-size: 11px; }
.pack-cell strong { display: block; color: var(--ink); font-size: 14px; }
.comparable-cell .badge { margin-bottom: 5px; }
.comparison-actions { min-width: 210px; }

.badge { display: inline-flex; align-items: center; min-height: 21px; padding: 2px 8px; border-radius: 999px; background: var(--neutral-bg); color: var(--neutral); font-size: 11px; font-weight: 750; line-height: 1.2; white-space: nowrap; }
.badge-success { background: var(--good-bg); color: var(--good); }
.badge-review { background: var(--warn-bg); color: var(--warn); }
.badge-probable { background: var(--neutral-bg); color: var(--neutral); }
.badge-error { background: var(--bad-bg); color: var(--bad); }
.master-product-image { display: block; width: 72px; height: 72px; margin-top: 6px; object-fit: contain; border-radius: 8px; background: var(--neutral-bg); }
.badge-promo { background: var(--promo-bg); color: var(--promo); }
.badge-test { background: #edf0f3; color: #647182; }
.validity { gap: 5px; }
.validity .symbol { font-size: 14px; font-weight: 900; }

.drop-zone { margin: 18px 0; padding: 36px; border: 2px dashed #b7c9db; border-radius: 12px; background: #f8fbff; text-align: center; }
.drop-zone.drag { border-color: var(--accent); background: #edf4ff; }
.drop-zone strong { display: block; font-size: 17px; }
.hint, .muted { color: var(--muted); font-size: 13px; }
.process-status { display: none; margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: #eef5ff; color: #24509a; }
.process-status.show { display: block; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.summary .card { padding: 15px; }
.summary strong { display: block; margin: 3px 0; font-size: 27px; }
.summary .ready { border-top: 3px solid var(--good); }
.summary .review { border-top: 3px solid var(--warn); }
.summary .reject { border-top: 3px solid var(--bad); }
.review-card { margin: 12px 0; padding: 17px; }
.review-card h3 { margin: 0; font-size: 17px; }
.detail-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 14px; margin: 13px 0; }
.detail-list div { font-size: 13px; }
.detail-list b { display: block; color: var(--muted); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; }
.empty { padding: 35px; color: var(--muted); text-align: center; }
#flash { min-height: 0; }
#flash:not(:empty) { margin-bottom: 18px; padding: 10px 13px; border-radius: 8px; background: #e9f2ff; color: #174a91; }

dialog { width: min(960px, calc(100vw - 64px)); max-height: 84vh; margin: auto; padding: 0; overflow: hidden; border: 0; border-radius: 14px; box-shadow: 0 18px 60px #18253655; color: var(--ink); }
dialog::backdrop { background: #10243c66; }
.modal-shell { display: flex; max-height: 84vh; flex-direction: column; background: var(--panel); }
.modal-header { position: sticky; top: 0; z-index: 3; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 19px 22px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.modal-header h2 { margin: 0 0 3px; font-size: 20px; }
.modal-subtitle { margin: 0; color: var(--muted); font-size: 12px; }
.modal-close { width: 34px; height: 34px; flex: 0 0 34px; padding: 0; border: 1px solid #d7e0ea; background: #f7f9fb; color: var(--ink); font-size: 21px; line-height: 1; }
.modal-content { overflow: auto; padding: 16px 22px 20px; }
.modal-summary { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.modal-summary strong { color: var(--ink); }
.modal-table-wrap { max-height: min(53vh, 540px); overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.modal-table-wrap table { min-width: 720px; }
.modal-table-wrap th { position: sticky; top: 0; z-index: 1; box-shadow: 0 1px 0 var(--line); }
.modal-table-wrap th, .modal-table-wrap td { padding: 7px 10px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.price-dual { display: grid; gap: 4px; min-width: 122px; }
.price-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; }
.price-line .badge { font-size: 10px; }
.price-line-meta { display: block; color: var(--muted); font-size: 10px; font-weight: 500; }
.week-state { display: grid; gap: 4px; min-width: 145px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 3; padding: 16px; }
  .brand { margin: 0; padding: 0 0 10px; border: 0; }
  .sidebar nav { display: flex; overflow: auto; }
  .nav-link { white-space: nowrap; }
  .local-only { display: none; }
  .main-content { padding: 24px 16px; }
  header { gap: 12px; }
  #header-date { display: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .detail-list { grid-template-columns: repeat(2, 1fr); }
  dialog { width: calc(100vw - 24px); max-height: 88vh; }
  .modal-shell { max-height: 88vh; }
  .comparable-table-wrap { overflow: visible; }
  .provider-items-table, .provider-items-table tbody, .provider-items-table tr, .provider-items-table td { display: block; width: 100%; }
  .provider-items-table { table-layout: auto; }
  .provider-items-table thead { display: none; }
  .provider-items-table tr { padding: 13px 0; border-bottom: 1px solid var(--line); }
  .provider-items-table tbody tr:last-child { border-bottom: 0; }
  .provider-items-table td { display: grid; grid-template-columns: minmax(118px, 34%) minmax(0, 1fr); gap: 8px; padding: 6px 0; border: 0; }
  .provider-items-table td::before { content: attr(data-label); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
  .provider-items-table .selection-cell { display: flex; align-items: center; gap: 8px; }
  .provider-items-table .selection-cell::before { content: attr(data-label); }
  .provider-items-table .provider-item-cell b, .provider-items-table .provider-item-cell small, .provider-items-table .pack-cell strong, .provider-items-table .pack-cell small, .provider-items-table .comparable-cell > *, .provider-items-table .comparison-actions > * { grid-column: 2; }
  .provider-items-table .provider-item-cell b { margin-top: -2px; }
  .provider-items-table .comparison-actions .inline-actions { grid-column: 2; }
}
