:root {
  color-scheme: dark;
  --bg: #0c0a08;
  --surface: rgba(28, 24, 20, 0.82);
  --surface-strong: rgba(34, 28, 22, 0.94);
  --surface-chat: rgba(18, 14, 10, 0.55);
  --line: rgba(201, 160, 88, 0.18);
  --line-strong: rgba(201, 160, 88, 0.4);
  --text: #f4ece0;
  --muted: #b8a98f;
  --subtle: #8c7f6a;
  --accent: #c9a058;
  --accent-strong: #f0d6a2;
  --success: #6bbf7a;
  --danger: #e06464;
  --warning: #e0b35a;
  --info: #6ba8d6;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  --app-bg-image: url('/shared-assets/fondo2.png');
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

body {
  background-image: linear-gradient(180deg, rgba(12, 10, 8, 0.74), rgba(12, 10, 8, 0.93)), var(--app-bg-image);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.app-header .brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #8a6a2c);
  display: grid; place-items: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px; font-weight: 700; color: #1a140c;
}

.app-header h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 32px;
  font-weight: 600;
  margin: 4px 0 6px;
  color: var(--accent-strong);
  letter-spacing: 0.01em;
}

.app-header .kicker {
  display: block;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 560px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.card h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--accent-strong);
}

.card h3 {
  font-size: 14px;
  margin: 16px 0 8px;
  color: var(--accent-strong);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card > p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.loading-shell {
  min-height: 60vh;
  display: grid;
  place-items: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
}

.spinner {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(40, 34, 28, 0.6);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover { background: rgba(56, 46, 36, 0.85); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #b8893c);
  border-color: var(--accent);
  color: #1a140c;
}
.btn.primary:hover { background: linear-gradient(135deg, var(--accent-strong), var(--accent)); }

.btn.danger { background: rgba(224, 100, 100, 0.16); border-color: rgba(224, 100, 100, 0.45); color: var(--danger); }
.btn.full { width: 100%; }
.btn.small { min-height: 32px; padding: 5px 12px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: var(--line); }

.hero-login { text-align: center; }
.hero-login .btn { margin-top: 16px; }

.feedback {
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
}
.feedback.success { background: rgba(107, 191, 122, 0.14); border: 1px solid rgba(107, 191, 122, 0.4); color: var(--success); }
.feedback.error { background: rgba(224, 100, 100, 0.14); border: 1px solid rgba(224, 100, 100, 0.4); color: var(--danger); }
.feedback.warning { background: rgba(224, 179, 90, 0.14); border: 1px solid rgba(224, 179, 90, 0.4); color: var(--warning); }

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 18px;
}

.session-bar .user { display: flex; align-items: center; gap: 10px; }
.session-bar .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8a6a2c);
  color: #1a140c;
  display: grid; place-items: center; font-weight: 800;
  overflow: hidden;
}
.session-bar .avatar img { width: 100%; height: 100%; object-fit: cover; }
.session-bar strong { color: var(--accent-strong); font-size: 14px; }
.session-bar .meta { color: var(--subtle); font-size: 12px; }

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px;
}

.tabs .tab {
  flex: 1;
  min-width: 120px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tabs .tab:hover { background: rgba(40, 34, 28, 0.5); color: var(--text); }
.tabs .tab.active {
  background: linear-gradient(135deg, var(--accent), #b8893c);
  color: #1a140c;
}

.tabs .tab .badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  font-size: 11px;
  background: rgba(0,0,0,0.25);
}
.tabs .tab.active .badge { background: rgba(255,255,255,0.3); }

.form-stack {
  display: grid;
  gap: 13px;
  margin-top: 10px;
}

.form-stack label { display: grid; gap: 5px; }

.form-stack label > span {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-strong);
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(18, 14, 10, 0.7);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 160, 88, 0.18);
}

textarea { min-height: 100px; resize: vertical; }

