:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --line: #d7dedb;
  --text: #17201c;
  --muted: #65736f;
  --accent: #0f766e;
  --accent-2: #1f6feb;
  --danger: #b42318;
  --ok: #137333;
  --shadow: 0 12px 32px rgba(27, 38, 35, 0.11);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 18px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

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

.status {
  min-height: 22px;
  margin: 0;
}

.status.error {
  color: var(--danger);
}

.status.ok {
  color: var(--ok);
}

.hidden {
  display: none !important;
}

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

.login-panel {
  width: min(460px, 100%);
  margin: 60px auto;
  padding: 22px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(420px, 1fr) minmax(290px, 380px);
  gap: 14px;
  align-items: start;
}

.search-panel,
.form-panel,
.history-panel {
  padding: 16px;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 74px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 13px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 700;
}

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

.btn.ghost {
  background: #fff;
}

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

.results,
.history,
.contact-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.result,
.history-item,
.contact {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.contact.replacement-active {
  border-color: rgba(14, 165, 233, 0.45);
  background: #f8fcff;
}

.replacement-line {
  margin-top: 4px;
  color: #0369a1;
  font-size: 12px;
  font-weight: 700;
}

.call-contact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.call-contact-header h2 {
  font-size: 16px;
}

.contact-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  background: #fff;
}

.contact-phone,
.contact-email {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.result {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.result.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.11);
}

.primary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-weight: 800;
}

.secondary-line {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.selected {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

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

.stopped-alert {
  margin-top: 10px;
  color: var(--danger);
  font-size: 15px;
  font-weight: 900;
}

.stopped-reason {
  margin-top: 5px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

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

.wide {
  grid-column: 1 / -1;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e6f4f1;
  color: #0b5f59;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.danger {
  background: #fee4e2;
  color: var(--danger);
}

.qr {
  width: 220px;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 320px 1fr;
  }

  .history-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 760px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
