:root {
  color-scheme: dark;
  --bg: #0d1116;
  --bg-soft: #171e26;
  --panel: linear-gradient(180deg, rgba(23, 29, 37, 0.95), rgba(13, 17, 22, 0.98));
  --panel-2: rgba(18, 23, 29, 0.88);
  --line: rgba(197, 161, 87, 0.18);
  --line-strong: rgba(197, 161, 87, 0.36);
  --text: #f4efe6;
  --muted: #b5ab9f;
  --accent: #d0a85d;
  --accent-2: #f0d7a6;
  --success: #72c48f;
  --danger: #ea8a73;
  --warning: #e7b35a;
  font: 15px/1.55 "Manrope", "Segoe UI Variable Text", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(7, 10, 14, 0.74), rgba(5, 7, 10, 0.9)),
    radial-gradient(circle at top left, rgba(208, 168, 93, 0.15), transparent 28%),
    url('/shared-assets/fondo2.png') center center / cover fixed no-repeat,
    linear-gradient(180deg, #10151b 0%, #080b0e 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(208, 168, 93, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(208, 168, 93, 0.024) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, black 48%, transparent 88%);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
#app { min-height: 100vh; }

.loading-shell,
.landing-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.hero-card,
.sidebar-card,
.new-ticket-card,
.detail-card,
.feedback {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.32);
}

.hero-card {
  width: min(100%, 760px);
  padding: clamp(28px, 5vw, 42px);
  display: grid;
  gap: 20px;
}

.hero-brand,
.brand-inline,
.topbar,
.topbar-actions,
.ticket-card-head,
.ticket-card-meta,
.detail-head,
.detail-pills,
.section-head,
.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.hero-brand,
.brand-inline { justify-content: flex-start; }

.brand-mark {
  width: 86px;
  height: 86px;
  border-radius: 26px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, rgba(240, 199, 103, 0.18), rgba(14, 14, 15, 0.96) 72%);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-mark.small {
  width: 52px;
  height: 52px;
  border-radius: 18px;
}

.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.eyebrow {
  display: inline-flex;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--muted);
}

h1, h2 { margin: 6px 0 0; font-family: "Cormorant Garamond", serif; font-weight: 700; }
h1 { font-size: clamp(2.3rem, 4vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 2.4vw, 2.2rem); }
p { margin: 0; }

.hero-copy,
.hero-requirement p,
.ticket-card p,
.empty-box,
.message-bubble p { color: var(--muted); }

.hero-requirement {
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 8px;
}

