
/* ==================================================================
 * پنل مدیریت ربات دایرکت — بازطراحی بصری (Ultra-minimal dark premium)
 * فقط لایه ظاهری بازنویسی شده؛ هیچ رفتاری از panel.js تغییر نکرده است.
 * ------------------------------------------------------------------
 * Sections: Variables → Reset → Typography → Layout → Sidebar →
 * Topbar → Cards → Tables → Forms → Buttons → Toggles → Chat →
 * Badges/Pills → Toast/Login → Utilities → Responsive
 * ================================================================== */

/* ---------------- Variables ---------------- */
:root {
  --bg: #0a0a0c;
  --bg-secondary: #101217;
  --elevated: #151922;
  --card: #1a1f2b;
  --card-2: #1e2431;

  --primary: #6366f1;
  --primary-600: #5457e0;
  --primary-soft: rgba(99, 102, 241, 0.14);
  --secondary: #8b5cf6;
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.14);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --info: #3b82f6;

  --text: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, 0.65);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);

  --sidebar-w: 264px;
}

/* ---------------- Reset ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(99, 102, 241, 0.12), transparent 60%),
    radial-gradient(760px 460px at 5% 5%, rgba(139, 92, 246, 0.08), transparent 55%);
}
button, input, textarea { font-family: inherit; color: inherit; }
::selection { background: rgba(99, 102, 241, 0.35); color: #fff; }

* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.12) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); background-clip: padding-box; }

/* ---------------- Typography ---------------- */
h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.card h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.hint { color: var(--text-secondary); font-size: 0.82rem; line-height: 1.7; margin: 0; }
.empty { color: var(--text-tertiary); font-size: 0.88rem; text-align: center; padding: 40px 16px; }
.error {
  color: #fecaca;
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.82rem;
}

/* ---------------- Layout ---------------- */
.app-shell { position: relative; z-index: 1; display: flex; min-height: 100vh; gap: 0; }
.content-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { flex: 1; padding: 24px 32px 48px; max-width: 1180px; width: 100%; margin: 0 auto; }
.tab-panel { display: none; animation: fadeIn 0.28s var(--ease); }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: linear-gradient(180deg, rgba(21, 25, 34, 0.9), rgba(16, 18, 23, 0.9));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 14px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; border-bottom: 1px solid var(--border); }
.brand-icon {
  width: 42px; height: 42px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 6px 18px -6px rgba(99, 102, 241, 0.7);
}
.brand-icon svg { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-text h1 { font-size: 1rem; font-weight: 700; }
.brand-sub { font-size: 0.72rem; color: var(--text-secondary); }

.status-badge {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 99px;
  font-size: 0.78rem; font-weight: 600;
  color: #a7f3d0; background: var(--success-soft);
  border: 1px solid rgba(16, 185, 129, 0.3);
  transition: var(--t);
}
.status-badge::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: pulse 2s infinite;
}
.status-badge.off { color: #fca5a5; background: var(--danger-soft); border-color: rgba(239, 68, 68, 0.3); }
.status-badge.off::before { background: var(--danger); animation: none; box-shadow: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.tabs { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.tab {
  position: relative; display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 11px 14px; border: none; background: transparent;
  color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
  border-radius: var(--radius); cursor: pointer; text-align: start; transition: var(--t);
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab .tab-icon { display: grid; place-items: center; width: 20px; height: 20px; flex-shrink: 0; }
.tab .tab-icon svg { width: 19px; height: 19px; }
.tab.active {
  color: #fff; background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25), 0 6px 20px -12px rgba(99, 102, 241, 0.8);
}
.tab.active .tab-icon { color: var(--primary); }
.tab.active::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 50%;
  transform: translateY(-50%); width: 3px; height: 20px; border-radius: 99px;
  background: linear-gradient(180deg, var(--primary), var(--secondary));
}
.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--border); }

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 32px; background: rgba(10, 10, 12, 0.72);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar-title h2 { font-size: 1.15rem; font-weight: 700; }
.topbar-title .hint { margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.cmdk {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--elevated);
  color: var(--text-secondary); font-size: 0.8rem; cursor: pointer; transition: var(--t);
}
.cmdk:hover { border-color: var(--border-strong); color: var(--text); }
.cmdk svg { width: 15px; height: 15px; }
.cmdk kbd {
  font-family: inherit; font-size: 0.7rem; padding: 2px 6px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); color: var(--text-secondary);
}
.user-chip {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 12px 6px 6px; border-radius: 99px;
  background: var(--elevated); border: 1px solid var(--border);
  font-size: 0.85rem; font-weight: 500;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}
.menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--elevated);
  color: var(--text); cursor: pointer; transition: var(--t);
}
.menu-btn:hover { border-color: var(--border-strong); }
.menu-btn svg { width: 20px; height: 20px; }

/* ---------------- Cards ---------------- */
.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.card:last-child { margin-bottom: 0; }
.card > .hint { margin-bottom: 14px; }
.table-card { padding: 8px; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.data-table { width: 100%; min-width: 560px; border-collapse: separate; border-spacing: 0; font-size: 0.88rem; }
.data-table thead th {
  position: sticky; top: 0; z-index: 1; text-align: start;
  font-weight: 600; font-size: 0.76rem; letter-spacing: 0.02em; color: var(--text-secondary);
  padding: 14px 16px; background: var(--elevated); border-bottom: 1px solid var(--border);
}
.data-table thead th:first-child { border-start-start-radius: var(--radius); }
.data-table thead th:last-child { border-start-end-radius: var(--radius); }
.data-table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
.data-table tbody tr { transition: var(--t); }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.data-table tbody tr:last-child td { border-bottom: none; }
.kw-text { font-weight: 600; white-space: nowrap; }
.kw-response { color: var(--text-secondary); max-width: 420px; }
td.actions, .actions { display: flex; gap: 6px; white-space: nowrap; }

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 0; }
.field label { font-size: 0.82rem; font-weight: 500; color: var(--text-secondary); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 16px; }
input[type="text"], input[type="number"], input[type="password"], input[type="url"], input[type="email"], select,
textarea, #fallback-message, #follow-gate-message, #chat-input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-secondary);
  color: var(--text); font-size: 0.9rem; transition: var(--t); outline: none; resize: vertical;
}
.keyword-btn-row {
  display: grid;
  grid-template-columns: 155px 1fr 1.3fr auto;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
}
@media (max-width: 820px) {
  .keyword-btn-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
textarea { line-height: 1.7; min-height: 44px; }
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
input:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, textarea:focus { border-color: var(--primary); background: var(--elevated); box-shadow: 0 0 0 3px var(--primary-soft); }
input:invalid:not(:placeholder-shown) { border-color: rgba(239, 68, 68, 0.4); }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-row strong { font-weight: 600; font-size: 0.95rem; }
.switch-row .hint { margin-top: 4px; }

/* ---------------- Buttons ---------------- */
.btn {
  --btn-bg: var(--elevated);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 18px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: var(--t);
  white-space: nowrap; user-select: none; line-height: 1;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 8px 20px -10px rgba(99, 102, 241, 0.9); }
.btn.primary:hover { background: var(--primary-600); transform: translateY(-1px); box-shadow: 0 12px 26px -10px rgba(99, 102, 241, 0.95); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--border-strong); color: var(--text); }
.btn.success { background: var(--success); color: #04160f; }
.btn.success:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn.secondary { background: rgba(139, 92, 246, 0.16); color: #d6ccff; border-color: rgba(139, 92, 246, 0.3); }
.btn.secondary:hover { background: rgba(139, 92, 246, 0.24); }
.btn.full { width: 100%; }
.btn.small { padding: 6px 12px; font-size: 0.78rem; font-weight: 500; border-radius: var(--radius-sm); }
.actions .btn.ghost:last-child:hover { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); background: var(--danger-soft); }

/* ---------------- Toggles (iOS-style) ---------------- */
.switch { position: relative; display: inline-flex; align-items: center; width: 46px; height: 26px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; border-radius: 99px; background: rgba(255, 255, 255, 0.12); border: 1px solid var(--border); transition: var(--t); }
.switch .slider::before {
  content: ""; position: absolute; top: 50%; inset-inline-start: 3px; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 50%; background: #f8fafc; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); transition: var(--t);
}
.switch input:checked + .slider { background: var(--primary); border-color: transparent; box-shadow: 0 0 12px -2px rgba(99, 102, 241, 0.8); }
.switch input:checked + .slider::before { inset-inline-start: 23px; }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------------- Chat (priority) ---------------- */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 74px - 72px); min-height: 520px; }
.conversation-list { margin: 0; padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.conversation-item { position: relative; padding: 12px 14px; border-radius: var(--radius); cursor: pointer; transition: var(--t); border: 1px solid transparent; }
.conversation-item:hover { background: rgba(255, 255, 255, 0.04); }
.conversation-item.active { background: var(--primary-soft); border-color: rgba(99, 102, 241, 0.25); }
.conversation-item .c-name { font-weight: 600; font-size: 0.9rem; color: var(--text); margin-bottom: 2px; }
.conversation-item .c-username { font-size: 0.74rem; color: var(--primary); direction: ltr; text-align: start; margin-bottom: 4px; }
.conversation-item .c-preview { font-size: 0.8rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item .c-time { font-size: 0.7rem; color: var(--text-tertiary); margin-top: 6px; }
.chat-pane { margin: 0; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-back {
  display: none; align-items: center; gap: 6px; padding: 10px 16px;
  background: var(--elevated); border: none; border-bottom: 1px solid var(--border);
  color: var(--text-secondary); font-size: 0.82rem; font-weight: 500; cursor: pointer; width: 100%; text-align: start;
}
.chat-back svg { width: 16px; height: 16px; }
.chat-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02); min-height: 60px;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.chat-header > div:first-child { font-weight: 600; font-size: 0.95rem; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 4px;
  background: radial-gradient(600px 300px at 100% 0%, rgba(99, 102, 241, 0.05), transparent 60%);
}
.msg { display: flex; max-width: 78%; animation: bubbleIn 0.25s var(--ease); }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg.customer { align-self: flex-start; }
.msg.bot, .msg.admin { align-self: flex-end; }
.msg .bubble {
  position: relative;
  min-width: 96px;
  padding: 8px 12px 7px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.msg.customer .bubble { background: var(--elevated); border: 1px solid var(--border); border-start-start-radius: 4px; }
.msg.bot .bubble { background: var(--primary); color: #fff; border-end-end-radius: 4px; }
.msg.admin .bubble { background: rgba(139, 92, 246, 0.2); border: 1px solid rgba(139, 92, 246, 0.35); color: #ece8ff; border-end-end-radius: 4px; }
.msg .sender { display: block; font-size: 0.68rem; font-weight: 700; opacity: 0.85; margin-bottom: 2px; }
.msg .bubble-content {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.msg .bubble-text {
  flex: 1 1 auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg .time {
  align-self: flex-end;
  margin-inline-start: auto;
  font-size: 0.65rem;
  opacity: 0.7;
  direction: ltr;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.2;
}
.chat-send { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); background: rgba(255, 255, 255, 0.02); align-items: flex-end; }
.chat-send textarea { flex: 1; min-height: 44px; max-height: 140px; }
.chat-send .btn { flex-shrink: 0; }

/* ---------------- Products ---------------- */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.product-card { margin: 0; padding: 18px; display: flex; flex-direction: column; gap: 8px; transition: var(--t); }
.product-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.product-card .p-name { font-weight: 600; font-size: 1rem; }
.product-card .p-price { font-weight: 700; font-size: 0.95rem; color: var(--primary); }
.product-card .p-desc { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.7; flex: 1; min-height: 20px; }
.product-card .p-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--border); }
.product-card .p-stock { font-size: 0.78rem; font-weight: 600; color: #a7f3d0; background: var(--success-soft); border: 1px solid rgba(16, 185, 129, 0.25); padding: 4px 10px; border-radius: 99px; }

/* ---------------- Toast / Notification ---------------- */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  min-width: 290px;
  max-width: min(92vw, 440px);
  padding: 12px 22px;
  border-radius: 9999px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
  animation: toastSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  direction: rtl;
  text-align: center;
  pointer-events: none;
}
.toast.success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 30px rgba(16, 185, 129, 0.35), 0 0 20px rgba(16, 185, 129, 0.25);
}
.toast.error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(185, 28, 28, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 30px rgba(239, 68, 68, 0.35);
}
@keyframes toastSlideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -24px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

/* ---------------- Login overlay ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px;
  background: rgba(6, 6, 10, 0.7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.login-card {
  width: 100%; max-width: 380px; padding: 34px 30px; text-align: center;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border-strong); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); animation: fadeIn 0.3s var(--ease);
}
.login-logo {
  width: 60px; height: 60px; margin: 0 auto 16px; display: grid; place-items: center;
  border-radius: 18px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 12px 30px -10px rgba(99, 102, 241, 0.8);
}
.login-logo svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 6px; }
.login-card .hint { margin-bottom: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card #login-btn {
  padding: 12px; border-radius: var(--radius); border: none; background: var(--primary); color: #fff;
  font-size: 0.92rem; font-weight: 600; cursor: pointer; transition: var(--t); box-shadow: 0 8px 20px -10px rgba(99, 102, 241, 0.9);
}
.login-card #login-btn:hover { background: var(--primary-600); transform: translateY(-1px); }

/* ---------------- Utilities ---------------- */
.hidden { display: none !important; }
.scrim { display: none; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1024px) {
  .chat-layout { grid-template-columns: 280px 1fr; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .topbar { padding: 14px 18px; }
  .cmdk { display: none; }
  main { padding: 18px 16px 40px; }
  .sidebar {
    position: fixed; z-index: 120; top: 0; inset-inline-start: 0; height: 100vh;
    transform: translateX(110%); transition: transform 0.3s var(--ease); padding: 16px;
  }
  html[dir="rtl"] .sidebar { transform: translateX(110%); }
  .app-shell.drawer-open .sidebar { transform: translateX(0); }
  .app-shell.drawer-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 110;
    background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); animation: fadeIn 0.2s var(--ease);
  }
  .grid-2 { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; height: calc(100vh - 64px - 56px); }
  .chat-pane { display: none; }
  .chat-back { display: flex; }
  .app-shell.show-chat .conversation-list { display: none; }
  .app-shell.show-chat .chat-pane { display: flex; }
}
@media (max-width: 480px) {
  .topbar-title .hint { display: none; }
  .user-chip span:not(.user-avatar) { display: none; }
  .msg { max-width: 88%; }
  .card { padding: 16px; }
}
@media (min-width: 1600px) {
  main { max-width: 1360px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------- 3X-UI Style Stat Cards & Widgets ---------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--t);
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.5);
}
.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-title {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.04);
  color: var(--primary);
  border: 1px solid var(--border);
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.stat-sub {
  font-size: 0.74rem;
  color: var(--text-tertiary);
}
.stat-progress-track {
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.stat-progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.4s ease;
}

/* ---------------- 3X-UI Style Log Terminal ---------------- */
.log-console {
  background: #080c14;
  border: 1px solid #1e293b;
  border-radius: var(--radius);
  padding: 14px;
  height: 340px;
  overflow-y: auto;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-line { margin-bottom: 4px; }
.log-line.INFO { color: #38bdf8; }
.log-line.WARNING { color: #facc15; }
.log-line.ERROR { color: #f87171; }
.log-line.SUCCESS { color: #34d399; }