:root {
  --bg: #14110e;
  --bg-elev: #1e1914;
  --bg-soft: #2a231c;
  --ink: #f3ebe1;
  --muted: #b5a794;
  --line: rgba(243, 235, 225, 0.12);
  --accent: #e08a3c;
  --accent-2: #c45c26;
  --ok: #6fbf8a;
  --danger: #d96b5c;
  --user: #3d6b8a;
  --assistant: #8a5a2b;
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Outfit", system-ui, sans-serif;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(224, 138, 60, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(61, 107, 138, 0.16), transparent 55%),
    linear-gradient(180deg, #1a1511 0%, var(--bg) 40%, #0f0d0b 100%);
  background-attachment: fixed;
}

.bg-glow {
  position: fixed;
  inset: auto -10% -20% auto;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(224, 138, 60, 0.08), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.topbar, main { position: relative; z-index: 1; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  background: rgba(20, 17, 14, 0.7);
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.85rem;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #1a1008;
  box-shadow: 0 8px 24px rgba(224, 138, 60, 0.35);
}

.brand-text { display: flex; flex-direction: column; gap: 0.1rem; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand-text small { color: var(--muted); font-size: 0.8rem; }

.nav { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.nav-btn, .mode-btn, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.nav-btn:hover, .mode-btn:hover, .btn:hover:not(:disabled) {
  border-color: rgba(224, 138, 60, 0.5);
  background: rgba(224, 138, 60, 0.08);
}
.nav-btn.is-active, .mode-btn.is-active {
  background: rgba(224, 138, 60, 0.16);
  border-color: rgba(224, 138, 60, 0.55);
}
.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
}
.nav-link:hover { color: var(--ink); }

main { padding: 1.25rem 1.5rem 2.5rem; max-width: 1400px; margin: 0 auto; }

.view { display: none; animation: fadeIn 0.35s ease; }
.view.is-visible { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.order-layout, .history-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(240px, 0.9fr) minmax(320px, 1.3fr) minmax(220px, 0.85fr);
  min-height: calc(100vh - 7rem);
}

.history-layout {
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.4fr);
}

.menu-panel, .agent-panel, .ticket-panel,
.history-list-panel, .history-detail-panel {
  background: rgba(30, 25, 20, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head { padding: 1.1rem 1.2rem 0.6rem; }
.panel-head.compact { padding-bottom: 0.35rem; }
.panel-head h1, .panel-head h2, .history-empty h2, .detail-card h3 {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
  font-weight: 700;
}
.panel-head h1 { font-size: 1.6rem; }
.panel-head p, .muted, .history-empty p { color: var(--muted); margin: 0; line-height: 1.45; }

.menu-list {
  overflow: auto;
  padding: 0.4rem 0.85rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.menu-cat h3 {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.menu-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  color: inherit;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font: inherit;
  margin-bottom: 0.35rem;
}
.menu-item:hover {
  border-color: rgba(224, 138, 60, 0.4);
  background: rgba(224, 138, 60, 0.08);
  transform: translateY(-1px);
}
.menu-item .name { font-weight: 600; }
.menu-item .ar { color: var(--muted); font-size: 0.85rem; grid-column: 1 / -1; }
.menu-item .langs {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.menu-item .price-block {
  text-align: right;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.85rem;
  line-height: 1.35;
}
.menu-lang-toggle {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0 1.1rem 0.6rem;
}
.menu-lang-toggle button {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.menu-lang-toggle button.is-active {
  color: var(--ink);
  border-color: rgba(224, 138, 60, 0.55);
  background: rgba(224, 138, 60, 0.14);
}

.agent-panel { padding: 1rem; }
.mode-toggle { display: flex; gap: 0.4rem; margin-bottom: 1rem; }

.pane { display: none; flex: 1; min-height: 0; flex-direction: column; gap: 1rem; }
.pane.is-visible { display: flex; }

.voice-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 1rem;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(224, 138, 60, 0.08), transparent 60%),
    var(--bg-soft);
  border: 1px solid var(--line);
  min-height: 240px;
}

.voice-orb {
  width: 120px;
  height: 120px;
  position: relative;
  display: grid;
  place-items: center;
}
.orb-core {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 0 rgba(224, 138, 60, 0.4);
  transition: transform 0.2s;
}
.orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(224, 138, 60, 0.35);
}
.voice-orb[data-state="listening"] .orb-core {
  animation: pulse 1.4s ease-in-out infinite;
}
.voice-orb[data-state="speaking"] .orb-ring {
  animation: spinRing 2.4s linear infinite;
  border-color: rgba(111, 191, 138, 0.55);
}
.voice-orb[data-state="speaking"] .orb-core {
  background: linear-gradient(145deg, #6fbf8a, #3d8a5c);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(224, 138, 60, 0.45); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 18px rgba(224, 138, 60, 0); }
}
@keyframes spinRing {
  to { transform: rotate(360deg); }
}

.voice-status { color: var(--muted); text-align: center; max-width: 28rem; }
.voice-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }

.btn.primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #1a1008;
  font-weight: 600;
}
.btn.danger {
  background: rgba(217, 107, 92, 0.15);
  border-color: rgba(217, 107, 92, 0.45);
  color: #f0c2bb;
}
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.transcript-box, .chat-log, .transcript-scroll {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.transcript-box { display: flex; flex-direction: column; flex: 1; min-height: 180px; overflow: hidden; }
.transcript-scroll {
  overflow: auto;
  padding: 0.85rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
  border: none;
  background: transparent;
}
.transcript-scroll.tall {
  min-height: 280px;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
}

.bubble {
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  line-height: 1.4;
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.bubble.user {
  align-self: flex-end;
  background: rgba(61, 107, 138, 0.35);
  border: 1px solid rgba(61, 107, 138, 0.45);
}
.bubble.assistant {
  align-self: flex-start;
  background: rgba(138, 90, 43, 0.28);
  border: 1px solid rgba(224, 138, 60, 0.28);
}
.bubble .who {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.chat-log {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 360px;
}
.chat-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
}
.chat-form input {
  font: inherit;
  color: var(--ink);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  outline: none;
}
.chat-form input:focus { border-color: rgba(224, 138, 60, 0.55); }

.ticket-panel { padding-bottom: 1rem; }
.ticket-items {
  list-style: none;
  margin: 0;
  padding: 0.4rem 1.1rem 0.8rem;
  overflow: auto;
  flex: 1;
}
.ticket-items li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.92rem;
}
.ticket-items .empty { color: var(--muted); border: none; display: block; }
.ticket-meta {
  margin: 0;
  padding: 0 1.1rem;
  display: grid;
  gap: 0.55rem;
}
.ticket-meta > div {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.ticket-meta dt { color: var(--muted); }
.ticket-meta dd { margin: 0; }

.history-list {
  overflow: auto;
  padding: 0.5rem 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.history-item {
  text-align: left;
  font: inherit;
  color: inherit;
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  cursor: pointer;
}
.history-item:hover, .history-item.is-active {
  border-color: rgba(224, 138, 60, 0.4);
  background: rgba(224, 138, 60, 0.08);
}
.history-item strong { display: block; margin-bottom: 0.2rem; }
.history-item span { color: var(--muted); font-size: 0.82rem; }

.history-detail-panel { padding: 1.1rem; }
.history-empty {
  height: 100%;
  min-height: 320px;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 0.4rem;
}
.history-detail.hidden, .hidden { display: none !important; }
.detail-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
  margin: 1rem 0;
}
.detail-card {
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}
.detail-audio { width: 100%; margin-top: 0.5rem; }

@media (max-width: 1100px) {
  .order-layout, .history-layout, .detail-grid {
    grid-template-columns: 1fr;
  }
  .menu-panel { max-height: 320px; }
  .chat-form { grid-template-columns: 1fr; }
}
