:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #18202f;
  --muted: #647084;
  --line: #dbe2ea;
  --primary: #0b63ce;
  --primary-dark: #084fa6;
  --soft: #eef4ff;
  --ok: #16a34a;
  --warn: #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.sub {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.actions {
  display: grid;
  grid-template-columns: minmax(150px, 0.55fr) repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 12px;
}

.filters {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
}

.filters details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filters summary {
  padding: 12px 14px;
  color: #334155;
  font-weight: 800;
  cursor: pointer;
}

.filter-tools {
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr) auto;
  gap: 8px;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--line);
}

.filter-tools button {
  min-height: 36px;
  padding: 0 12px;
  background: var(--soft);
  color: var(--primary-dark);
  border: 1px solid #c9dcff;
  font-weight: 700;
}

.filter-tools label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filter-tools input {
  min-height: 36px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  padding: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.chip input {
  margin: 0;
  accent-color: var(--primary);
}

.chip:has(input:checked) {
  border-color: #9fc1ff;
  background: var(--soft);
  color: var(--primary-dark);
}

.hours-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.hours-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hours-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.primary,
.secondary,
.copy {
  min-height: 46px;
  padding: 0 18px;
  font-weight: 700;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  background: var(--soft);
  color: var(--primary-dark);
  border: 1px solid #c9dcff;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.statusbar > div {
  display: flex;
  align-items: center;
  min-width: 0;
  color: var(--muted);
}

.dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.dot.loading {
  background: transparent;
  border: 2px solid #d8e4f5;
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

.dot.ready {
  background: var(--ok);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.copy {
  background: #111827;
  color: #fff;
  white-space: nowrap;
}

.viewer {
  margin-top: 12px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary {
  display: none;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.5;
}

.summary:not(:empty) {
  display: block;
}

pre {
  min-height: 420px;
  max-height: 70vh;
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: #111827;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.table-wrap {
  overflow: auto;
  max-height: 70vh;
}

table {
  width: 100%;
  min-width: 1320px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbff;
  color: #334155;
  font-weight: 800;
  white-space: nowrap;
}

td {
  color: #1f2937;
}

td:nth-child(17) {
  min-width: 280px;
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding: 18px 0;
  }

  h1 {
    font-size: 24px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .statusbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-tools label {
    grid-column: 1 / -1;
  }

  .filter-tools button[data-filter-add] {
    grid-column: 1 / -1;
  }

  .chips {
    max-height: 240px;
  }

  .copy {
    width: 100%;
  }

  pre {
    min-height: 55vh;
    font-size: 12px;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
    font-size: 13px;
  }

  thead {
    display: none;
  }

  tr {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
  }

  td {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
    padding: 6px 0;
    border-bottom: 0;
    word-break: break-word;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }

  td:nth-child(17) {
    min-width: 0;
  }
}
