/* ═══════════════════════════════════════════════════════
   Secdrift CRM — Helpdesk Layout
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --f: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --r: 8px;
  --t: 0.15s ease;
}

/* ── Dark Theme ──────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #08090d;
  --sidebar-bg: #0e1117;
  --surface: #161b26;
  --surface-2: #1c2333;
  --border: #1e2536;
  --border-2: #283044;
  --text: #e8eaf0;
  --text-2: #9ba3b5;
  --text-3: #6b7385;
  --text-4: #454d60;
  --primary: #4f8ff7;
  --primary-dim: rgba(79,143,247,0.12);
  --green: #34d399;
  --green-dim: rgba(52,211,153,0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251,191,36,0.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --input-bg: #0e1117;
  --topbar-bg: #0b0d14;
  --hover: rgba(255,255,255,0.04);
  --active-row: rgba(79,143,247,0.08);
}

/* ── Light Theme ─────────────────────────────────────── */
[data-theme="light"] {
  --bg: #f5f6f8;
  --sidebar-bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-2: #d1d5db;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --text-4: #9ca3af;
  --primary: #3b7dee;
  --primary-dim: rgba(59,125,238,0.1);
  --green: #10b981;
  --green-dim: rgba(16,185,129,0.1);
  --yellow: #f59e0b;
  --yellow-dim: rgba(245,158,11,0.1);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.1);
  --input-bg: #f5f6f8;
  --topbar-bg: #ffffff;
  --hover: rgba(0,0,0,0.03);
  --active-row: rgba(59,125,238,0.06);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--f);
  background: var(--bg);
  color: var(--text);
}

/* ═════════════════════════════════════════════════════
   TOPBAR
   ═════════════════════════════════════════════════════ */
.crm-topbar {
  height: 48px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.crm-topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  overflow: hidden;
  max-height: 48px;
}

.crm-topbar-nav, .crm-topbar-actions, .crm-sync-status, .crm-topbar-user {
  position: relative;
  z-index: 2;
}

.crm-topbar-logo-img {
  height: 30px;
  width: auto;
  object-fit: contain;
}
[data-theme="dark"] .crm-topbar-logo-img {
  filter: invert(1);
}

.crm-topbar-nav a {
  font-size: 0.78rem;
  color: var(--text-3);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--r);
  transition: color var(--t);
}
.crm-topbar-nav a:hover { color: var(--text); }

.crm-topbar-spacer { flex: 1; }

.crm-sync-status {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.68rem; color: var(--text-4);
}
.sync-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.sync-dot.online { background: var(--green); }
.sync-dot.offline { background: var(--text-4); }
.sync-dot.pending { background: var(--yellow); }
.sync-dot.syncing { background: var(--primary); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.crm-topbar-user {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.75rem; color: var(--text-2);
}
.user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary-dim); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 600;
}

.crm-topbar-actions { display: flex; gap: 2px; }
.crm-topbar-actions button, .crm-btn-ghost.crm-btn-sm {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  border: none; background: none; color: var(--text-3);
  cursor: pointer; transition: all var(--t);
}
.crm-topbar-actions button:hover, .crm-btn-ghost.crm-btn-sm:hover {
  color: var(--text); background: var(--hover);
}

/* ═════════════════════════════════════════════════════
   HELPDESK LAYOUT
   ═════════════════════════════════════════════════════ */
.hd {
  display: flex;
  height: calc(100vh - 48px);
  overflow: hidden;
}

/* ── Left Sidebar ────────────────────────────────────── */
.hd-sidebar {
  width: 340px;
  min-width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.hd-sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
}

.hd-tab {
  flex: 1;
  font-family: var(--f);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 10px 4px;
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--t);
  text-align: center;
  white-space: nowrap;
}
.hd-tab:hover { color: var(--text-2); }
.hd-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.hd-tab-count {
  font-size: 0.58rem;
  font-weight: 600;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 2px;
}
.hd-tab.active .hd-tab-count {
  background: var(--primary-dim);
  color: var(--primary);
}

