/* ===================================================================
   Garena & Game Tool Checker — Award-Winning Dark Console Theme
   Design standard: Linear.app / Raycast / Supabase caliber.
   Deep obsidian canvas, precision hairline bevels, executive typography.
   Zero AI slop, zero neon glow, zero tacky vibrating animations.
=================================================================== */

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

:root,
[data-theme="dark"] {
  /* Surfaces (High-End Machined Zinc) */
  --bg-app: #09090b;
  --bg-sidebar: #0e0e11;
  --bg-topbar: #0e0e11;
  --bg-card: #131317;
  --bg-card-hover: #18181d;
  --bg-input: #101014;
  --bg-pill: #1c1c22;
  --bg-table-header: #111115;
  --bg-modal: #141418;
  --bg-toast: #16161b;
  --bg-hover-row: rgba(255, 255, 255, 0.028);

  /* Hairline Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.045);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-dashed: rgba(255, 255, 255, 0.12);
  --border-dashed-hover: rgba(255, 255, 255, 0.25);
  --border-specular: rgba(255, 255, 255, 0.16);

  /* Typography */
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-faint: #52525b;

  /* Brand Accent: Sophisticated Wine Red (Solid, Non-Neon) */
  --accent: #9e1c38;
  --accent-hover: #b32242;
  --accent-active: #7d132a;
  --accent-subtle: rgba(158, 28, 56, 0.12);
  --accent-border: rgba(158, 28, 56, 0.28);

  /* Semantic Data Colors: Grounded & Crisp (WCAG compliant) */
  --success: #22c55e;
  --success-subtle: rgba(34, 197, 94, 0.10);
  --success-border: rgba(34, 197, 94, 0.22);

  --error: #ef4444;
  --error-subtle: rgba(239, 68, 68, 0.10);
  --error-border: rgba(239, 68, 68, 0.22);

  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.10);
  --warning-border: rgba(245, 158, 11, 0.22);

  --info: #38bdf8;
  --info-subtle: rgba(56, 189, 248, 0.10);
  --info-border: rgba(56, 189, 248, 0.22);

  /* Geometry & Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-pill: 9999px;

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Tactile Shadows (Zero AI Neon Glow) */
  --shadow-bevel: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-button: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  --shadow-modal: 0 16px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--border-strong);
  --shadow-input: inset 0 1px 2px rgba(0, 0, 0, 0.25);

  --badge-bg: rgba(255, 255, 255, 0.05);
  --badge-bg-active: rgba(255, 255, 255, 0.12);
  --modal-backdrop: rgba(0, 0, 0, 0.65);
  --bg-dropzone: rgba(255, 255, 255, 0.015);
  --bg-dropzone-hover: rgba(255, 255, 255, 0.035);
  --scrollbar-thumb: rgba(255, 255, 255, 0.10);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.18);
  --radial-glow: transparent;
}

[data-theme="light"] {
  /* Surfaces */
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-topbar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-pill: #e2e8f0;
  --bg-table-header: #f8fafc;
  --bg-modal: #ffffff;
  --bg-toast: #ffffff;
  --bg-hover-row: rgba(0, 0, 0, 0.02);

  /* Hairline Borders */
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-strong: #cbd5e1;
  --border-dashed: #cbd5e1;
  --border-dashed-hover: #94a3b8;
  --border-specular: #cbd5e1;

  /* Typography */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Brand Accent */
  --accent: #9e1c38;
  --accent-hover: #80142b;
  --accent-active: #660e21;
  --accent-subtle: rgba(158, 28, 56, 0.08);
  --accent-border: rgba(158, 28, 56, 0.22);

  /* Semantic Data Colors */
  --success: #16a34a;
  --success-subtle: rgba(22, 163, 74, 0.08);
  --success-border: rgba(22, 163, 74, 0.22);

  --error: #dc2626;
  --error-subtle: rgba(220, 38, 38, 0.08);
  --error-border: rgba(220, 38, 38, 0.22);

  --warning: #d97706;
  --warning-subtle: rgba(217, 119, 6, 0.08);
  --warning-border: rgba(217, 119, 6, 0.22);

  --info: #0284c7;
  --info-subtle: rgba(2, 132, 199, 0.08);
  --info-border: rgba(2, 132, 199, 0.22);

  /* Shadows */
  --shadow-bevel: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-button: 0 1px 2px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  --shadow-modal: 0 20px 40px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--border);
  --shadow-input: inset 0 1px 2px rgba(15, 23, 42, 0.03);

  --badge-bg: rgba(15, 23, 42, 0.05);
  --badge-bg-active: rgba(15, 23, 42, 0.10);
  --modal-backdrop: rgba(15, 23, 42, 0.35);
  --bg-dropzone: rgba(15, 23, 42, 0.015);
  --bg-dropzone-hover: rgba(15, 23, 42, 0.03);
  --scrollbar-thumb: rgba(15, 23, 42, 0.12);
  --scrollbar-thumb-hover: rgba(15, 23, 42, 0.22);
  --radial-glow: transparent;
}