.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.tag-btn {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(18, 14, 10, 0.6);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.tag-btn:hover { border-color: var(--line-strong); color: var(--text); }
.tag-btn.is-selected {
  background: linear-gradient(135deg, var(--accent), #b8893c);
  border-color: var(--accent);
  color: #1a140c;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(201, 160, 88, 0.16);
  color: var(--accent-strong);
  border: 1px solid var(--line);
}

.status-pill.open, .status-pill.pending, .status-pill.investigating, .status-pill.under_review {
  background: rgba(224, 179, 90, 0.16); color: var(--warning); border-color: rgba(224, 179, 90, 0.4);
}
.status-pill.resolved, .status-pill.accepted {
  background: rgba(107, 191, 122, 0.16); color: var(--success); border-color: rgba(107, 191, 122, 0.4);
}
.status-pill.dismissed, .status-pill.rejected {
  background: rgba(224, 100, 100, 0.16); color: var(--danger); border-color: rgba(224, 100, 100, 0.4);
}

.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.list { display: grid; gap: 12px; }

.list-item {
  background: rgba(18, 14, 10, 0.6);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: grid;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.list-item:hover { border-color: var(--line-strong); background: rgba(24, 18, 14, 0.75); }
.list-item.is-selected { border-color: var(--accent); background: rgba(28, 22, 16, 0.85); }

.list-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.list-item-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent-strong);
  line-height: 1.3;
}

.list-item-id {
  font-size: 12px;
  color: var(--subtle);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.list-item-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: var(--subtle);
}

.list-item-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty {
  text-align: center;
  color: var(--subtle);
  padding: 32px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.detail-header h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px;
  margin: 0;
  color: var(--accent-strong);
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.detail-meta-item {
  background: rgba(18, 14, 10, 0.5);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
}
.detail-meta-item span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 3px;
}
.detail-meta-item strong { font-size: 13px; color: var(--text); font-weight: 600; }

.detail-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.detail-section h3 {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}

.detail-body {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-chat);
  border-radius: var(--radius-xs);
  padding: 14px;
  border-left: 3px solid var(--accent);
}

.chat-thread {
  display: grid;
  gap: 14px;
  max-height: 420px;
  overflow-y: auto;
  padding: 14px;
  background: var(--surface-chat);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  scroll-behavior: smooth;
}

.chat-msg {
  display: flex;
  gap: 10px;
  flex-direction: column;
}

.chat-msg.is-staff { align-items: flex-end; }

.chat-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 12px;
  flex-shrink: 0;
}
.chat-msg.is-user .chat-msg-avatar { background: linear-gradient(135deg, var(--accent), #8a6a2c); color: #1a140c; }
.chat-msg.is-staff .chat-msg-avatar { background: linear-gradient(135deg, var(--info), #3a6a8a); color: #fff; }
.chat-msg.is-system .chat-msg-avatar { background: var(--subtle); color: #fff; }

.chat-msg-body {
  max-width: 80%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.is-user .chat-msg-body {
  background: rgba(201, 160, 88, 0.14);
  border: 1px solid rgba(201, 160, 88, 0.3);
  border-bottom-left-radius: 3px;
}

.chat-msg.is-staff .chat-msg-body {
  background: rgba(107, 168, 214, 0.12);
  border: 1px solid rgba(107, 168, 214, 0.3);
  border-bottom-right-radius: 3px;
}

.chat-msg.is-staff-note .chat-msg-body {
  background: rgba(224, 179, 90, 0.1);
  border: 1px dashed rgba(224, 179, 90, 0.4);
  font-style: italic;
}

.chat-msg-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--subtle);
}
.chat-msg-meta strong { color: var(--accent-strong); font-size: 12px; }
.chat-msg.is-staff .chat-msg-meta { flex-direction: row-reverse; }

.chat-msg-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(107, 168, 214, 0.2);
  color: var(--info);
}
.chat-msg.is-user .chat-msg-tag { background: rgba(201, 160, 88, 0.2); color: var(--accent-strong); }
.chat-msg.is-staff-note .chat-msg-tag { background: rgba(224, 179, 90, 0.2); color: var(--warning); }

.chat-composer {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.chat-composer textarea { min-height: 70px; }

.chat-empty {
  text-align: center;
  color: var(--subtle);
  padding: 24px 16px;
  font-size: 13px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.back-btn:hover { color: var(--accent-strong); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: center;
}

.stat-card .num {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-strong);
  line-height: 1;
}

.stat-card .label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-top: 4px;
}

@media (max-width: 620px) {
  .app-shell { padding: 18px 12px 48px; }
  .card { padding: 16px; }
  .app-header h1 { font-size: 24px; }
  .tabs .tab { min-width: 100px; font-size: 12px; }
  .detail-meta-grid { grid-template-columns: 1fr 1fr; }
  .chat-msg-body { max-width: 90%; }
}
