:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --border: #2d3a4f;
  --error: #f87171;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.header {
  padding: 1.5rem 1.5rem 0;
}

.export-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}

.export-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.export-btn:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.section-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.ref-intro {
  margin: 0 0 1rem;
  max-width: 52rem;
  line-height: 1.45;
}

.table-ref {
  max-width: 36rem;
  font-size: 0.88rem;
}

.table-ref th,
.table-ref td {
  white-space: normal;
}

.table-ref td:last-child {
  font-weight: 600;
  color: var(--accent);
}

.small {
  font-size: 0.85rem;
  margin: 0.5rem 0 0.25rem;
}

.muted {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
}

code {
  background: var(--panel);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.88em;
}

.main {
  padding: 1rem 1.5rem 2rem;
  max-width: 1200px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.panel-team-presets {
  padding-bottom: 0.85rem;
}

.team-presets-hint {
  margin: 0 0 0.5rem;
  max-width: 42rem;
}

.team-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-top: 0.35rem;
}

.team-select-wrap {
  flex: 1;
  min-width: min(100%, 14rem);
}

.team-preset-actions {
  align-items: flex-end;
}

.team-presets-status {
  margin: 0.5rem 0 0;
  min-height: 1.25rem;
}

.panel-story {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}

.story-details {
  margin: 0;
}

.story-summary {
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
  list-style: none;
  padding: 0.35rem 0;
}

.story-summary::-webkit-details-marker {
  display: none;
}

.story-summary::before {
  content: "▸ ";
  color: var(--muted);
  display: inline-block;
  transition: transform 0.12s ease;
}

.story-details[open] .story-summary::before {
  transform: rotate(90deg);
}

.story-details .ref-intro {
  margin-top: 0.75rem;
}

.overflow {
  overflow-x: auto;
}

.label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

textarea,
input[type="date"],
select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
}

select {
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
  margin-top: 1rem;
}

.row-single {
  grid-template-columns: 1fr;
  margin-top: 0.75rem;
}

@media (max-width: 720px) {
  .row {
    grid-template-columns: 1fr;
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font: inherit;
  cursor: pointer;
}

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

.btn.primary:hover {
  filter: brightness(1.08);
}

.status {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.status.error {
  color: var(--error);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.5rem;
  text-align: left;
  white-space: nowrap;
}

.table tfoot th,
.table tfoot td {
  border-top: 2px solid var(--border);
  border-bottom: none;
  font-weight: 600;
  color: var(--text);
}

.table .var-over {
  color: #fbbf24;
}

.table .var-under {
  color: #86efac;
}

.table .var-ok {
  color: var(--muted);
  font-weight: 500;
}

.table .var-na {
  color: var(--muted);
}

.table th {
  color: var(--muted);
  font-weight: 500;
}

.table th.th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.table th.th-sortable:hover {
  color: var(--text);
}

.table th.th-sortable[aria-sort="ascending"]::after,
.table th.th-sortable[aria-sort="descending"]::after {
  margin-left: 0.35em;
  font-size: 0.65em;
  color: var(--accent);
  vertical-align: middle;
}

.table th.th-sortable[aria-sort="ascending"]::after {
  content: "▲";
}

.table th.th-sortable[aria-sort="descending"]::after {
  content: "▼";
}

.table td a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.table td a:hover {
  text-decoration: underline;
}

.error-cell {
  color: var(--error);
}

details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.pre {
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  overflow: auto;
  font-size: 0.8rem;
  color: var(--muted);
}
