:root {
  --primary: #fc4c02;
  --primary-hover: #f76d32;
  --surface: #f8f5f0;
  --ink: #000000;
  --secondary: #31312f;
  --muted: rgba(49, 49, 47, .68);
  --line: #e5e5e5;
  --card-ring: rgb(236, 220, 211) 0 0 0 1px inset;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
}

body {
  margin: 0;
  background: #ffffff;
  color: var(--ink);
  font-family: Poppins, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page {
  width: min(1280px, calc(100vw - 48px));
  margin: 0 auto;
}

.snap-panel {
  min-height: 100vh;
  padding: 36px 0 64px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.query-panel {
  display: grid;
  align-content: center;
}

.results {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
}

.hero {
  margin-bottom: 24px;
  padding: 44px 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, #000000 0%, #31312f 100%);
  color: #ffffff;
}

.kicker {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  max-width: 860px;
  font-size: clamp(48px, 6vw, 76px);
  line-height: 1.12;
  font-weight: 600;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.12;
  font-weight: 600;
}

h3 {
  margin-bottom: 4px;
  font-size: 24px;
  line-height: 1.2;
}

.hero-copy {
  max-width: 760px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, .78);
  font-size: 18px;
  line-height: 1.5;
}

.query-card,
.filter-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--card-ring);
}

.query-top,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.section-head {
  align-items: flex-end;
  margin-bottom: 0;
}

.query-top p,
.filter-title p {
  margin-bottom: 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span,
.checkbox span {
  color: var(--secondary);
  font-size: 14px;
  font-weight: 500;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 8px 14px;
}

textarea {
  min-height: 160px;
  padding: 14px 16px;
  resize: vertical;
}

select[multiple] {
  min-height: 132px;
  border-radius: 14px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(252, 76, 2, .12);
}

.button-primary,
.button-secondary,
.button-ghost {
  min-height: 42px;
  padding: 8px 20px;
  border-radius: 100px;
  cursor: pointer;
  transition: background-color .2s ease-in, transform .1s ease-in;
  white-space: nowrap;
}

.button-primary {
  border: 0;
  background: var(--primary);
  color: #ffffff;
}

.button-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.button-secondary {
  border: 0;
  background: #000000;
  color: #ffffff;
}

.button-secondary:hover {
  background: var(--secondary);
  transform: translateY(-1px);
}

.button-ghost {
  border: 1px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
}

.button-ghost:hover {
  background: var(--surface);
  transform: translateY(-1px);
}

.button-primary:disabled,
.button-secondary:disabled,
.button-ghost:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.query-footer,
.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.result-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.query-meta,
.result-meta {
  color: var(--muted);
  font-size: 14px;
}

.status,
.missing {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--secondary);
}

.status.error {
  background: #fff0e7;
  color: #9a2500;
}

.filter-card {
  margin-bottom: 18px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.time-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 16px;
  align-items: end;
}

.checkbox {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
}

.checkbox input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.compact {
  margin-bottom: 0;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 230px);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--card-ring);
  scroll-snap-align: none;
}

table {
  width: 100%;
  min-width: 1680px;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 14px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #000000;
  color: #ffffff;
  font-weight: 600;
  white-space: nowrap;
}

tbody tr.group-even {
  background: #fff0e7;
}

tbody tr.group-start td {
  border-top: 2px solid var(--primary);
}

tbody tr:hover {
  background: #ffe1d3;
}

tbody tr {
  user-select: none;
}

td:first-child,
th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
}

td:first-child {
  background: #ffffff;
  font-weight: 600;
  box-shadow: 1px 0 0 var(--line);
}

tbody tr.group-even td:first-child {
  background: #fff0e7;
}

tbody tr:hover td:first-child {
  background: #ffe1d3;
}

th:first-child {
  z-index: 5;
  background: #000000;
  box-shadow: 1px 0 0 rgba(255, 255, 255, .18);
}

td {
  cursor: cell;
}

td.selected-cell,
td.selected-cell:hover {
  background: #ffd9c7;
  box-shadow: inset 0 0 0 2px var(--primary);
}

td:first-child.selected-cell,
tbody tr.group-even td:first-child.selected-cell,
tbody tr:hover td:first-child.selected-cell {
  background: #ffd9c7;
}

td.active-cell {
  box-shadow: inset 0 0 0 3px #000000;
}

td.selected-cell.active-cell {
  box-shadow: inset 0 0 0 2px var(--primary), inset 0 0 0 4px #000000;
}

.filter-button {
  margin-left: 8px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 100px;
  background: rgba(255, 255, 255, .08);
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
}

.filter-button:hover,
.filter-button.active {
  border-color: var(--primary);
  background: var(--primary);
}

.filter-popover {
  position: fixed;
  z-index: 30;
  width: min(320px, calc(100vw - 28px));
  max-height: 480px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .18);
}

.filter-popover-head,
.filter-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.popover-close,
.filter-tools button,
.filter-option button {
  border: 0;
  border-radius: 100px;
  background: var(--surface);
  color: var(--secondary);
  cursor: pointer;
}

.popover-close {
  width: 28px;
  height: 28px;
  font-size: 18px;
}

.filter-search {
  margin: 12px 0;
  border-radius: 100px;
}

.filter-tools {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.filter-tools button {
  padding: 5px 10px;
}

.filter-option-list {
  display: grid;
  gap: 4px;
  max-height: 310px;
  overflow: auto;
  padding-right: 4px;
}

.filter-option {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--secondary);
  font-size: 13px;
}

.filter-option:hover {
  background: var(--surface);
}

.filter-option input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.filter-option button {
  padding: 3px 8px;
  font-size: 11px;
}

.copy-toast {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 20;
  padding: 10px 16px;
  border-radius: 100px;
  background: #000000;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .15s ease-in, transform .15s ease-in;
  pointer-events: none;
}

.copy-toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 780px) {
  .page {
    width: min(100vw - 28px, 1280px);
  }

  .hero,
  .query-card,
  .filter-card {
    padding: 22px;
  }

  .query-top,
  .section-head,
  .query-footer,
  .result-actions,
  .filter-grid,
  .time-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: calc(100vh - 300px);
  }
}