.hd-sidebar-search {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text-4);
}
.hd-sidebar-search input {
  flex: 1;
  background: none; border: none;
  color: var(--text);
  font-family: var(--f);
  font-size: 0.78rem;
  outline: none;
}
.hd-sidebar-search input::placeholder { color: var(--text-4); }

/* Ticket list */
.hd-ticket-list {
  flex: 1;
  overflow-y: auto;
}

.hd-ticket-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t);
}
.hd-ticket-item:hover { background: var(--hover); }
.hd-ticket-item.active { background: var(--active-row); border-left: 3px solid var(--primary); }

.hd-ticket-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.hd-badge {
  font-size: 0.58rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.hd-badge.open { background: var(--primary-dim); color: var(--primary); }
.hd-badge.waiting { background: var(--yellow-dim); color: var(--yellow); }
.hd-badge.closed { background: var(--green-dim); color: var(--green); }

.hd-ticket-subject {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.hd-ticket-time {
  font-size: 0.62rem;
  color: var(--text-4);
  font-family: var(--mono);
  flex-shrink: 0;
}

.hd-ticket-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-3);
}

.hd-ticket-customer {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hd-ticket-assignee {
  margin-left: auto;
  font-size: 0.62rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-4);
  flex-shrink: 0;
}
.hd-ticket-assignee.me { background: var(--primary-dim); color: var(--primary); }

.hd-new-btn {
  margin: 10px;
  padding: 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-family: var(--f);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--t);
}
.hd-new-btn:hover { opacity: 0.9; }

.hd-empty-list {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-4);
  font-size: 0.8rem;
}

/* ── Right: Main Panel ───────────────────────────────── */
.hd-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.hd-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-4);
  gap: 12px;
}
.hd-empty-state p { font-size: 0.85rem; }

/* ── Ticket Header ───────────────────────────────────── */
.hd-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.hd-header-info { flex: 1; min-width: 0; }

.hd-header-subject {
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hd-header-meta {
  font-size: 0.7rem;
  color: var(--text-3);
  margin-top: 2px;
  display: flex;
  gap: 10px;
}

.hd-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.hd-status-select {
  font-family: var(--f);
  font-size: 0.72rem;
  padding: 5px 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  cursor: pointer;
  outline: none;
}

.hd-btn-delete {
  font-family: var(--f);
  font-size: 0.68rem;
  padding: 5px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--red);
  cursor: pointer;
  transition: all var(--t);
}
.hd-btn-delete:hover { background: var(--red-dim); }

/* ── Conversation + Info Split ───────────────────────── */
.hd-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.hd-conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.hd-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message bubbles */
.hd-msg {
  padding: 12px 16px;
  border-radius: 10px;
  max-width: 100%;
  font-size: 0.82rem;
  line-height: 1.55;
}

.hd-msg.inbound {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
}

.hd-msg.outbound {
  background: var(--primary-dim);
  border: 1px solid rgba(79,143,247,0.12);
  border-left: 3px solid var(--green);
}

.hd-msg-meta {
  font-size: 0.68rem;
  color: var(--text-4);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.hd-msg-meta strong { color: var(--text-2); }

.hd-msg-label {
  font-size: 0.58rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-3);
}

.hd-msg-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-4);
  font-size: 0.58rem;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--f);
  transition: all var(--t);
}
.hd-msg-toggle:hover { color: var(--text-2); border-color: var(--text-3); }

.hd-msg-text {
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.hd-msg-html { display: none; }
.hd-msg-iframe {
  width: 100%;
  min-height: 120px;
  border: none;
  border-radius: 6px;
  background: #fff;
}

/* Attachments */
.hd-att-btn {
  margin-top: 8px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-3);
  font-size: 0.7rem;
  font-family: var(--f);
  padding: 5px 10px;
  border-radius: var(--r);
  cursor: pointer;
  transition: all var(--t);
}
.hd-att-btn:hover { border-color: var(--primary); color: var(--primary); }

