:root {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #d8e1ec;
  --line-strong: #b9c7d8;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --accent: #334155;
  --danger: #b42318;
  --warn: #a15c07;
  --ok: #16794c;
  --shadow: 0 16px 40px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f8fbfd 0%, var(--bg) 42%, #e8eff6 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.shell.is-locked {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
}

p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.55;
}

.hero-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: min(420px, 45%);
}

.status-pill,
.count-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid #b8d9d4;
  border-radius: 999px;
  padding: 7px 11px;
  background: #eef8f6;
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.status-pill.muted,
.count-badge {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  padding: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.shell > .panel {
  margin-top: 14px;
}

.primary-panel {
  min-height: 100%;
}

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

textarea,
input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  color: var(--text);
}

textarea {
  min-height: 136px;
  resize: vertical;
  padding: 12px;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

input[type="password"] {
  height: 42px;
  padding: 0 12px;
}

textarea:focus,
input[type="password"]:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(15, 118, 110, 0.14);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

button {
  min-height: 38px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 8px 13px;
  background: var(--primary);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

button:hover {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.ghost,
.panel-title button {
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
}

button.ghost:hover,
.panel-title button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

button.ghost.danger {
  border-color: #f0c9c4;
  color: var(--danger);
}

button.ghost.danger:hover {
  border-color: #e8aaa2;
  background: #fff7f6;
}

.queue {
  display: grid;
  gap: 10px;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: var(--surface-soft);
}

.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.item-main {
  min-width: 0;
}

.item-title {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.item-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.success {
  background: #e9f8f0;
  color: var(--ok);
}

.badge.error {
  background: #fff0ee;
  color: var(--danger);
}

.badge.pending,
.badge.exchanging,
.badge.phone_wait {
  background: #fff8e8;
  color: var(--warn);
}

.badge.skipped {
  background: #edf2f7;
  color: var(--muted);
}

.item.phone_wait {
  border-color: #efc36b;
  background: #fffbf0;
}

.item.skipped {
  opacity: 0.78;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.item-actions button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.log-panel {
  margin-bottom: 24px;
}

.log {
  min-height: 150px;
  max-height: 300px;
  overflow: auto;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px;
  background: #111827;
  color: #dbeafe;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.log-line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(6px);
}

.auth-gate.is-hidden {
  display: none;
}

.auth-box {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 22px;
  box-shadow: var(--shadow);
}

.auth-box input {
  margin-top: 16px;
}

.auth-box button {
  width: 100%;
  margin-top: 12px;
}

noscript {
  display: block;
  max-width: 720px;
  margin: 24px auto;
  padding: 12px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: #fff;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 20px, 720px);
    margin-top: 10px;
  }

  .hero,
  .grid,
  .item {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero {
    padding: 20px;
  }

  .hero-meta {
    align-items: flex-start;
    min-width: 0;
  }

  h1 {
    font-size: 27px;
  }

  .item-actions {
    justify-content: flex-start;
  }
}