html, body {
  height: 100%;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
}

.only-mobile {
  display: none !important;
}

/* ===================================================================
   MOBILE TOPBAR
=================================================================== */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
}

.mobile-menu-btn {
  position: relative;
}

.mobile-menu-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  font-size: 8.5px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0 4px;
  font-weight: 700;
  line-height: 12px;
  min-width: 12px;
  text-align: center;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-topbar-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  flex-shrink: 0;
}

.mobile-stop-btn {
  background: var(--error);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(244, 63, 94, 0.45);
  transition: transform 0.1s, opacity 0.15s;
}

.mobile-stop-btn:active {
  transform: scale(0.95);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background-color 0.15s;
}

.icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-pill);
}

.sidebar-mobile-links {
  display: none;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-link-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.sidebar-link-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* ===================================================================
   APP WORKSPACE LAYOUT (STUDIO WORKSPACE STANDARD)
=================================================================== */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-app);
}

/* ===================================================================
   MASTER TOPBAR (SLEEK, CLEAN, ZERO CLUTTER)
=================================================================== */
.master-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
  min-height: 46px;
  padding: 0 16px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}

.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: var(--badge-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ===================================================================
   WORKSPACE BODY (SPLIT SIDEBAR + RESULTS)
=================================================================== */
.workspace-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  width: 100%;
  position: relative;
}

