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

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --link: #60a5fa;
  --radius: 8px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", monospace;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

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

header p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

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

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.field {
  margin-bottom: 0.6rem;
}

.field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.field input,
.field output {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-size: 0.875rem;
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.field output {
  display: block;
  min-height: 2rem;
}

.field output.empty {
  color: var(--text-muted);
}

.field a.maps-link {
  color: var(--link);
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

button,
.file-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-family: var(--font);
  font-weight: 500;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

button:disabled,
.file-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-danger {
  background: #7f1d1d;
  color: #fecaca;
  border: 1px solid #991b1b;
}

.btn-danger:hover:not(:disabled) {
  background: #991b1b;
}

.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.file-btn {
  display: inline-block;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.file-btn input {
  display: none;
}

.status-bar {
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  min-height: 2.5rem;
}

.status-bar.busy {
  border-color: var(--accent);
}

.status-bar.error {
  border-color: var(--danger);
  color: #fca5a5;
}

.progress-bar {
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.progress-bar.hidden {
  display: none;
}

.log-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  max-height: 120px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: 420px;
}

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

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
  font-family: var(--mono);
  font-size: 0.75rem;
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.08);
}

tbody tr.selected {
  background: rgba(59, 130, 246, 0.15);
}

td a {
  color: var(--link);
}

.divider {
  margin: 0.75rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

.utm-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.utm-toggle label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.hidden {
  display: none;
}

.utm-fields.hidden {
  display: none;
}