.hd-att-grid {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px;
}
.hd-att-thumb {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 4px;
  background: var(--surface);
  transition: border-color var(--t);
}
.hd-att-thumb:hover { border-color: var(--primary); }
.hd-att-thumb img {
  max-width: 160px; max-height: 120px;
  border-radius: 4px; object-fit: cover; display: block;
}
.hd-att-name {
  font-size: 0.58rem; color: var(--text-4);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; text-align: center; margin-top: 2px;
}

/* ── Reply Section ───────────────────────────────────── */
.hd-reply {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  background: var(--surface);
  flex-shrink: 0;
}

.hd-reply-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.hd-reply-actions button {
  font-family: var(--f);
  font-size: 0.68rem;
  padding: 4px 10px;
  border-radius: var(--r);
  cursor: pointer;
  transition: all var(--t);
}

.hd-btn-template {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-3);
}
.hd-btn-template:hover { border-color: var(--primary); color: var(--primary); }

.hd-btn-ai {
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(168,85,247,0.1));
  border: 1px solid var(--border);
  color: var(--text-2);
  display: flex; align-items: center; gap: 4px;
}
.hd-btn-ai:hover {
  border-color: #8b5cf6; color: #a78bfa;
}
.hd-btn-ai:disabled { opacity: 0.5; cursor: not-allowed; }

.hd-reply-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.hd-reply-row textarea {
  flex: 1;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--f);
  font-size: 0.8rem;
  resize: vertical;
  min-height: 60px;
  max-height: 200px;
  outline: none;
  transition: border-color var(--t);
}
.hd-reply-row textarea:focus { border-color: var(--primary); }

.hd-reply-send {
  padding: 10px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-family: var(--f);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--t);
}
.hd-reply-send:hover { opacity: 0.9; }
.hd-reply-send:disabled { opacity: 0.5; }

.hd-reply-buttons {
  display: flex; flex-direction: column; gap: 6px; align-items: stretch;
}
.hd-reply-attach {
  display: flex; align-items: center; justify-content: center;
  padding: 8px; border: 1px dashed var(--border-2); border-radius: var(--r);
  color: var(--text-3); cursor: pointer; transition: all var(--t);
}
.hd-reply-attach:hover { color: var(--primary); border-color: var(--primary); }

.hd-reply-attachments {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 0;
}
.hd-reply-attachments:empty { display: none; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; font-size: 0.7rem; color: var(--text-2);
}
.attach-chip-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip-size { color: var(--text-4); font-family: var(--mono); font-size: 0.62rem; }
.attach-chip button {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: 0.85rem; padding: 0 2px; line-height: 1;
}
.attach-chip button:hover { color: var(--red); }

/* ── Info Panel (right side of conversation) ─────────── */
.hd-info {
  width: 260px;
  border-left: 1px solid var(--border);
  background: var(--sidebar-bg);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 16px;
}

.hd-info-section {
  margin-bottom: 20px;
}

.hd-info-title {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-4);
  margin-bottom: 8px;
}

.hd-info-row {
  font-size: 0.75rem;
  color: var(--text-2);
  margin-bottom: 4px;
}
.hd-info-row a { color: var(--primary); text-decoration: none; }
.hd-info-row a:hover { text-decoration: underline; }
.hd-info-label {
  font-size: 0.65rem;
  color: var(--text-4);
}