/* ===================================================================
   SIDEBAR (FOCUSED INPUT PANEL)
=================================================================== */
.sidebar {
  width: 320px;
  min-width: 320px;
  max-width: 320px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 14px 12px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-head-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.icon-btn-subtle {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.icon-btn-subtle:hover {
  color: var(--text-primary);
  background: var(--bg-card);
  border-color: var(--border);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-right: 2px;
}

.sidebar-foot {
  flex-shrink: 0;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* ===================== BRAND ===================== */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  flex-shrink: 0;
  overflow: hidden;
}

[data-theme="light"] .brand-logo {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #0f172a;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-fallback-icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
  display: block;
}

[data-theme="light"] .brand-fallback-icon {
  color: var(--accent);
}

.brand-logo.sm {
  width: 26px;
  height: 26px;
  border-radius: 5px;
}

.brand-logo.sm .brand-fallback-icon {
  width: 15px;
  height: 15px;
}

.brand-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  font-weight: 500;
  text-transform: uppercase;
  margin-top: 1px;
}

/* ===================== SIDEBAR SECTIONS ===================== */
.side-section {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.side-section.grow {
  flex: 1;
  min-height: 130px;
}

.side-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.side-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.side-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

.side-hint code {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* ===================== INPUTS & TEXTAREA ===================== */
.input, .textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-input);
  color: var(--text-primary);
  padding: 8.5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  outline: none;
  font-family: var(--font-ui);
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.input::placeholder, .textarea::placeholder {
  color: var(--text-faint);
}

.input:hover, .textarea:hover {
  border-color: var(--border-strong);
}

.input:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 16px -2px rgba(179, 29, 63, 0.35);
  background: var(--bg-card);
}

.input-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ===================== CHANGE PASSWORD SECTION ===================== */
.change-pass-tabs {
  display: flex;
  gap: 3px;
  background: var(--bg-card);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 2px;
}

.change-pass-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.change-pass-tab:hover {
  color: var(--text-primary);
}

.change-pass-tab.active {
  background: var(--bg-input);
  color: var(--text-primary);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.input-with-actions {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-actions .input {
  padding-right: 62px;
}

.input-actions-group {
  position: absolute;
  right: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.input-action-btn {
  width: 25px;
  height: 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.input-action-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.input-action-btn.sm {
  width: 22px;
  height: 22px;
}

/* Random Password Card */
.random-pass-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.random-pass-info-text {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.random-pass-info-text svg {
  color: var(--accent);
  flex-shrink: 0;
}

.random-preview-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.5px;
  word-break: break-all;
}

.new-pass-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.new-pass-badge:hover {
  background: rgba(34, 197, 94, 0.2);
  border-color: var(--success);
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.input-error-shake {
  animation: inputShake 0.4s ease-in-out;
  border-color: var(--error) !important;
}

.textarea {
  flex: 1;
  min-height: 120px;
  resize: none;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
}

/* Drag overlay on textarea */
.drag-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 11, 16, 0.94);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(2px);
}

.drag-overlay.show {
  display: flex;
}

.drag-overlay-text {
  font-weight: 650;
  color: var(--accent);
  font-size: 13px;
}

/* ===================================================================
   DEDICATED DRAG & DROP ZONE
=================================================================== */
.dropzone-box {
  border: 1.5px dashed var(--border-dashed);
  border-radius: var(--radius-sm);
  background: var(--bg-dropzone);
  padding: 10px 12px;
  margin-top: 6px;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
  user-select: none;
  position: relative;
}

.dropzone-box:hover {
  border-color: var(--border-dashed-hover);
  background: var(--bg-dropzone-hover);
}

.dropzone-box.drag-over {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.dropzone-idle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dropzone-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: color 0.18s, border-color 0.18s;
}

.dropzone-box.drag-over .dropzone-icon {
  color: var(--accent);
  border-color: var(--accent-border);
}

.dropzone-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dropzone-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.dropzone-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

.dropzone-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* Active Drag State */
.dropzone-active-state {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  padding: 5px 0;
}

.dropzone-box.drag-over .dropzone-idle {
  display: none;
}

.dropzone-box.drag-over .dropzone-active-state {
  display: flex;
}

.dropzone-box.drag-over .dropzone-file-card {
  display: none !important;
}

.dropzone-box.has-file {
  border: none;
  padding: 0;
  background: transparent;
  cursor: default;
}

.dropzone-box.has-file:hover {
  background: transparent;
  border-color: transparent;
}

/* File Loaded State Card - Single Unified Card */
.dropzone-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  box-shadow: none !important;
  transition: border-color 0.18s ease;
}

.dropzone-file-card:hover {
  border-color: var(--accent-border);
}

.loaded-file-icon {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.loaded-file-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.loaded-file-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

.loaded-file-meta {
  font-size: 10.5px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.loaded-file-meta .remaining-count {
  color: var(--accent);
  font-weight: 600;
}

.loaded-file-remove {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.loaded-file-remove:hover {
  color: var(--error);
  background: var(--error-subtle);
  border-color: rgba(248, 113, 113, 0.25);
}

/* ===================== BUTTONS ===================== */
.btn-group {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.15s ease;
  flex: 1;
  font-family: var(--font-ui);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-sm {
  padding: 7px 11px;
  font-size: 12px;
  flex: none;
  width: 100%;
  margin-top: 6px;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
  transform: scale(0.98);
}

.btn-danger {
  background: var(--bg-card);
  color: #f87171;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-bevel);
  font-weight: 600;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.30);
  color: #fca5a5;
}

.btn-danger:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-ghost {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-bevel);
  width: 100%;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}

.btn-mini {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.btn-mini:hover {
  color: var(--text-primary);
  background: var(--bg-pill);
}

/* ===================================================================
   MAIN PANEL & TOPBAR
=================================================================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-app);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-topbar);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-bevel);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.topbar-link:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

#statEta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-idle {
  background: #22c55e;
}

.dot-running {
  background: var(--info);
}

.dot-stopped {
  background: var(--error);
}

/* ===================================================================
   SIDEBAR UTILITIES & COMPACT CONTROLS
=================================================================== */
.side-label-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-text-subtle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 1px 7px;
  line-height: 18px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.12s ease;
}

.btn-text-subtle:hover {
  background: var(--bg-pill);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.dropzone-compact {
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px dashed var(--border-dashed);
  border-radius: var(--radius-sm);
  background: var(--bg-dropzone);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  min-height: unset;
}

.dropzone-compact:hover {
  border-color: var(--border-dashed-hover);
  background: var(--bg-dropzone-hover);
  color: var(--text-primary);
}

.dropzone-compact .dropzone-idle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
}

.dropzone-compact .dropzone-text-line b {
  color: var(--text-primary);
}

.dropzone-compact .dropzone-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

.btn-run {
  flex: 1 1 auto;
  height: 38px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap !important;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-run:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-stop {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 68px !important;
  height: 38px;
  padding: 0 14px !important;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.sidebar-brand-sig {
  text-align: center;
  padding-top: 8px;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.sidebar-brand-sig b {
  color: var(--text-muted);
  font-weight: 600;
}

/* ===================================================================
   UNIFIED RESULTS TOOLBAR (SLIM, ELEGANT, NON-REDUNDANT)
=================================================================== */
.results-toolbar {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-table-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.filter-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.filter-tab:hover {
  color: var(--text-primary);
  background: var(--bg-pill);
}

.filter-tab.active {
  background: var(--bg-pill);
  color: var(--text-primary);
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-bevel);
}

.tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tab-dot.hit { background: var(--success); }
.tab-dot.fail { background: var(--error); }
.tab-dot.reload { background: var(--warning); }

.tab-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--badge-bg);
  color: var(--text-muted);
  font-family: var(--font-mono);
  line-height: 14px;
}

.filter-tab.active .tab-badge {
  background: var(--badge-bg-active);
  color: var(--text-primary);
}

.tab-badge.hit { color: var(--success); }
.tab-badge.fail { color: var(--error); }
.tab-badge.reload { color: var(--warning); }

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.run-stats {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.run-stat-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-num {
  font-weight: 600;
  color: var(--text-primary);
}

.stat-unit {
  font-size: 10px;
  color: var(--text-muted);
}

.run-stat-sep {
  color: var(--border-strong);
  font-size: 12px;
}

.toolbar-right #btnExport {
  width: auto !important;
  margin: 0 !important;
  height: 28px !important;
  padding: 0 11px !important;
  font-size: 11.5px !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  flex-shrink: 0 !important;
  border-radius: var(--radius-sm);
}

/* ===================================================================
   DATA GRID (ENTERPRISE CONSOLE TABLE)
=================================================================== */
.results-wrap {
  flex: 1;
  overflow: auto;
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--bg-app);
  position: relative;
  min-height: 0;
  contain: paint layout;
}

/* Single Central Watermark Canvas */
.watermark-canvas {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  overflow: hidden;
}

.watermark-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  opacity: 0.045;
  transform: rotate(-7deg);
  transition: opacity 0.2s ease;
}

[data-theme="light"] .watermark-inner {
  opacity: 0.052;
}

.watermark-inner svg {
  color: var(--accent);
  filter: drop-shadow(0 0 20px rgba(158, 28, 56, 0.3));
}

.watermark-text {
  font-family: var(--font-mono);
  font-size: 58px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.results-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: auto;
}

.results-table thead th {
  white-space: nowrap;
  text-align: left;
  padding: 8px 12px;
  background: var(--bg-table-header);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.results-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
}

.results-table th.col-idx,
.results-table td.col-idx {
  width: 65px !important;
  min-width: 65px !important;
  max-width: 65px !important;
  padding: 7px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  text-align: left;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  border-right: 1px solid var(--border-subtle);
}

.cell-ellipsis {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-table tbody tr {
  transition: background-color 0.08s ease;
}

.results-table tbody tr:hover {
  background: var(--bg-hover-row);
}

.results-table tbody tr:hover td.col-idx {
  color: var(--text-secondary);
}

@keyframes hit-glow {
  0% {
    background-color: rgba(34, 197, 94, 0.15);
  }
  100% {
    background-color: transparent;
  }
}

.row-hit-flash {
  animation: hit-glow 1s ease forwards;
}

/* Status Chips - Clean, minimal, crisp */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.2;
}

.status-chip::before {
  content: "";
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-success {
  background: rgba(34, 197, 94, 0.10);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.22);
}

.status-error {
  background: rgba(239, 68, 68, 0.10);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.22);
}

.status-reload {
  background: rgba(245, 158, 11, 0.10);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.22);
}

/* Empty State - Architectural & Non-AI */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 10px;
  text-align: center;
  padding: 48px 20px;
  font-size: 12.5px;
  user-select: none;
}

.empty-state.show {
  display: flex;
}

.empty-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}