.hero-actions { display: flex; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.btn.primary {
  border-color: rgba(208, 168, 93, 0.38);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #1c160d;
  font-weight: 700;
}

.btn.secondary,
.btn.ghost { background: rgba(255, 255, 255, 0.04); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.support-shell {
  height: 100vh;
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  overflow: hidden;
}

.topbar {
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(12, 16, 21, 0.78);
  backdrop-filter: blur(12px);
}

.compact-topbar {
  min-height: 64px;
}

.compact-brand-inline {
  gap: 10px;
}

.compact-brand-copy {
  display: grid;
  gap: 2px;
}

.topbar-actions { flex-wrap: wrap; }

.identity-pill,
.status-pill,
.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.identity-pill span,
.ticket-card-meta,
.message-meta span { color: var(--muted); font-size: 13px; }

.status-open { color: #f6e0b1; background: rgba(231, 179, 90, 0.12); }
.status-in_progress { color: #cae2ff; background: rgba(120, 170, 255, 0.12); }
.status-waiting_user { color: #ffe6b1; background: rgba(230, 179, 82, 0.1); }
.status-resolved { color: #caf3d7; background: rgba(114, 196, 143, 0.12); }
.status-closed { color: #f0d5cf; background: rgba(234, 138, 115, 0.12); }

.support-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  min-height: 0;
}

.sidebar-card,
.new-ticket-card,
.detail-card { padding: 16px; }
.sidebar-card {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}
.workspace-column {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-height: 0;
}
.detail-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.workspace-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 6px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(10, 14, 18, 0.78);
}

.workspace-switch-btn {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}

.workspace-switch-btn.active {
  background: linear-gradient(180deg, rgba(240, 215, 166, 0.98), rgba(208, 168, 93, 0.96));
  color: #1c160d;
  font-weight: 700;
}

.workspace-switch-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.profile-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.profile-card-head,
.profile-copy,
.profile-roles {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-card-head {
  align-items: center;
}

.profile-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  place-items: center;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-copy {
  flex-direction: column;
  gap: 2px;
}

.profile-copy strong {
  font-size: 14px;
}

.profile-copy span {
  color: var(--muted);
  font-size: 12px;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
}

.role-chip {
  color: var(--accent-2);
}

.role-chip.is-muted {
  color: var(--muted);
}

.ticket-list,
.messages-panel,
.ticket-form,
.reply-form {
  display: grid;
  gap: 12px;
}

.reply-form {
  align-content: start;
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: linear-gradient(180deg, rgba(13, 17, 22, 0), rgba(13, 17, 22, 0.9) 20%, rgba(13, 17, 22, 0.98) 100%);
}

.reply-attachment-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
}

.reply-attachment-strip[hidden] {
  display: none !important;
}

.reply-attachment-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(208, 168, 93, 0.22);
  background: rgba(208, 168, 93, 0.08);
  color: var(--accent-2);
  font-size: 12px;
}

.reply-attachment-remove {
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.reply-compose-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.reply-message-field {
  min-width: 0;
}

.reply-message-field textarea {
  min-height: 84px;
  max-height: 120px;
  padding: 10px 12px;
}

.reply-submit-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  white-space: nowrap;
}

.ticket-list {
  min-height: 0;
  overflow: auto;
  align-content: start;
}

.ticket-form-inline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-tip {
  margin-top: -4px;
  color: var(--muted);
  font-size: 13px;
}

.ticket-card {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
}

.ticket-card.active {
  border-color: var(--line-strong);
  background: linear-gradient(135deg, rgba(208, 168, 93, 0.16), rgba(255, 255, 255, 0.02));
}

.detail-head { align-items: flex-start; }

.detail-title {
  margin-top: 2px;
  font-size: 1.5rem;
}

.messages-panel {
  min-height: 0;
  height: 100%;
  overflow: auto;
  gap: 8px;
  padding-right: 2px;
  padding-top: 2px;
}

.message-row {
  display: flex;
}

.message-row.user {
  justify-content: flex-start;
}

.message-row.staff {
  justify-content: flex-end;
}

.message-row.continuation {
  margin-top: -4px;
}

.message-bubble {
  max-width: min(100%, 1040px);
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.empty-workspace-card {
  display: grid;
  gap: 16px;
}

.workspace-empty-actions {
  display: flex;
  justify-content: flex-start;
}

.message-bubble.staff {
  border-color: rgba(120, 170, 255, 0.18);
  background: rgba(120, 170, 255, 0.08);
  border-top-right-radius: 6px;
}

.message-bubble.user {
  border-color: rgba(208, 168, 93, 0.18);
  background: rgba(208, 168, 93, 0.08);
  border-top-left-radius: 6px;
}

.message-bubble.compact {
  gap: 2px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.message-meta {
  gap: 8px;
  flex-wrap: wrap;
}

.message-meta strong {
  font-size: 13px;
}

.message-meta span {
  font-size: 11px;
}

.message-bubble p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.message-attachments {
  display: grid;
  gap: 6px;
}

.message-link,
.message-image-link {
  display: inline-flex;
  width: fit-content;
}

.message-link {
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-2);
  font-size: 12px;
}

.message-image-link {
  max-width: min(100%, 280px);
}

.message-image {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

label {
  display: grid;
  gap: 8px;
}

label span { color: var(--muted); font-size: 13px; }

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(14, 18, 23, 0.88);
}

textarea { resize: vertical; }

.feedback {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 30;
  width: min(560px, calc(100vw - 24px));
  padding: 12px 14px;
  transform: translateX(-50%);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.26);
}

.feedback.success { border-color: rgba(114, 196, 143, 0.3); color: #caf3d7; }
.feedback.danger { border-color: rgba(234, 138, 115, 0.3); color: #ffd1c8; }

.empty-box {
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
  .support-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .support-grid { grid-template-columns: 1fr; }
  .topbar,
  .topbar-actions,
  .detail-head,
  .detail-pills { align-items: flex-start; }
  .topbar,
  .topbar-actions { flex-direction: column; }
  .workspace-switch {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .workspace-switch-btn {
    width: 100%;
  }
  .reply-image-field {
    max-width: none;
  }
  .reply-compose-row {
    grid-template-columns: 1fr;
  }
  .reply-submit-btn {
    width: 100%;
  }
  .ticket-form-inline {
    grid-template-columns: 1fr;
  }
  .message-bubble {
    max-width: 100%;
  }
  .feedback {
    top: 10px;
    width: calc(100vw - 20px);
  }
}