/* Orders */
.hd-order {
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--r);
  font-size: 0.72rem;
  margin-bottom: 6px;
}
.hd-order-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;
}
.hd-order-id { font-family: var(--mono); color: var(--primary); font-weight: 500; }
.hd-order-status {
  font-size: 0.6rem; padding: 1px 6px; border-radius: 10px; font-weight: 500;
}
.hd-order-status.pending { background: rgba(234,179,8,0.15); color: #eab308; }
.hd-order-status.handled { background: rgba(52,211,153,0.15); color: var(--green); }
.hd-order-status.cancelled { background: rgba(239,68,68,0.15); color: var(--red); }
.hd-order-details {
  display: flex; gap: 8px; align-items: center; margin-bottom: 4px;
}
.hd-order-amount { font-weight: 600; }
.hd-order-date { color: var(--text-4); font-family: var(--mono); font-size: 0.62rem; }
.hd-order-products { font-size: 0.65rem; color: var(--text-3); margin-bottom: 4px; }
.hd-order-products div { margin-bottom: 1px; }
.hd-order-tracking {
  display: flex; align-items: center; gap: 6px; font-size: 0.65rem;
  padding: 4px 8px; background: var(--surface); border-radius: var(--r); margin-top: 4px;
}
.hd-order-tracking svg { flex-shrink: 0; color: var(--text-3); }
.hd-order-tracking a {
  color: var(--primary); text-decoration: none; font-family: var(--mono); font-size: 0.62rem;
}
.hd-order-tracking a:hover { text-decoration: underline; }
.hd-order-tracking span { font-family: var(--mono); font-size: 0.62rem; color: var(--text-2); }
.hd-order-shipper { color: var(--text-4); font-size: 0.6rem; }

/* Notes */
.hd-note {
  font-size: 0.72rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.hd-note-time { font-family: var(--mono); font-size: 0.6rem; color: var(--text-4); }
.hd-note-author { font-weight: 600; color: var(--text-2); }
.hd-note-text { color: var(--text-3); }

.hd-note-input {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.hd-note-input input {
  flex: 1;
  padding: 5px 8px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--f);
  font-size: 0.72rem;
  outline: none;
}
.hd-note-input input:focus { border-color: var(--primary); }
.hd-note-input button {
  font-family: var(--f);
  font-size: 0.65rem;
  padding: 4px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
}
.hd-note-input button:hover { color: var(--primary); border-color: var(--primary); }

.hd-no-data {
  font-size: 0.72rem;
  color: var(--text-4);
  font-style: italic;
}

/* ── Lightbox ────────────────────────────────────────── */
.crm-lightbox {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  align-items: center; justify-content: center;
}
.crm-lightbox.show { display: flex; }
.crm-lightbox-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.85); }
.crm-lightbox-img {
  position: relative;
  max-width: 90vw; max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  object-fit: contain;
}

/* ── Modal ───────────────────────────────────────────── */
.crm-modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6);
  align-items: center; justify-content: center;
}
.crm-modal-overlay.show { display: flex; }

.crm-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 420px;
  max-width: 90vw;
}
.crm-modal-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }

.crm-form-field { margin-bottom: 12px; }
.crm-form-field label {
  display: block;
  font-size: 0.7rem; font-weight: 500;
  color: var(--text-3);
  margin-bottom: 4px;
}
.crm-form-field input {
  width: 100%;
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--f);
  font-size: 0.82rem;
  outline: none;
}
.crm-form-field input:focus { border-color: var(--primary); }

.crm-modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px;
}

.crm-btn-ghost {
  font-family: var(--f);
  font-size: 0.78rem;
  padding: 8px 16px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-2);
  cursor: pointer;
}
.crm-btn-primary {
  font-family: var(--f);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
}

/* ── User Management Modal ───────────────────────────── */
.crm-modal-wide { width: 560px; max-height: 85vh; overflow-y: auto; }
.crm-modal-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.crm-modal-header .crm-modal-title { margin-bottom: 0; }
.crm-modal-header .crm-btn-sm { font-size: 1.2rem; padding: 2px 8px; }
.crm-modal-divider { border-top: 1px solid var(--border); margin: 16px 0; }
.crm-form-row { display: flex; gap: 12px; }
.crm-form-row .crm-form-field { flex: 1; }
.crm-form-field select {
  width: 100%;
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--f);
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}
.crm-form-field select:focus { border-color: var(--primary); }
.crm-form-error {
  font-size: 0.72rem; color: var(--red); margin-top: 8px; min-height: 1em;
}