.empty-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.empty-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 320px;
}

.btn-sample-data {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s ease;
  margin-top: 4px;
  font-family: var(--font-ui);
}

.btn-sample-data:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-sample-data:active {
  transform: scale(0.98);
}

/* ===================================================================
   MODALS (EXPORT & GUIDE)
=================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.24s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: all;
  visibility: visible;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.modal-backdrop.show .modal {
  transform: scale(1) translateY(0);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-weight: 650;
  font-size: 14px;
  color: var(--text-primary);
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Export Modal */
.export-modal-body {
  padding: 16px 18px;
}

.export-section-label {
  font-size: 11px;
  font-weight: 650;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.export-format-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.export-fmt-btn {
  flex: 1;
  padding: 8px 0;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-bevel);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s, transform 0.12s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.export-fmt-btn:active {
  transform: scale(0.97);
}

.export-fmt-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.export-fmt-btn.active {
  background: var(--bg-pill);
  border-color: var(--accent);
  color: var(--accent);
}

.export-multi-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.export-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.export-type-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-bevel);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.export-type-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.export-type-card:active {
  transform: scale(0.98);
}

.export-type-card.selected {
  background: var(--bg-card-hover);
  border-color: var(--accent-border);
}

.export-type-card.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.export-type-card.all-card {
  grid-column: 1 / -1;
}

