:root {
  color-scheme: dark;
  --bg: #0F141C;
  --surface: #1E2A3A;
  --surface-2: #172230;
  --border: rgba(255, 255, 255, 0.08);
  --text: #E6EDF3;
  --text-muted: #8B949E;
  --accent: #1ABC9C;
  --accent-dark: #148f77;
  --accent-ink: #0F141C;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(26, 188, 156, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.admin-shell {
  max-width: min(1600px, 100%);
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 16px;
  box-sizing: border-box;
}

.admin-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  min-height: 70vh;
  align-items: stretch;
}

.admin-layout.has-detail {
  grid-template-columns: 220px minmax(280px, 1fr) minmax(320px, 1.15fr);
}

@media (max-width: 1100px) {
  .admin-layout,
  .admin-layout.has-detail {
    grid-template-columns: 1fr;
  }
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 8px;
}

header .brand {
  flex: 1;
  min-width: 0;
}

header .btn {
  flex-shrink: 0;
  white-space: nowrap;
  margin-top: 2px;
}

header .btn.back-arrow {
  min-width: 44px;
  padding: 12px 14px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 640px) {
  header {
    flex-direction: column;
    align-items: stretch;
  }

  header .btn {
    align-self: flex-start;
  }
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand .eyebrow {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
}

.brand p, .hint {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

body.brand-yogamoor {
  --accent: #10b981;
  --accent-dark: #059669;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(16, 185, 129, 0.12), transparent 55%),
    var(--bg);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  overflow: auto;
  max-height: 78vh;
}

.grid { display: grid; gap: 16px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

textarea { min-height: 120px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(26, 188, 156, 0.35);
  border-color: var(--accent);
}

button, .btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 700;
  padding: 12px 18px;
  cursor: pointer;
}

button:hover, .btn:hover { background: var(--accent-dark); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

button.secondary, .btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.92rem;
}

.status.error {
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.status.success {
  background: rgba(52, 211, 153, 0.12);
  color: #bbf7d0;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.hidden { display: none !important; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill.open, .pill.awaiting_support { background: rgba(96, 165, 250, 0.15); color: #93c5fd; }
.pill.awaiting_customer, .pill.responded { background: rgba(52, 211, 153, 0.15); color: #6ee7b7; }
.pill.resolved { background: rgba(250, 204, 21, 0.15); color: #fde68a; }
.pill.closed { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }

.nav-list, .ticket-list, .thread { display: grid; gap: 8px; }
.thread { gap: 16px; margin: 20px 0 8px; }
.nav-list button {
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  font-weight: 600;
}
.nav-list button.active, .nav-list button:hover {
  border-color: rgba(26, 188, 156, 0.35);
  background: var(--surface-2);
}

.ticket-item {
  display: block;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.ticket-item:hover, .ticket-item.active {
  border-color: rgba(26, 188, 156, 0.35);
}
.ticket-item .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}
.ticket-item h3 { margin: 0 0 4px; font-size: 0.95rem; }

.message {
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.message.customer {
  border-left: 3px solid rgba(96, 165, 250, 0.45);
}
.message.support {
  border-color: rgba(26, 188, 156, 0.35);
  border-left: 3px solid var(--accent);
}
.message.system {
  opacity: 0.85;
  font-style: italic;
  border-left: 3px solid rgba(148, 163, 184, 0.35);
}
.message .who {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.message .who .sender {
  font-weight: 700;
  color: var(--text);
}
.message .who .channel-pill {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.message .who .when {
  margin-left: auto;
  font-size: 0.78rem;
}
.message-body {
  line-height: 1.65;
  font-size: 0.94rem;
  color: var(--text);
}
.message-body p {
  margin: 0 0 0.75em;
}
.message-body p:last-child {
  margin-bottom: 0;
}
.message-quote {
  margin-top: 4px;
  padding: 10px 12px 12px;
  border-left: 3px solid var(--border);
  border-radius: 0 8px 8px 0;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}
.message-quote summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.82rem;
  user-select: none;
  margin-bottom: 8px;
}
.message-quote summary:hover {
  color: var(--text);
}
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 14px 0 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.reply-section {
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
