:root {
  color-scheme: light;
  --ink: #102a38;
  --muted: #5f7480;
  --navy: #0b3045;
  --navy-2: #12485f;
  --cyan: #21b9b5;
  --cyan-soft: #dff7f4;
  --blue: #2f7fb3;
  --coral: #e97855;
  --line: #d9e4e8;
  --surface: #ffffff;
  --bg: #eef4f6;
  --shadow: 0 10px 30px rgba(10, 48, 69, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(33, 185, 181, 0.12), transparent 28rem),
    var(--bg);
  font-size: 16px;
  line-height: 1.45;
}

button, input, select, summary { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem clamp(1.25rem, 4vw, 4rem);
  color: #fff;
  background: linear-gradient(120deg, var(--navy), var(--navy-2));
  border-bottom: 5px solid var(--cyan);
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: #8fe6df;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.8rem, 3vw, 2.65rem); letter-spacing: -0.04em; }
h2 { margin-bottom: 0.3rem; font-size: 1.15rem; }

.cutoff { text-align: right; color: #c8e4eb; }
.cutoff span { display: block; font-size: 0.82rem; }
.cutoff strong { display: block; color: #fff; font-size: 1.12rem; }

main { width: min(1600px, 100%); margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 3rem) 4rem; }

.filters, .panel, .kpi {
  background: var(--surface);
  border: 1px solid rgba(16, 42, 56, 0.08);
  box-shadow: var(--shadow);
}

.filters { padding: 1.2rem; border-radius: 18px; }
.filter-heading, .workspace-heading, .panel-heading, .dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.filter-heading p, .workspace-heading p, .dialog-header p { margin-bottom: 0; color: var(--muted); }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(135px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

label { color: var(--muted); font-size: 0.86rem; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 42px;
  margin-top: 0.35rem;
  padding: 0.55rem 0.7rem;
  color: var(--ink);
  background: #f8fbfc;
  border: 1px solid var(--line);
  border-radius: 10px;
}
input:focus, select:focus { outline: 3px solid rgba(33, 185, 181, 0.18); border-color: var(--cyan); }
.search-label { grid-column: span 2; }

.filter-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.55rem; }
.primary-button {
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-weight: 800;
}
.primary-button:hover { background: var(--navy-2); }
.primary-button:disabled { opacity: 0.5; cursor: default; }
.filter-control { min-width: 0; color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.filter-label { display: block; }
.filter-control small { display: block; margin-top: 0.3rem; color: var(--muted); font-size: 0.72rem; font-weight: 600; line-height: 1.3; }
.multi-select { position: relative; margin-top: 0.35rem; }
.multi-select summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  color: var(--ink);
  background: #f8fbfc;
  border: 1px solid var(--line);
  border-radius: 10px;
  list-style: none;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.multi-select summary::-webkit-details-marker { display: none; }
.multi-select summary::after { content: "▾"; flex: 0 0 auto; color: var(--muted); }
.multi-select[open] summary { outline: 3px solid rgba(33, 185, 181, 0.18); border-color: var(--cyan); }
.multi-select[open] summary::after { content: "▴"; }
.multi-select-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.4rem);
  left: 0;
  width: min(340px, calc(100vw - 2rem));
  padding: 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 42px rgba(10, 48, 69, 0.2);
}
.multi-search-label { display: block; }
.multi-search-label input { margin-bottom: 0.65rem; }
.multi-options { max-height: 250px; overflow-y: auto; display: grid; gap: 0.25rem; padding-right: 0.2rem; }
.multi-option {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.45rem 0.5rem;
  color: var(--ink);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.multi-option:hover { background: var(--cyan-soft); }
.multi-option input { width: 17px; min-height: 17px; margin: 0.08rem 0 0; padding: 0; flex: 0 0 auto; accent-color: var(--cyan); }
.multi-option[hidden] { display: none; }
.multi-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; margin-top: 0.65rem; }
.multi-apply, .multi-clear { width: 100%; padding-inline: 0.55rem; font-size: 0.82rem; }
.export-status { min-height: 1.1rem; margin: 0.7rem 0 0; color: #08746f; font-size: 0.78rem; font-weight: 750; }
.export-status.error { color: #a14c14; }

.secondary-button, .icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-weight: 800;
}
.secondary-button:hover { border-color: var(--cyan); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.kpi { position: relative; overflow: hidden; padding: 1rem 1.1rem; border-radius: 16px; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: #7f98a3; }
.kpi.accent-cyan::before { background: var(--cyan); }
.kpi.accent-blue::before { background: var(--blue); }
.kpi.accent-coral::before { background: var(--coral); }
.kpi span { display: block; color: var(--muted); font-size: 0.86rem; font-weight: 800; }
.kpi strong { display: block; margin-top: 0.3rem; font-size: clamp(1.4rem, 2.5vw, 2rem); letter-spacing: -0.04em; }

.price-query { margin-bottom: 1rem; }
.price-query-heading, .price-card-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.price-query-heading p { margin-bottom: 0; color: var(--muted); }
.section-kicker { color: #08746f !important; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.12em; }
.price-date-label { flex: 0 0 min(220px, 100%); }
.price-summary { margin: 1rem 0 0.75rem; color: var(--navy); font-size: 0.88rem; font-weight: 850; }
.price-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.price-card { padding: 0.9rem; border: 1px solid var(--line); border-radius: 14px; background: #f9fcfc; }
.price-card-heading strong, .price-card-heading span { display: block; }
.price-card-heading span { margin-top: 0.2rem; color: var(--muted); font-size: 0.8rem; }
.price-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.75rem; }
.price-chip { padding: 0.38rem 0.58rem; color: #075e5a; background: var(--cyan-soft); border: 1px solid #a8ded9; border-radius: 999px; font-size: 0.82rem; font-weight: 900; }
.price-warning { margin: 0.65rem 0 0; padding: 0.55rem 0.65rem; color: #7b4218; background: #fff3df; border-radius: 9px; font-size: 0.78rem; font-weight: 750; }
.price-unavailable { color: var(--muted); font-size: 0.82rem; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.panel { border-radius: 18px; padding: 1.15rem; }
.panel-heading span { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.bar-list { display: grid; gap: 0.65rem; margin-top: 1rem; }
.bar-row { display: grid; grid-template-columns: minmax(95px, 0.7fr) 2fr minmax(105px, auto); gap: 0.65rem; align-items: center; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.86rem; font-weight: 750; }
.bar-track { height: 11px; overflow: hidden; background: #e8f0f2; border-radius: 999px; }
.bar-fill { height: 100%; min-width: 3px; background: linear-gradient(90deg, var(--blue), var(--cyan)); border-radius: inherit; }
.bar-value { text-align: right; color: var(--navy); font-size: 0.82rem; font-weight: 850; }
.empty { padding: 1rem; color: var(--muted); text-align: center; background: #f7fafb; border-radius: 12px; }

.workspace { margin-top: 1rem; padding: 0; overflow: hidden; }
.workspace-heading { padding: 1.2rem 1.2rem 0.8rem; }
.result-count { color: var(--navy); background: var(--cyan-soft); padding: 0.35rem 0.6rem; border-radius: 999px; font-size: 0.82rem; font-weight: 850; }
.tabs { display: flex; gap: 0.35rem; overflow-x: auto; padding: 0 1.2rem 0.8rem; border-bottom: 1px solid var(--line); }
.tab { flex: 0 0 auto; padding: 0.55rem 0.75rem; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 0.88rem; font-weight: 800; }
.tab.active { color: #fff; background: var(--navy); }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { position: sticky; top: 0; z-index: 1; padding: 0.75rem; color: #d8edf2; background: var(--navy); text-align: left; white-space: nowrap; }
td { padding: 0.7rem 0.75rem; border-bottom: 1px solid #e8eff1; vertical-align: top; }
tbody tr:nth-child(even) { background: #f8fbfc; }
tbody tr:hover { background: #eaf8f6; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.filter-total-row > * { padding: 0.65rem 0.75rem; color: var(--navy); background: var(--cyan-soft); font-weight: 850; }
.filter-total-row > th { position: static; }
.detail-button { padding: 0.35rem 0.55rem; border: 1px solid #9ed8d4; border-radius: 8px; color: #075e5a; background: #e8fbf9; font-size: 0.8rem; font-weight: 850; }
.source { color: var(--muted); font-size: 0.78rem; }

.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 0.7rem; padding: 0.85rem 1.2rem 1.2rem; }
.pagination button { padding: 0.45rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 750; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

dialog { width: min(1120px, calc(100% - 2rem)); max-height: 90vh; padding: 0; border: 0; border-radius: 20px; box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28); }
dialog::backdrop { background: rgba(4, 24, 34, 0.65); backdrop-filter: blur(3px); }
.dialog-header { padding: 1.2rem 1.3rem; color: #fff; background: var(--navy); }
.dialog-header h2 { font-size: 1.45rem; }
.dialog-header p { color: #c8e4eb; }
.icon-button { width: 42px; height: 42px; padding: 0; color: #fff; background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); font-size: 1.6rem; }
.dialog-totals { display: flex; flex-wrap: wrap; gap: 0.7rem; padding: 1rem 1.3rem; background: var(--cyan-soft); }
.dialog-totals span { padding: 0.45rem 0.65rem; background: #fff; border-radius: 9px; font-weight: 800; }
.dialog-totals strong { color: var(--navy); }
.dialog-price-list { padding: 0.9rem 1.3rem; border-bottom: 1px solid var(--line); background: #f8fbfc; }
.dialog-price-list > strong { display: block; color: var(--navy); font-size: 0.9rem; }
.data-warning { background: #fff7e8 !important; }
.missing-value { color: #a14c14; font-size: 0.72rem; font-weight: 900; }

.error-state { margin: 2rem; padding: 1rem; color: #7b271a; background: #ffe8df; border: 1px solid #f2b7a4; border-radius: 12px; }

@media (max-width: 1050px) {
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .topbar { align-items: flex-start; padding: 1.2rem; }
  .cutoff { text-align: left; }
  main { padding: 1rem 0.75rem 3rem; }
  .filter-heading, .workspace-heading, .topbar { flex-direction: column; }
  .filter-actions { width: 100%; justify-content: flex-start; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-label { grid-column: span 2; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
  .price-results { grid-template-columns: 1fr; }
  .price-query-heading, .price-card-heading { flex-direction: column; }
  .price-date-label { flex-basis: auto; width: 100%; }
  .bar-row { grid-template-columns: minmax(80px, 0.7fr) 1.6fr minmax(85px, auto); }
}

@media (max-width: 440px) {
  .filter-grid { grid-template-columns: 1fr; }
  .search-label { grid-column: auto; }
  .kpi-grid { grid-template-columns: 1fr; }
}
