:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-2: #0c1730;
  --panel: rgba(12, 22, 42, 0.84);
  --panel-strong: rgba(14, 28, 55, 0.94);
  --line: rgba(132, 168, 255, 0.18);
  --text: #eaf0ff;
  --muted: #91a5cf;
  --accent: #65d6ff;
  --accent-2: #8b5cf6;
  --good: #34d399;
  --danger: #fb7185;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(79, 122, 255, 0.18), transparent 28%),
    radial-gradient(circle at right, rgba(101, 214, 255, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea { font: inherit; }

.shell {
  max-width: 1220px;
  margin: 0 auto;
  padding: 28px 18px 56px;
}
.shell-wide { max-width: 1320px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 24px;
}
.topbar-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
  color: var(--muted);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 4vw, 3.55rem); line-height: 1.02; }
h2 { margin-bottom: 0; font-size: 1.24rem; }
h3 { margin-bottom: 6px; }
.lead { color: var(--muted); max-width: 76ch; line-height: 1.55; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel, .stat-card, .metric-card, .recent-card, .chat-bubble {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}
.panel {
  border-radius: 22px;
  padding: 20px;
}

.chat-panel { min-height: 72vh; display: flex; flex-direction: column; }
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 2px 18px;
}
.chat-bubble {
  max-width: 78%;
  border-radius: 20px;
  padding: 16px 18px;
}
.chat-bubble.bot {
  align-self: flex-start;
  border-top-left-radius: 8px;
  background: linear-gradient(180deg, rgba(18, 31, 63, 0.95), rgba(12, 21, 41, 0.96));
}
.chat-bubble.user {
  align-self: flex-end;
  border-top-right-radius: 8px;
  background: linear-gradient(135deg, rgba(21, 40, 77, 0.95), rgba(17, 25, 53, 0.95));
}
.bubble-label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.chat-bubble p { margin-bottom: 0; line-height: 1.55; }

.chat-composer {
  margin-top: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.composer-stage { display: grid; gap: 8px; }
.composer-meta { color: var(--muted); font-size: 0.9rem; }
#chatInput, input, textarea {
  width: 100%;
  border: 1px solid rgba(132, 168, 255, 0.22);
  background: rgba(4, 11, 24, 0.8);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 16px;
  outline: none;
}
#chatInput:focus, input:focus, textarea:focus {
  border-color: rgba(101, 214, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(101, 214, 255, 0.1);
}
#chatButton, .primary-button, .close-ticket-btn, .ghost-button, .ghost-link, .cta-link, .icon-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}
#chatButton:hover, .primary-button:hover, .close-ticket-btn:hover, .ghost-button:hover, .ghost-link:hover, .cta-link:hover, .icon-button:hover { transform: translateY(-1px); }
#chatButton, .primary-button, .close-ticket-btn, .progress-ticket-btn, .cta-link {
  color: #051018;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 800;
}
.ghost-button, .ghost-link, .icon-button {
  color: var(--text);
  background: rgba(132, 168, 255, 0.08);
  border: 1px solid rgba(132, 168, 255, 0.18);
}
.ghost-link, .cta-link { display: inline-flex; align-items: center; justify-content: center; }
.microcopy { color: var(--muted); margin-top: 12px; font-size: 0.92rem; }

.side-panel { display: grid; gap: 14px; }
.metric-card, .stat-card, .mini-stat {
  border-radius: 18px;
  padding: 16px;
}
.metric-card {
  display: grid;
  gap: 6px;
  background: linear-gradient(180deg, rgba(18, 31, 63, 0.9), rgba(11, 19, 39, 0.9));
}
.metric-card span, .stat-card span, .mini-stat span, .ticket-meta, .age-pill, .recent-card span, label span, dt {
  color: var(--muted);
}
.metric-card strong, .stat-card strong, .mini-stat strong {
  font-size: 1.8rem;
  letter-spacing: -0.03em;
}
.cta-link { margin-top: 4px; }

.dashboard-shell { padding-bottom: 68px; }
.dashboard-topbar { align-items: center; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: linear-gradient(180deg, rgba(17, 28, 53, 0.96), rgba(10, 16, 31, 0.92));
}
.stat-card strong { display: block; margin-top: 8px; }
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.75fr);
  gap: 18px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.live-pill, .age-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.22);
  color: #a7f3d0;
  font-size: 0.82rem;
}
.age-pill { background: rgba(101, 214, 255, 0.12); border-color: rgba(101, 214, 255, 0.22); color: #c9f4ff; }
.ticket-list, .recent-list, .mini-stats { display: grid; gap: 12px; }
.dashboard-ticket { padding: 16px; border-radius: 18px; background: var(--panel-strong); }
.ticket-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.ticket-location, .ticket-problem { color: #dce5ff; line-height: 1.5; }
.ticket-actions { display: flex; justify-content: end; margin-top: 14px; }
.close-ticket-btn { min-width: 98px; }
.progress-ticket-btn { min-width: 160px; margin-right: 8px; }
.progress-ticket-btn[disabled] { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.2); }
.recent-card { border-radius: 16px; padding: 14px; }
.recent-card p { margin-bottom: 0; color: #d6def6; }
.empty-state { color: var(--muted); }
.mini-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(16, 29, 55, 0.95), rgba(10, 18, 33, 0.95));
}
.mini-stat strong { font-size: 1.25rem; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 6, 23, 0.66);
  padding: 18px;
  z-index: 50;
}
.modal-card {
  width: min(760px, 100%);
  border-radius: 24px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(15, 26, 52, 0.98), rgba(8, 14, 28, 0.98));
  border: 1px solid rgba(132, 168, 255, 0.18);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
}
.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 1.5rem;
}
.modal-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.modal-form .full { grid-column: 1 / -1; }
.modal-actions { grid-column: 1 / -1; display: flex; justify-content: end; gap: 12px; margin-top: 4px; }
textarea { resize: vertical; min-height: 120px; }
.hidden { display: none !important; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
label { display: grid; gap: 8px; }
.full { grid-column: 1 / -1; }
button { font: inherit; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}
.detail-grid div, .ticket-card, .recent-card, .mini-stat, .stat-card, .metric-card {
  border: 1px solid rgba(132, 168, 255, 0.18);
}
.detail-grid div {
  border-radius: 14px;
  padding: 12px;
  background: rgba(11, 18, 33, 0.72);
}
.detail-grid dt { margin-bottom: 8px; }
.detail-grid dd { margin: 0; line-height: 1.45; }

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .chat-bubble { max-width: 92%; }
}
@media (max-width: 720px) {
  .topbar, .section-head, .ticket-card-head { flex-direction: column; align-items: start; }
  .chat-composer, .modal-form, .form-grid, .detail-grid, .stats-grid { grid-template-columns: 1fr; }
  .shell { padding-inline: 14px; }
  .panel, .modal-card { border-radius: 18px; }
}
