:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --ink: #111827;
  --muted: #64748b;
  --line: #d9e2ef;
  --brand: #0f172a;
  --accent: #2563eb;
  --success: #15803d;
  --danger: #b91c1c;
  --warning: #b45309;
  --radius: 8px;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  min-height: 44px;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
}

.eyebrow,
.topbar h1 {
  margin: 0;
}

.eyebrow {
  font-size: 0.76rem;
  color: #cbd5e1;
}

.topbar h1 {
  margin-top: 2px;
  font-size: 1.18rem;
  line-height: 1.1;
}

.status-stack {
  display: grid;
  gap: 6px;
  justify-items: end;
  flex: 0 0 auto;
}

.route-pill,
.net-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.net-pill {
  background: rgba(34, 197, 94, 0.18);
}

.net-pill.offline {
  background: rgba(245, 158, 11, 0.2);
}

.layout {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 14px;
  display: grid;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls-panel {
  padding: 14px;
}

.results-panel {
  min-width: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.results-panel .panel-title {
  padding: 14px 14px 0;
}

.panel-title h2 {
  margin: 0;
  font-size: 1.05rem;
}

.panel-title span {
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--accent);
  font-size: 1.35rem;
  line-height: 1;
}

.form-grid,
.email-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  outline: 0;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.primary-button,
.secondary-button,
.success-button {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 800;
  color: #fff;
}

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

.secondary-button {
  background: #334155;
}

.success-button {
  background: var(--success);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.summary-grid div {
  min-width: 0;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 1.08rem;
  white-space: nowrap;
}

.actions-grid,
.email-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.email-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.table-scroller {
  width: 100%;
  max-height: calc(100vh - 250px);
  min-height: 320px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1f2937;
  color: #fff;
  font-size: 0.78rem;
  white-space: nowrap;
}

td {
  background: #fff;
}

tr:nth-child(even) td {
  background: #f9fbfd;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.map-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: #fff;
  background: #0ea5e9;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.muted,
.empty-cell {
  color: var(--muted);
}

.empty-cell {
  height: 180px;
  text-align: center;
  background: #fff;
}

.loader {
  position: fixed;
  inset: auto 14px calc(env(safe-area-inset-bottom) + 14px);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  border-radius: var(--radius);
  color: #fff;
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.28);
  font-weight: 800;
}

.loader[hidden] {
  display: none;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.85s linear infinite;
}

.toast-container {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 12px;
  right: 12px;
  z-index: 50;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  justify-self: center;
  width: min(520px, 100%);
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: #334155;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.24);
  font-weight: 700;
  transform: translateY(-12px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

.toast.warning {
  background: var(--warning);
}

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

@media (min-width: 760px) {
  .topbar {
    padding-left: 24px;
    padding-right: 24px;
  }

  .layout {
    padding: 20px;
    grid-template-columns: 340px minmax(0, 1fr);
    align-items: start;
  }

  .controls-panel {
    position: sticky;
    top: 92px;
  }

  .topbar h1 {
    font-size: 1.4rem;
  }
}
