:root {
  --highlight: #89ba17;
  --bg: #1a1a1a;
  --surface: #242424;
  --surface2: #2e2e2e;
  --border: #3a3a3a;
  --text: #e8e8e8;
  --text-muted: #888;
  --danger: #c0392b;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 340px;
  box-shadow: var(--shadow);
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--highlight);
  margin: 0 0 24px;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-error {
  background: rgba(192,57,43,0.15);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: #e74c3c;
  font-size: 13px;
}

/* ── App shell ──────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--highlight);
  letter-spacing: 0.04em;
}

.app-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* ── Sections ───────────────────────────────────────────────────────────── */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-header .section-title { margin: 0; }

/* ── Form controls ──────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--highlight); }
.input-disabled { opacity: 0.45; cursor: not-allowed; }
.input-sm { padding: 5px 8px; font-size: 13px; }

.select {
  appearance: none;
  background: var(--surface2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 7px 32px 7px 10px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.select:focus { border-color: var(--highlight); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--highlight);
  color: #1a1a1a;
  border-color: var(--highlight);
}
.btn-primary:hover { background: var(--highlight); border-color: var(--highlight); }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--highlight); color: var(--highlight); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: rgba(192,57,43,0.15); }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-icon { width: 30px; padding: 4px; font-size: 15px; flex-shrink: 0; }

/* ── Source section ─────────────────────────────────────────────────────── */
.source-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Tags ───────────────────────────────────────────────────────────────── */
.tag-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.tag-add-row .input { flex: 1; }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 20px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--highlight);
  color: #1a1a1a;
  border-radius: 20px;
  padding: 3px 10px 3px 12px;
  font-size: 13px;
  font-weight: 500;
}
.tag-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.tag-remove:hover { opacity: 1; }

/* ── Table cards ────────────────────────────────────────────────────────── */
.table-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-weight: 600;
  font-size: 15px;
}
.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.overlay-url {
  font-size: 12px;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 8px;
}

.team-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field + .field,
.field + form,
form + .field { margin-top: 12px; }

.field { display: flex; flex-direction: column; }
.field label { margin-bottom: 4px; }

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.field-tag { min-width: 140px; flex: 1; }

/* ── Tom Select ─────────────────────────────────────────────────────────── */
/* Hide native select before JS initialises Tom Select to prevent flicker. */
select[data-ts] { display: none; }
.ts-wrapper .ts-control {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  min-height: 38px;
  padding: 3px 8px;
  box-shadow: none;
  cursor: text;
  gap: 4px;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--highlight);
  box-shadow: none;
}
.ts-wrapper .ts-control input {
  color: var(--text);
  background: transparent;
  line-height: 1.5;
  font-size: 14px;
  font-family: var(--font);
}
.ts-wrapper .ts-control input::placeholder {
  color: var(--text-muted);
}
/* Chips */
.ts-wrapper.multi .ts-control > .item {
  background: var(--highlight);
  color: #1a1a1a;
  border: none;
  border-radius: 20px;
  padding: 2px 6px 2px 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  cursor: grab;
}
.ts-wrapper.multi .ts-control > .item.active {
  background: var(--highlight);
  color: #1a1a1a;
}
.ts-wrapper.multi .ts-control > .item .remove {
  color: inherit;
  opacity: 0.65;
  margin-left: 4px;
  padding: 0 2px;
  border-left: none;
}
.ts-wrapper.multi .ts-control > .item .remove:hover {
  opacity: 1;
  background: transparent;
  color: inherit;
}
/* Dropdown */
.ts-dropdown {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 100;
}
.ts-dropdown .ts-dropdown-content {
  padding: 4px 0;
}
.ts-dropdown .option {
  color: var(--text);
  padding: 6px 10px;
  font-size: 14px;
}
.ts-dropdown .option:hover,
.ts-dropdown .option.active {
  background: var(--surface);
  color: var(--text);
}
.ts-dropdown .option.selected {
  color: var(--highlight);
}
.ts-dropdown .create {
  color: var(--highlight);
  padding: 6px 10px;
  font-size: 14px;
}
.ts-dropdown .create:hover,
.ts-dropdown .create.active {
  background: var(--surface);
}
.ts-dropdown .no-results {
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 13px;
}

.display-tags-field {
  margin-bottom: 14px;
}

/* ── HTMX indicator ─────────────────────────────────────────────────────── */
.htmx-request .btn { opacity: 0.6; }

/* ── Logo ───────────────────────────────────────────────────────────────────── */
.logo-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.logo-img {
  max-height: 80px;
  max-width: 200px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  padding: 4px;
  flex-shrink: 0;
}
.logo-actions {
  display: flex;
  flex-direction: row;
  gap: 6px;
}

/* ── Kickertool section ───────────────────────────────────────────────────── */
.input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.input-row .input,
.input-row .select { flex: 1; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  accent-color: var(--highlight);
  cursor: pointer;
}
.hint-error {
  color: var(--danger);
}

/* ── Collapsible section headers ──────────────────────────────────────────── */
.section > details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.section > details > summary::-webkit-details-marker { display: none; }
.section > details > summary .section-title { margin: 0; flex: 1; }
.section > details > summary .fold-chevron {
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.section > details:not([open]) > summary .fold-chevron {
  transform: rotate(180deg);
}
.section > details > summary + * { margin-top: 14px; }
/* Remove bottom margin from summary itself when collapsed */
.section > details:not([open]) > summary { margin-bottom: 0; }