.export-type-info {
  flex: 1;
  min-width: 0;
}

.export-type-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.export-type-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
  font-family: var(--font-mono);
}

.check-mark {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.export-type-card.selected .check-mark {
  background: var(--accent);
  border-color: var(--accent);
}

.export-type-card.selected .check-mark::after {
  content: '✓';
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
}

.export-confirm-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.btn-copy {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-bevel);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-copy:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-copy:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.dot-mini {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}

.dot-mini.c-green { color: var(--success); }
.dot-mini.c-red { color: var(--error); }
.dot-mini.c-yellow { color: var(--warning); }
.dot-mini.c-dim { color: var(--text-muted); }

/* ===== Session Choice Modal ===== */
.session-modal {
  max-width: 440px;
}

.session-modal .modal-head {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
}

.session-modal .modal-title {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 650;
  color: var(--text-primary);
  width: auto;
  margin: 0 auto;
}

.session-modal .modal-title svg {
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.session-modal-body {
  padding: 16px 20px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.session-modal-intro {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Thống kê chi tiết Hits / Fails / Reloads / Chưa check */
.session-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.session-stat-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-bevel);
}

.session-stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.session-stat-dot.c-green { background: var(--success); }
.session-stat-dot.c-red { background: var(--error); }
.session-stat-dot.c-yellow { background: var(--warning); }
.session-stat-dot.c-info { background: var(--info); }

.session-stat-pill-label {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}

.session-stat-pill-val {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.session-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-opt-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
  position: relative;
  font-family: inherit;
}

.session-opt-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.session-opt-btn.primary {
  border-color: var(--accent-border);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(179, 29, 63, 0.08) 100%);
}

.session-opt-btn.primary:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--bg-card-hover) 0%, rgba(179, 29, 63, 0.16) 100%);
}

