:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-accent: #1f2937;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #f59e0b;
  --primary-dark: #d97706;
  --danger: #ef4444;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Fira Sans", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1e293b, #0f172a 55%);
  color: var(--text);
  color-scheme: dark;
}

html,
body,
* {
  scrollbar-width: thin;
  scrollbar-color: #475569 #0f172a;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
*::-webkit-scrollbar-track {
  background: #0f172a;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 999px;
  border: 2px solid #0f172a;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 32px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  flex-direction: column;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}

.brand-icon {
  width: auto;
  height: 1.15em;
  object-fit: contain;
  border-radius: 8px;
  flex: 0 0 auto;
}

.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.4px;
}

.status-pill.ok {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.6);
}

.status-pill.bad {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.6);
}

.nav {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.nav-btn {
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: transparent;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.container {
  padding: 32px;
}

.view {
  animation: fadeIn 0.35s ease;
}

.hidden {
  display: none;
}

h1 {
  margin: 0 0 16px;
  font-size: 28px;
  text-align: center;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.form-panel {
  max-width: 680px;
  margin: 0 auto;
}

.actions-panel {
  display: flex;
  align-items: stretch;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

.file-label {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.file-label input[type="file"] {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 12px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.table th {
  text-align: left;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1px;
}

label {
  display: block;
  margin-bottom: 16px;
  color: var(--muted);
  text-align: left;
}

input,
textarea,
select {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: var(--panel-accent);
  color: var(--text);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(245, 158, 11, 0.75);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

input::placeholder,
textarea::placeholder {
  color: rgba(148, 163, 184, 0.85);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(248, 250, 252, 0.82) 50%),
    linear-gradient(135deg, rgba(248, 250, 252, 0.82) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

select option,
select optgroup {
  background: #111827;
  color: #f8fafc;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

button.primary {
  background: var(--primary);
  border: none;
  color: #1f2937;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

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

.secondary,
.action-button {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text);
  padding: 0 16px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  width: 160px;
  line-height: 1;
  text-align: center;
  font-size: 14px;
}

button.secondary {
  appearance: none;
}

.file-label {
  height: 40px;
  line-height: 1;
}

.import-export-hint {
  margin-top: 8px;
  text-align: right;
}

button.small {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-right: 6px;
}

button.small.danger {
  border-color: var(--danger);
  color: var(--danger);
}

button.small.ghost {
  border-color: transparent;
  color: var(--muted);
}

.chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(148, 163, 184, 0.4);
  transition: 0.2s;
  border-radius: 999px;
}

.slider::before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background-color: #0f172a;
  transition: 0.2s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: var(--primary);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.form-hint {
  margin-top: 12px;
  color: var(--primary);
}

.stats {
  margin-top: 16px;
  font-weight: 600;
  color: var(--muted);
}

.logs {
  display: grid;
  gap: 16px;
}

.log-entry {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.6);
}

.log-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
}

.log-title {
  font-weight: 600;
}

.log-body {
  font-size: 15px;
  margin-bottom: 8px;
}

.log-details {
  font-size: 13px;
  color: var(--muted);
}

.log-toggle {
  margin-top: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.85);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.log-toggle:hover {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(30, 41, 59, 0.95);
}

.log-recipient-details.hidden {
  display: none;
}

.log-successes,
.log-failures {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.log-successes-title,
.log-failures-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.log-successes-title {
  color: #86efac;
}

.log-failures-title {
  color: #fca5a5;
}

.log-success-item,
.log-failure-item {
  padding: 8px 10px;
  border-radius: 10px;
}

.log-success-item {
  background: rgba(20, 83, 45, 0.18);
  border: 1px solid rgba(74, 222, 128, 0.18);
}

.log-failure-item {
  background: rgba(127, 29, 29, 0.18);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.log-success-item + .log-success-item,
.log-failure-item + .log-failure-item {
  margin-top: 8px;
}

.log-success-recipient,
.log-failure-recipient {
  font-size: 13px;
  font-weight: 600;
}

.log-success-recipient {
  color: #dcfce7;
}

.log-failure-recipient {
  color: #fecaca;
}

.log-success-recipient span,
.log-failure-recipient span {
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}

.log-success-status {
  margin-top: 4px;
  font-size: 13px;
  color: #bbf7d0;
  text-transform: capitalize;
}

.log-failure-reason {
  margin-top: 4px;
  font-size: 13px;
  color: #fee2e2;
  white-space: pre-wrap;
  word-break: break-word;
}

.version-pill {
  position: fixed;
  left: 16px;
  bottom: 16px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.5px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .container {
    padding: 20px;
  }

  .nav {
    flex-wrap: wrap;
  }

  .panel {
    padding: 18px;
    border-radius: 16px;
  }

  .actions-panel,
  .form-actions {
    flex-direction: column;
  }

  .secondary,
  .action-button,
  button.primary,
  .file-label {
    width: 100%;
    max-width: 100%;
  }

  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .log-header {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }
}

/* test-environment banner (env-agnostic; shows only on *-test hosts) */
body.test-banner-active {
  padding-top: 48px;
}

.test-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #8a1f2d;
  color: #fff;
  text-align: center;
  font: 800 13px/1.2 Arial, Helvetica, sans-serif;
  letter-spacing: .12em;
  padding: 12px 16px;
  box-shadow: 0 10px 24px #0004;
}

body.test-banner-active .test-banner {
  display: flex;
}

