:root {
  --ink: #0b1220;
  --indigo: #4c62f7;
  --indigo-deep: #3b46e0;
  --mint: #10ba99;
  --paper: #f3f6fb;
  --card: #ffffff;
  --line: #e3e8f2;
  --muted: #5b6785;
  --danger: #b3261e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Manrope", system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 800;
  letter-spacing: -.03em;
  font-size: 18px;
}
.brand span { color: var(--indigo); }

.status {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef1f7;
  color: var(--muted);
}
.status-on { background: #dcf7ef; color: #0a7a64; }
.status-text { background: #fff3d6; color: #8a5a00; }
.status-off { background: #ffe3e3; color: var(--danger); }

.hidden { display: none !important; }

.tenantbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.tenantbar strong { color: var(--ink); }
.link {
  border: 0;
  background: transparent;
  color: var(--indigo);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
}

.picker {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 28px 18px 36px;
}
.picker.hidden { display: none; }
.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--indigo);
}
.picker h1 {
  margin: 0;
  font-size: clamp(26px, 7vw, 38px);
  letter-spacing: -.04em;
  line-height: 1.05;
}
.picker-copy {
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
.tenant-list {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}
.tenant-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--card);
  box-shadow: 0 10px 26px rgba(11, 18, 32, .06);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.tenant-card:hover,
.tenant-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(76, 98, 247, .45);
  box-shadow: 0 16px 34px rgba(76, 98, 247, .14);
}
.tenant-card strong { font-size: 18px; letter-spacing: -.02em; }
.tenant-card span { font-size: 13px; line-height: 1.4; color: var(--muted); }
.tenant-card em {
  margin-top: 4px;
  font-style: normal;
  font-size: 13px;
  font-weight: 800;
  color: var(--indigo);
}

.chat {
  flex: 1;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message { display: flex; }
.message.bot { justify-content: flex-start; }
.message.user { justify-content: flex-end; }
.message.system { justify-content: center; }

.bubble {
  max-width: min(84%, 560px);
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.bot .bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  box-shadow: 0 6px 18px rgba(11, 18, 32, .05);
}
.user .bubble {
  background: linear-gradient(135deg, var(--indigo), var(--indigo-deep));
  color: #fff;
  border-bottom-right-radius: 5px;
}
.system .bubble {
  background: #eef1f7;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
}

.order {
  margin: 0 16px 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(11, 18, 32, .07);
}
.order.hidden { display: none; }
.order .customer {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}
.order h2 {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: -.01em;
}
.order ul { list-style: none; margin: 0; padding: 0; }
.order li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.order li:last-child { border-bottom: 0; }
.order .detail {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}
.order .total {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-weight: 800;
}
.order .state {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.order .state.ok { color: #0a7a64; font-weight: 700; }
.order .state.fail { color: var(--danger); font-weight: 700; }

.consent {
  margin: 0 16px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(11, 18, 32, .07);
}
.consent.hidden { display: none; }
.consent h2 { margin: 0 0 6px; font-size: 15px; }
.consent p {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.consent a { color: var(--indigo); }
.consent-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.consent-actions button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--indigo);
  cursor: pointer;
}
.consent-actions .ghost {
  background: #eef1f7;
  color: var(--ink);
}

.composer {
  position: sticky;
  bottom: 0;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(243, 246, 251, .6), var(--paper) 30%);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.talk {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 16px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--indigo), var(--indigo-deep));
  box-shadow: 0 12px 26px rgba(76, 98, 247, .35);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .2s ease;
}
.talk:active { transform: scale(.99); }
.talk[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.talk.recording {
  background: linear-gradient(135deg, #e0574f, #b3261e);
  box-shadow: 0 12px 26px rgba(179, 38, 30, .3);
}
.talk-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: currentColor;
  opacity: .9;
}
.talk.recording .talk-dot {
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: .5; }
}

.hint {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.text-form {
  display: flex;
  gap: 8px;
}
.text-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
.text-form input:focus {
  outline: 2px solid rgba(76, 98, 247, .35);
  border-color: var(--indigo);
}
.text-form button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--ink);
  cursor: pointer;
}
.text-form button:hover { background: #172036; }

.reset {
  align-self: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 8px;
}

@media (min-width: 720px) {
  body { max-width: 720px; margin: 0 auto; }
  .topbar { border-radius: 0 0 16px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
  .talk.recording .talk-dot { animation: none; }
}