.session-opt-btn.secondary {
  border-color: var(--border);
  background: var(--bg-card);
}

.session-opt-btn.secondary:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.session-opt-btn.danger {
  border-color: var(--border);
}

.session-opt-btn.danger:hover {
  border-color: var(--error-border);
  background: linear-gradient(135deg, var(--bg-card-hover) 0%, rgba(244, 63, 94, 0.08) 100%);
}

.session-opt-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.session-opt-btn.primary .session-opt-icon {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(179, 29, 63, 0.35);
}

.session-opt-btn.secondary .session-opt-icon {
  background: var(--bg-pill);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.session-opt-btn.secondary:hover .session-opt-icon {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.session-opt-btn.danger .session-opt-icon {
  background: var(--bg-pill);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.session-opt-btn.danger:hover .session-opt-icon {
  background: var(--error-subtle);
  color: var(--error);
  border-color: var(--error-border);
}

.badge-rec {
  position: absolute;
  top: 10px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.35px;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(179, 29, 63, 0.16);
  color: #ff5277;
  border: 1px solid rgba(255, 82, 119, 0.55);
  box-shadow: 0 1px 4px rgba(179, 29, 63, 0.22);
  user-select: none;
  pointer-events: none;
  text-transform: uppercase;
  transition: all 0.16s ease;
}

[data-theme="light"] .badge-rec {
  background: rgba(179, 29, 63, 0.08);
  color: var(--accent);
  border-color: rgba(179, 29, 63, 0.45);
}

.session-opt-btn.primary:hover .badge-rec {
  background: rgba(179, 29, 63, 0.25);
  border-color: rgba(255, 82, 119, 0.85);
  box-shadow: 0 1px 6px rgba(179, 29, 63, 0.35);
}

.session-opt-btn.primary .session-opt-title {
  padding-right: 68px;
}

.session-opt-text {
  flex: 1;
  min-width: 0;
}

.session-opt-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.session-opt-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: 4px;
}

.session-opt-desc b {
  color: var(--text-primary);
  font-weight: 600;
}

/* Guide Modal */
.modal-wide { max-width: 540px; }
.modal-tall { max-height: 85vh; }
.guide-body { max-height: 65vh; }
.guide-section { margin-bottom: 16px; }
.guide-section:last-of-type { margin-bottom: 6px; }

.guide-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.guide-num {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background: var(--bg-pill);
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

.guide-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 6px;
}

.guide-text b {
  color: var(--text-primary);
}

.guide-text code {
  background: var(--bg-card);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.guide-example {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.guide-status-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}

.guide-status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.guide-status-item .status-chip {
  flex-shrink: 0;
}

.guide-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

/* ===================================================================
   TOAST NOTIFICATION
=================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-toast);
  border: 1px solid var(--border-strong);
  border-left: 3.5px solid var(--text-muted);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border);
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
  pointer-events: none;
  z-index: 100000;
  max-width: 380px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.12);
}

.toast.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.toast.error {
  border-left-color: var(--error);
}

.toast.success {
  border-left-color: var(--success);
}

/* ===================================================================
   SCROLLBAR
=================================================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ===================================================================
   APP INITIAL LOADING SCREEN
=================================================================== */
.app-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: all;
  user-select: none;
  transition: opacity 0.25s ease, visibility 0.25s;
  visibility: visible;
  opacity: 1;
}

.app-loading-screen.loaded {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.loading-spinner {
  width: 26px;
  height: 26px;
  border: 2px solid var(--bg-pill);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.loading-text {
  font-size: 12.5px;
  font-family: var(--font-ui);
  color: var(--text-secondary);
  font-weight: 500;
}

.loading-error-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 360px;
  text-align: center;
}

.loading-error-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--error);
}

.loading-error-msg {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.loading-error-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ===================================================================
   RESPONSIVE (TABLET & MOBILE)
=================================================================== */
@media (max-width: 1024px) {
  .stat-strip {
    grid-template-columns: 145px repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-app) !important;
  }

  .only-mobile {
    display: flex !important;
  }

  /* TOPBAR: Chỉ hiển thị thanh mobile duy nhất, gọn gàng và tinh tế */
  .mobile-topbar {
    display: flex;
    height: 48px;
    padding: 6px 14px;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .mobile-menu-btn {
    width: 36px;
    height: 36px;
    padding: 7px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
  }

  .mobile-topbar-actions {
    display: flex;
    align-items: center;
    gap: 5px;
  }

  .mobile-topbar-actions .icon-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
  }

  .master-topbar,
  .main .topbar,
  .topbar {
    display: none !important;
  }

  .app {
    height: calc(100% - 48px);
    height: calc(100dvh - 48px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .workspace-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    min-height: 0;
  }

  .main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
  }

  /* SIDEBAR: Drawer toàn màn hình cao, bo góc phải, mượt mà chuẩn native */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(340px, 86vw);
    min-width: unset;
    z-index: 999;
    visibility: hidden;
    pointer-events: none;
    box-shadow: none !important;
    border-right: 1px solid var(--border);
    border-radius: 0 16px 16px 0;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
  }

  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    display: block;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    pointer-events: all;
  }

  .sidebar-scroll {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    gap: 12px;
    overflow-y: auto;
  }

  .sidebar-head {
    padding: 12px 14px;
  }

  .side-section {
    margin-bottom: 0;
  }

  .side-section.grow {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 180px;
  }

  /* Textarea account co giãn tự nhiên theo chiều cao như bản PC */
  .textarea {
    flex: 1;
    min-height: 160px;
    height: auto !important;
    max-height: none !important;
    padding: 10px 12px;
    font-size: 12px;
    border-radius: 8px;
  }

  .side-hint {
    font-size: 10.5px;
    margin: 4px 0 6px;
    line-height: 1.4;
  }

  /* Dropzone trên mobile: đồng bộ chuẩn đẹp như PC */
  .dropzone-box {
    padding: 9px 12px;
    border: 1.5px dashed var(--border-dashed);
    border-radius: 8px;
    background: var(--bg-dropzone);
    min-height: unset;
    margin-top: 4px;
    cursor: pointer;
  }

  .dropzone-idle {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    justify-content: center;
  }

  .dropzone-icon {
    margin-bottom: 0;
    color: var(--accent);
  }

  .dropzone-title {
    display: inline;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-primary);
  }

  .dropzone-sub {
    display: inline;
    font-size: 11.5px;
    color: var(--text-muted);
  }

  .dropzone-link {
    display: inline;
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
  }

  .sidebar-foot {
    padding: 10px 14px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
  }

  .btn-group {
    display: flex;
    flex-direction: row;
    gap: 8px;
  }

  #btnStart {
    flex: 2;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 8px;
  }

  #btnStop {
    flex: 1;
    padding: 10px 10px;
    font-size: 12px;
    border-radius: 8px;
  }

  #btnExport {
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 8px;
    margin-top: 6px;
    width: 100%;
  }

  .sidebar-mobile-links {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
  }

  .sidebar-link-btn {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 6px;
  }

  /* ===================================================================
     STAT STRIP TRÊN MOBILE:
     - Card 1 (Tiến độ): Hero Banner ngang ở trên (100% width)
     - 6 Cards còn lại: Lưới 3 cột x 2 hàng cân đối 100%
  =================================================================== */
  .stat-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin: 8px 10px 0;
    flex-shrink: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }

  .stat-strip .strip-ring {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 8px 12px;
    min-height: 52px;
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }

  .stat-strip .strip-cell {
    min-width: 0;
    padding: 7px 4px 6px;
    min-height: 50px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
  }

  .strip-icon {
    display: none;
  }

  .stat-label {
    order: 1;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .stat-value {
    order: 2;
    font-size: 17px;
    line-height: 1.1;
    font-weight: 700;
    font-family: var(--font-mono);
  }

  #statEta {
    display: block;
    font-size: 8.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
  }

  .ring {
    width: 58px;
    height: 58px;
    flex-shrink: 0;
  }

  .ring-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #ringPercent {
    font-size: 15px;
    font-weight: 800;
    font-family: var(--font-mono);
  }

  .strip-ring .ring-label {
    display: none;
  }

  .strip-ring-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .strip-ring-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
  }

  .strip-ring-sub {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-top: 3px;
    font-family: var(--font-mono);
  }

  /* Filter bar & table */
  .filter-bar {
    padding: 6px 10px 4px;
    gap: 6px;
    flex-direction: column;
    align-items: stretch;
    flex-shrink: 0;
  }

  .filter-tabs {
    display: flex;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    box-shadow: var(--shadow-bevel);
  }

  .filter-tab {
    flex: 1;
    justify-content: center;
    padding: 5px 2px;
    font-size: 11px;
    gap: 4px;
    border-radius: 4px;
    border: 1px solid transparent;
  }

  .filter-tab.active {
    background: var(--bg-pill);
    border-color: var(--border-subtle);
  }

  .tab-badge {
    font-size: 9.5px;
    padding: 1px 4px;
  }

  .search-wrap {
    width: 100%;
    margin-left: 0;
  }

  .search-box {
    width: 100%;
    height: 32px;
    padding: 5px 10px 5px 28px;
    font-size: 11.5px;
    border-radius: var(--radius-sm);
  }

  .results-wrap {
    flex: 1 1 auto;
    min-height: 0;
    margin: 4px 10px 10px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    position: relative;
    box-shadow: var(--shadow-bevel);
  }

  .results-table {
    min-width: 620px;
    font-size: 11.5px;
    border-collapse: separate;
    border-spacing: 0;
  }

  .results-table thead th {
    padding: 8px 10px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-table-header);
    border-bottom: 1px solid var(--border);
  }

  .results-table td {
    padding: 7px 10px;
    font-size: 11.5px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-subtle);
  }

  .results-table th.col-idx,
  .results-table td.col-idx {
    position: sticky;
    left: 0;
    width: 46px !important;
    min-width: 46px !important;
    max-width: 46px !important;
    padding: 7px 4px;
    text-align: center;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    box-shadow: none;
    z-index: 3;
    color: var(--text-muted);
  }

  .results-table thead th.col-idx {
    z-index: 5;
    background: var(--bg-table-header);
    border-right: 1px solid var(--border);
  }

  .cell-ellipsis {
    max-width: 120px;
  }

  .empty-state {
    padding: 32px 14px;
    gap: 10px;
  }
}

@media (max-width: 520px) {
  .btn-group {
    flex-direction: column;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal {
    max-width: 100%;
    max-height: 94vh;
  }

  .export-type-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .export-confirm-bar {
    flex-wrap: wrap;
  }

  .export-confirm-bar button {
    flex: 1 1 45%;
  }
}

@media (max-width: 380px) {
  .stat-strip {
    gap: 4px;
    margin: 6px 6px 0;
  }

  .strip-ring,
  .strip-cell {
    padding: 5px 4px;
  }

  .stat-value {
    font-size: 13px;
  }

  .stat-label {
    font-size: 8px;
  }

  .results-wrap {
    margin: 4px 6px 6px;
  }
}

/* Hiệu ứng phản hồi xúc giác thị giác khi click copy ô dữ liệu */
@keyframes cellCopiedPulse {
  0% {
    background-color: rgba(16, 185, 129, 0.45);
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.6);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
  }
}

.cell-copied-flash {
  animation: cellCopiedPulse 0.5s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