/* User list table */
.users-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.users-table th {
  text-align: left; padding: 6px 8px; font-weight: 500; font-size: 0.68rem;
  color: var(--text-4); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.users-table td {
  padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.users-table tr:last-child td { border-bottom: none; }
.users-table .user-role {
  font-size: 0.65rem; padding: 2px 8px; border-radius: 10px; font-weight: 500;
}
.users-table .user-role.admin { background: rgba(79,143,247,0.15); color: var(--primary); }
.users-table .user-role.user { background: rgba(52,211,153,0.15); color: var(--green); }
.users-table .user-actions { display: flex; gap: 4px; }
.users-table .user-actions button {
  font-family: var(--f); font-size: 0.68rem; padding: 4px 10px;
  border-radius: var(--r); cursor: pointer; border: 1px solid var(--border);
  background: none; color: var(--text-2);
}
.users-table .user-actions button:hover { background: var(--surface-2); }
.users-table .user-actions .btn-delete-user { color: var(--red); border-color: rgba(239,68,68,0.3); }
.users-table .user-actions .btn-delete-user:hover { background: rgba(239,68,68,0.1); }

/* Edit user inline */
.user-edit-row td { background: var(--surface-2); }
.user-edit-row input, .user-edit-row select {
  padding: 4px 8px; background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text); font-family: var(--f); font-size: 0.75rem;
  width: 100%;
}

/* ── Admin Tabs ──────────────────────────────────────── */
.admin-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.admin-tab {
  background: none; border: none; padding: 8px 16px; font-family: var(--f);
  font-size: 0.78rem; font-weight: 500; color: var(--text-3); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all var(--t);
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Auth Log ────────────────────────────────────────── */
.authlog-table { font-size: 0.73rem; }
.authlog-table td { padding: 6px 10px; }
.authlog-table .authlog-fail td { background: rgba(239,68,68,0.04); }
.authlog-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 0.68rem; font-weight: 600;
}
.authlog-ok { background: rgba(52,211,153,0.12); color: var(--green); }
.authlog-bad { background: rgba(239,68,68,0.15); color: var(--red); }
.authlog-ip { font-family: var(--mono); font-size: 0.68rem; color: var(--text-3); }
.authlog-ua { font-size: 0.68rem; color: var(--text-3); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#admin-tab-authlog { max-height: 400px; overflow-y: auto; }

/* ── Wait Time ───────────────────────────────────────── */
.hd-ticket-wait {
  font-size: 0.62rem; font-family: var(--mono); font-weight: 500;
  padding: 1px 6px; border-radius: 10px;
}
.wait-green { background: rgba(52,211,153,0.12); color: var(--green); }
.wait-orange { background: rgba(234,179,8,0.12); color: #eab308; }
.wait-red { background: rgba(239,68,68,0.15); color: var(--red); }

.hd-wait-badge {
  font-size: 0.65rem; font-family: var(--mono); font-weight: 500;
  padding: 2px 8px; border-radius: 10px; margin-left: 8px; vertical-align: middle;
}

/* ── Priority Dots ───────────────────────────────────── */
.hd-prio-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.hd-prio-dot.high { background: #eab308; }
.hd-prio-dot.urgent { background: var(--red); animation: pulse-prio 1.5s ease-in-out infinite; }
@keyframes pulse-prio {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

.hd-prio-select {
  font-family: var(--f); font-size: 0.75rem;
  padding: 5px 8px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r); cursor: pointer;
}

/* ── Collision Banner ────────────────────────────────── */
.hd-collision-banner {
  padding: 8px 14px; font-size: 0.75rem; font-weight: 500;
  background: rgba(234,179,8,0.1); border: 1px solid rgba(234,179,8,0.25);
  border-radius: var(--r); color: #eab308;
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 2px 0;
}

/* Spinner */
.hd-spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid var(--text-4);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .hd-info { display: none; }
}
@media (max-width: 640px) {
  .hd-sidebar { width: 100%; }
  .hd-main { display: none; }
  .hd.has-active .hd-sidebar { display: none; }
  .hd.has-active .hd-main { display: flex; }
}
