:root {
  color-scheme: light;
  --bg: #f6f5f0;
  --card: #ffffff;
  --ink: #17202a;
  --muted: #66717d;
  --line: #d9dee2;
  --teal: #14786f;
  --teal-bg: #e3f4ef;
  --red: #b83945;
  --red-bg: #fde4e6;
  --amber: #946200;
  --amber-bg: #fff0c9;
  --green: #2f7746;
  --green-bg: #e5f4e8;
  --blue: #2c609c;
  --blue-bg: #e6f0fb;
  --shadow: 0 10px 24px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 14px 28px;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 14px;
}

.kicker {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p,
dd {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.06;
}

.runtime-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  white-space: nowrap;
}

.data-source-label {
  padding-left: 8px;
  border-left: 1px solid var(--line);
  color: var(--muted);
}

.data-source-label.live {
  color: var(--green);
}

.data-source-label.error-fallback {
  color: var(--amber);
}

.priority-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.priority-strip div {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.priority-strip strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1;
}

.priority-strip span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 850;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 0 -14px 12px;
  padding: 0 14px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: #3b4651;
  font-size: 0.77rem;
  font-weight: 900;
}

.tab.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.queue-list {
  display: grid;
  gap: 12px;
}

.queue-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.queue-card.waiting-human {
  border-color: #e8a8af;
  box-shadow: 0 10px 24px rgba(184, 57, 69, 0.12);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.identity {
  min-width: 0;
}

.phone {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.customer-name {
  margin: 3px 0 0;
  font-size: 1.12rem;
  line-height: 1.18;
}

.status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.status,
.stage-badge {
  display: inline-flex;
  align-items: center;
  max-width: 180px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--teal-bg);
  color: var(--teal);
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
}

.stage-badge {
  background: var(--blue-bg);
  color: var(--blue);
}

.status.waiting,
.stage-badge.waiting {
  background: var(--red-bg);
  color: var(--red);
}

.status.booked {
  background: var(--green-bg);
  color: var(--green);
}

.status.followup,
.stage-badge.review {
  background: var(--amber-bg);
  color: var(--amber);
}

.stage-badge.unknown {
  background: #eef0f2;
  color: var(--muted);
}

.card-fields {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.card-fields div {
  min-width: 0;
}

dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

dd {
  margin: 0;
  color: #26313b;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.card-fields > div:not(.inline-fields) {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfa;
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.inline-fields > div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfa;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.quick-action {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

.quick-action.active {
  border-color: var(--teal);
  background: var(--teal-bg);
  color: var(--teal);
}

.quick-action.warning {
  border-color: #efc1c6;
  color: var(--red);
}

.quick-action.takeover {
  border-color: #efc1c6;
}

.quick-action:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.action-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 780;
  text-align: center;
}

.empty-state,
.load-error {
  padding: 20px 14px;
  border: 1px dashed #aeb7bf;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.5;
  text-align: center;
}

@media (min-width: 620px) {
  .app {
    padding: 24px 18px 36px;
  }

  .quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
