/* =========================================================
   Apple check coverage — Design tokens (primitive → semantic → component)
   Source: design-system/apple-check-bh/MASTER.md
   Style: Soft UI Evolution · Light
   ========================================================= */

@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

/* --- Primitive --- */
:root {
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-300: #5eead4;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;

  --orange-50: #fff7ed;
  --orange-600: #ea580c;
  --orange-700: #c2410c;

  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-600: #dc2626;
  --red-700: #b91c1c;

  --green-50: #ecfdf5;
  --green-100: #d1fae5;
  --green-700: #047857;

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-800: #1e293b;

  --white: #ffffff;

  --font-sans: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgb(19 78 74 / 0.06);
  --shadow-md: 0 4px 12px rgb(19 78 74 / 0.08);
  --shadow-lg: 0 12px 28px rgb(19 78 74 / 0.1);

  --duration: 200ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --touch-min: 44px;
}

/* --- Semantic --- */
:root {
  --color-background: var(--teal-50);
  --color-surface: var(--white);
  --color-foreground: var(--teal-900);
  --color-muted-fg: var(--slate-500);
  --color-muted: #e8f1f4;
  --color-border: var(--teal-200);
  --color-border-strong: var(--teal-300);

  --color-primary: var(--teal-600);
  --color-primary-hover: var(--teal-700);
  --color-on-primary: var(--white);
  --color-secondary: var(--teal-500);
  --color-accent: var(--orange-600);
  --color-accent-hover: var(--orange-700);
  --color-on-accent: var(--white);

  --color-success: var(--green-700);
  --color-success-bg: var(--green-50);
  --color-success-border: var(--green-100);
  --color-destructive: var(--red-600);
  --color-destructive-bg: var(--red-50);
  --color-destructive-border: var(--red-100);

  --color-ring: var(--teal-600);

  --typography-font: var(--font-sans);
  --typography-heading: var(--font-sans);
}

/* --- Component --- */
:root {
  --button-bg: var(--color-accent);
  --button-fg: var(--color-on-accent);
  --button-hover-bg: var(--color-accent-hover);
  --button-radius: var(--radius-sm);
  --button-padding-y: 0.75rem;
  --button-padding-x: 1.25rem;
  /* Shared width for the quick-check scan button and the Choose file /
     Stop / Resume action button so both rows line up. */
  --action-btn-width: 9.5rem;

  --panel-bg: var(--color-surface);
  --panel-border: var(--color-border);
  --panel-radius: var(--radius-lg);
  --panel-padding: var(--space-lg);
  --panel-shadow: var(--shadow-md);

  --input-border: var(--slate-200);
  --input-radius: var(--radius-sm);
  --input-focus-ring: 0 0 0 3px rgb(13 148 136 / 0.2);

  --progress-track: var(--slate-100);
  --progress-fill-from: var(--teal-600);
  --progress-fill-to: var(--teal-500);

  --metric-bg: rgb(240 253 250 / 0.7);
  --code-bg: var(--slate-100);
}

/* --- Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--typography-font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-foreground);
  background:
    radial-gradient(1100px 520px at 8% -8%, rgb(153 246 228 / 0.55) 0%, transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgb(255 237 213 / 0.55) 0%, transparent 50%),
    linear-gradient(180deg, var(--teal-50) 0%, var(--slate-50) 100%);
  background-attachment: fixed;
  /* Safety net: no stray horizontal scroll from nowrap items on small screens */
  overflow-x: clip;
}

@media (max-width: 820px) {
  body {
    /* iOS Safari repaints badly with fixed backgrounds */
    background-attachment: scroll;
  }
}

a {
  color: var(--color-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--duration) var(--ease);
}

a:hover {
  color: var(--color-primary-hover);
}

:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Layout --- */
.page {
  max-width: 920px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-3xl);
}

.page-wide {
  max-width: none;
  width: 100%;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

@media (min-width: 768px) {
  .page {
    padding: var(--space-xl) var(--space-lg) 5rem;
  }

  .page-wide {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* --- Top utility row (language switch) --- */
.top-utility {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: var(--space-xs) 0 0;
  margin-bottom: calc(var(--space-sm) * -1);
}

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  padding: var(--space-sm) 0;
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.about-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  background: var(--orange-50, #fff7ed);
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.about-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.about-link:hover {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: var(--touch-min);
  color: var(--color-foreground);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand:hover {
  color: var(--color-foreground);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

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

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text small {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted-fg);
}

.brand-text span {
  font-size: 0.9375rem;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: var(--space-sm);
  }
  .brand-text span {
    white-space: normal;
  }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 36px;
  min-width: 7rem;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-muted-fg);
  white-space: nowrap;
  flex-shrink: 0;
}

.status-pill[data-state="running"] {
  color: var(--color-success);
  border-color: var(--color-success-border);
  background: var(--color-success-bg);
}

.status-pill[data-state="error"] {
  color: var(--color-destructive);
  border-color: var(--color-destructive-border);
  background: var(--color-destructive-bg);
}

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

.status-pill[data-state="running"] .status-dot {
  animation: pulse-dot 1.4s var(--ease) infinite;
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.85);
  }
}

/* --- Hero --- */
.hero {
  margin-bottom: var(--space-xl);
  animation: fade-up 0.4s var(--ease) both;
}

.hero h1 {
  margin: 0 0 var(--space-sm);
  font-family: var(--typography-heading);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
  color: var(--color-foreground);
}

.sub {
  margin: 0;
  max-width: 52ch;
  color: var(--color-muted-fg);
  font-size: 1.0625rem;
}

.sub strong {
  color: var(--color-success);
  font-weight: 600;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  align-items: stretch;
}

.hero-actions .hero-cta,
.hero-actions .btn {
  flex: 1 1 11.5rem;
  min-width: 11.5rem;
  max-width: 18rem;
  margin-top: 0;
  min-height: 2.75rem;
  box-sizing: border-box;
  white-space: nowrap;
}

.hero-actions .btn.ghost {
  margin-top: 0;
}

/* --- Metrics strip --- */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  animation: fade-up 0.45s var(--ease) 0.05s both;
}

@media (max-width: 900px) {
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .metrics {
    grid-template-columns: 1fr;
  }
}

.metric {
  background: var(--metric-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  backdrop-filter: blur(8px);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 var(--space-xs);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted-fg);
}

.metric-label svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.metric-value {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.metric-value-text {
  font-size: 1.05rem;
  word-break: break-word;
}

.metric-hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--color-muted-fg);
}

.metric-value.warn {
  color: var(--color-destructive);
}

.metric-capacity {
  border-color: rgb(13 148 136 / 0.35);
}

.capacity-values {
  display: grid;
  gap: 0.3rem;
}

.capacity-values p {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-muted-fg);
}

.capacity-values strong {
  font-size: 1.05rem;
  color: var(--color-fg);
}

/* --- VPS load alert (admin dashboard) --- */
.metric-sysload {
  border-color: rgb(37 99 235 / 0.3);
}

.metric-host {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted-fg);
  word-break: break-all;
}

.metric-sysload-alert {
  border-color: var(--color-destructive);
  background: var(--color-destructive-bg);
}

.capacity-values strong.sys-over {
  color: var(--color-destructive);
}

.sysload-banner {
  margin-bottom: var(--space-md);
  padding: 0.7rem 1rem;
  border: 1px solid var(--color-destructive-border);
  border-left: 4px solid var(--color-destructive);
  border-radius: 8px;
  background: var(--color-destructive-bg);
  color: var(--color-destructive);
  font-size: 0.9rem;
}

.sysload-banner-hint {
  color: var(--color-muted-fg);
}

/* --- 24h server load / scan volume chart (admin dashboard) --- */
.sysload-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 0 0 var(--space-sm);
  font-size: 0.8rem;
  color: var(--color-muted-fg);
}

.sysload-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.sysload-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.sysload-legend-swatch.swatch-cpu {
  background: var(--orange-600);
}

.sysload-legend-swatch.swatch-ram {
  background: var(--teal-600);
}

.sysload-legend-swatch.swatch-imei {
  background: rgb(20 184 166 / 0.3);
}

.sysload-chart-wrap {
  width: 100%;
  overflow: hidden;
}

.sysload-chart-wrap canvas {
  display: block;
  width: 100%;
}

/* --- Cookie consent (GA4 Consent Mode v2) --- */
.cookie-consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0));
  background: rgb(15 23 42 / 0.92);
  color: #f8fafc;
  box-shadow: 0 -8px 28px rgb(15 23 42 / 0.22);
}

.cookie-consent-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
}

.cookie-consent-title {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.cookie-consent-text {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #cbd5e1;
  max-width: 42rem;
}

.cookie-consent-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.cookie-consent-actions .ghost {
  color: #e2e8f0;
  border-color: rgb(148 163 184 / 0.45);
  margin-top: 0;
}

.cookie-consent-actions .ghost:hover {
  background: rgb(148 163 184 / 0.15);
}

/* --- Admin website traffic panel --- */
.panel-web-traffic .traffic-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0 0 var(--space-md);
}

.traffic-kpi {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  background: var(--color-muted-bg, rgb(248 250 252));
}

.traffic-kpi-label {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted-fg);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.traffic-kpi-value {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}

.traffic-kpi-hint {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--color-muted-fg);
}

.traffic-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.traffic-chart-wrap {
  width: 100%;
  min-height: 220px;
  overflow: hidden;
}

.traffic-chart-wrap canvas {
  display: block;
  width: 100%;
}

.traffic-lists {
  display: grid;
  gap: 0.85rem;
}

.traffic-list h3 {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.traffic-list ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.traffic-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--panel-border);
  font-size: 0.85rem;
}

.traffic-list li:last-child {
  border-bottom: 0;
}

.traffic-list .traffic-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.traffic-list .traffic-count {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--color-muted-fg);
}

.traffic-status {
  margin: 0.35rem 0 0;
}

.traffic-status.err {
  color: var(--color-destructive);
}

.panel-head-actions.panel-head-traffic {
  align-items: center;
}

@media (max-width: 900px) {
  .panel-web-traffic .traffic-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .traffic-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .panel-web-traffic .traffic-kpis {
    grid-template-columns: 1fr;
  }
}

/* --- Panels (interaction containers) --- */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--panel-radius);
  padding: var(--panel-padding);
  margin-bottom: var(--space-md);
  box-shadow: var(--panel-shadow);
  animation: fade-up 0.45s var(--ease) both;
}

.panel:nth-of-type(1) {
  animation-delay: 0.08s;
}
.panel:nth-of-type(2) {
  animation-delay: 0.12s;
}
.panel:nth-of-type(3) {
  animation-delay: 0.16s;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.panel-title .step {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--teal-100);
  color: var(--teal-700);
  font-size: 0.8125rem;
  font-weight: 700;
  flex-shrink: 0;
}

.panel-title svg {
  width: 20px;
  height: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.elapsed-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 5.5rem;
  min-height: 32px;
  justify-content: center;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--teal-50);
  color: var(--teal-700);
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.elapsed-timer svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.hint {
  margin: 0 0 var(--space-md);
  color: var(--color-muted-fg);
  font-size: 0.875rem;
}

.hint code,
.err code,
.metric-hint code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  background: var(--code-bg);
  color: var(--slate-800);
  padding: 0.1rem 0.4rem;
  border-radius: 0.35rem;
  border: 1px solid var(--slate-200);
}

/* --- Upload --- */
.upload {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: stretch;
}

.worker-config {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm) var(--space-md);
}

.worker-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-foreground);
}

.worker-config input[type="number"] {
  width: 5.5rem;
  min-height: var(--touch-min);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--input-border);
  border-radius: var(--input-radius);
  font: inherit;
  color: var(--color-foreground);
  background: var(--white);
}

.worker-config input[type="number"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--input-focus-ring);
}

.worker-config input[type="number"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.worker-hint {
  flex: 1 1 220px;
  margin: 0;
}

.file-field {
  flex: 1 1 220px;
  position: relative;
}

.file-field input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.file-field input[type="file"]:disabled {
  cursor: not-allowed;
}

.file-fake {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: var(--touch-min);
  padding: 0.65rem 1rem;
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--input-radius);
  background: var(--teal-50);
  color: var(--color-muted-fg);
  font-size: 0.875rem;
  transition:
    border-color var(--duration) var(--ease),
    background var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}

.file-fake svg {
  width: 20px;
  height: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.file-field:hover .file-fake,
.file-field:focus-within .file-fake {
  border-color: var(--color-primary);
  background: var(--white);
  box-shadow: var(--input-focus-ring);
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-foreground);
  font-weight: 500;
}

.file-name.is-placeholder {
  color: var(--color-muted-fg);
  font-weight: 400;
}

/* --- Quick check (paste IMEI / Serial) --- */
.quick-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.quick-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
}

.quick-row textarea {
  flex: 1 1 auto;
  min-height: calc(3 * 1.5em + 1.3rem);
  resize: vertical;
  padding: 0.65rem 1rem;
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--input-radius);
  background: var(--teal-50);
  color: var(--color-foreground);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  transition:
    border-color var(--duration) var(--ease),
    background var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}

.quick-row textarea::placeholder {
  color: var(--color-muted-fg);
  font-family: var(--typography-font);
}

.quick-row textarea:hover:not(:disabled),
.quick-row textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--white);
  box-shadow: var(--input-focus-ring);
}

.quick-row textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.quick-scan-btn {
  /* Match the Choose file / Run button below (min-height 44px, same radius) */
  flex: 0 0 var(--action-btn-width);
  min-width: var(--action-btn-width);
  min-height: var(--touch-min);
  padding: var(--button-padding-y) var(--button-padding-x);
  border-radius: var(--button-radius);
  background: var(--button-bg);
  color: var(--button-fg);
  box-shadow: 0 1px 2px rgb(194 65 12 / 0.25);
}

.quick-scan-btn svg {
  width: 18px;
  height: 18px;
}

.quick-note {
  font-weight: 600;
  color: var(--teal-700);
}

.serial-s-hint {
  margin-top: -0.35rem;
  font-weight: 600;
  color: var(--color-text-muted, #5c6b73);
}

.quick-sub {
  margin-bottom: 0;
}

#quick-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--teal-700);
}

#quick-count.over {
  color: var(--color-destructive);
}

/* --- OR divider --- */
.or-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-md) 0;
}

.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border-strong);
}

.or-divider span {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--color-muted-fg);
  padding: 0.2rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

/* --- Mode lock note --- */
.mode-lock-note {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--orange-600);
  border-radius: var(--radius-sm);
  background: var(--orange-50);
  color: var(--orange-700);
  font-weight: 600;
}

.mode-lock-note svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Buttons --- */
button,
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: var(--touch-min);
  padding: var(--button-padding-y) var(--button-padding-x);
  border: 0;
  border-radius: var(--button-radius);
  background: var(--button-bg);
  color: var(--button-fg);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease);
  box-shadow: 0 1px 2px rgb(194 65 12 / 0.25);
}

button:hover:not(:disabled),
.btn:hover {
  background: var(--button-hover-bg);
  box-shadow: var(--shadow-md);
}

button:active:not(:disabled),
.btn:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-sm);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

button svg,
.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

button.ghost,
.btn.ghost {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  box-shadow: none;
  margin-top: var(--space-sm);
}

button.ghost:hover:not(:disabled),
.btn.ghost:hover {
  background: var(--teal-50);
  box-shadow: none;
}

.btn-success {
  background: var(--color-success);
  box-shadow: 0 1px 2px rgb(4 120 87 / 0.25);
}

.btn-success:hover {
  background: #066042;
}

.btn-export {
  margin-top: 0;
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  white-space: nowrap;
  flex-shrink: 0;
}

#action-btn {
  flex: 0 0 var(--action-btn-width);
  min-width: var(--action-btn-width);
}

#action-btn[data-state="stop"] {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  box-shadow: none;
}

#action-btn[data-state="stop"]:hover {
  background: var(--teal-50);
  box-shadow: none;
}

#action-btn[data-state="resume"] {
  background: var(--color-success);
  box-shadow: 0 1px 2px rgb(4 120 87 / 0.25);
}

#action-btn[data-state="resume"]:hover {
  background: #066042;
}

#action-btn .icon-choose,
#action-btn .icon-start,
#action-btn .icon-stop,
#action-btn .icon-resume {
  display: none;
}

#action-btn[data-state="choose"] .icon-choose,
#action-btn[data-state="start"] .icon-start,
#action-btn[data-state="stop"] .icon-stop,
#action-btn[data-state="resume"] .icon-resume {
  display: block;
}

.export-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-md);
}

/* --- Progress --- */
.progress-wrap {
  margin-bottom: var(--space-sm);
}

.bar {
  height: 12px;
  background: var(--progress-track);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--slate-200);
}

#bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--progress-fill-from), var(--progress-fill-to));
  border-radius: inherit;
  transition: width 0.35s var(--ease);
}

#progress-text {
  margin: var(--space-sm) 0 0;
  color: var(--color-muted-fg);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--color-success);
  font-weight: 600;
}

.progress-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  margin-top: var(--space-md);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

@media (max-width: 480px) {
  .stat-row {
    grid-template-columns: 1fr;
  }
}

.stat {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
}

.stat dt {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-muted-fg);
}

.stat dd {
  margin: 0.15rem 0 0;
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.panel-head-results {
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
}

.result-status-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(4.5rem, 1fr));
  gap: var(--space-sm);
  margin: 0;
  flex: 1 1 14rem;
  min-width: 0;
  max-width: 28rem;
  margin-left: auto;
}

.result-stat {
  padding: 0.4rem 0.65rem;
  text-align: center;
}

.result-stat dt {
  letter-spacing: 0.04em;
}

.result-stat dd {
  font-size: 1.05rem;
}

.result-stat-active {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
}

.result-stat-active dd {
  color: var(--color-success);
}

.result-stat-inactive {
  background: var(--orange-50);
  border-color: #fed7aa;
}

.result-stat-inactive dd {
  color: var(--orange-700);
}

.result-stat-nodata {
  background: var(--slate-50);
  border-color: var(--slate-200);
}

.result-stat-nodata dd {
  color: var(--slate-600);
}

@media (max-width: 640px) {
  .panel-head-results {
    align-items: stretch;
  }

  .result-status-row {
    max-width: none;
    margin-left: 0;
    width: 100%;
  }
}

/* --- Info grid --- */
.grid2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

@media (min-width: 700px) {
  .grid2 {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
  }
}

.info-block h3 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 var(--space-sm);
  font-size: 0.9375rem;
  font-weight: 650;
}

.info-block h3 svg {
  width: 18px;
  height: 18px;
  color: var(--color-primary);
}

.info-block p {
  margin: 0 0 var(--space-sm);
  font-size: 0.9375rem;
}

.info-block .hint {
  margin-bottom: 0;
}

/* --- Table --- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.table-wrap-users {
  overflow: auto;
  /* header (~34px) + 10 data rows (~38px each) */
  max-height: calc(34px + 10 * 38px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 420px;
}

th,
td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--slate-200);
}

tr:last-child td {
  border-bottom: 0;
}

th {
  background: var(--teal-50);
  color: var(--color-muted-fg);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  /* Headers stay on one line — the wrapper scrolls horizontally instead */
  white-space: nowrap;
}

td {
  font-variant-numeric: tabular-nums;
  color: var(--color-foreground);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  /* Never let a pill wrap into an oval on narrow screens */
  white-space: nowrap;
}

.badge-ok {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}

.badge-pending {
  background: var(--orange-50);
  color: var(--orange-700);
  border: 1px solid #fed7aa;
}

.badge-warn {
  background: #fef9c3;
  color: #a16207;
  border: 1px solid #fde047;
}

.badge-muted {
  background: var(--gray-light2, #f1f5f9);
  color: var(--gray-dark2, #475569);
  border: 1px solid #cbd5e1;
}

/* --- Flash / errors --- */
.flash {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-md);
}

.flash li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
  font-size: 0.875rem;
  border: 1px solid transparent;
}

.flash li svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.flash .ok {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: var(--color-success-border);
}

.flash .error,
.err {
  background: var(--color-destructive-bg);
  color: var(--red-700);
  border-color: var(--color-destructive-border);
}

.err {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  border: 1px solid var(--color-destructive-border);
  margin: var(--space-sm) 0 0;
}

/* --- Footer --- */
.footer {
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  color: var(--color-muted-fg);
  font-size: 0.8125rem;
  text-align: center;
}

/* --- Motion --- */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .status-pill[data-state="running"] .status-dot {
    animation: none;
  }
}

/* --- Login --- */
.login-page {
  position: relative;
  min-height: 100vh;
  padding: var(--space-lg);
  background: linear-gradient(160deg, var(--teal-50) 0%, var(--white) 45%, var(--teal-100) 100%);
}

.auth-global-header {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.auth-global-header .lang-switch {
  margin-left: var(--space-xs);
}

.login-card {
  width: min(420px, 100%);
  margin: clamp(2rem, 8vh, 5rem) auto 2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xl);
}

.login-brand {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-md);
}

/* Unwrap title+tagline so logo aligns with h1 only. */
.login-brand > div {
  display: contents;
}

.login-brand .brand-mark {
  grid-row: 1;
  grid-column: 1;
}

.login-brand h1 {
  grid-row: 1;
  grid-column: 2;
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
  color: var(--color-foreground);
}

.login-brand p {
  grid-row: 2;
  grid-column: 2;
  margin: 0.15rem 0 0;
}

.signup-verification-note {
  margin: 0 0 var(--space-lg);
  padding: 0.75rem 1rem;
  color: var(--teal-800);
  background: var(--teal-50);
  border: 1px solid var(--teal-200);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.45;
}

.login-brand small {
  display: block;
  color: var(--color-muted-fg);
  font-size: 0.75rem;
}

.login-form .field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

/* Admin/account forms: label above input, input fills its grid cell */
.admin-form .field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 0;
}

.admin-form .field span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-foreground);
}

.admin-form .field input,
.admin-form .field select {
  width: 100%;
}

.login-form-link {
  margin: calc(var(--space-sm) * -1) 0 var(--space-md);
  text-align: right;
  font-size: 0.875rem;
}

.login-footer-link {
  margin-top: 1rem;
  text-align: center;
}

.login-form .field span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-foreground);
}

.login-form input,
.admin-form input,
.admin-form select {
  min-height: var(--touch-min);
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--white);
}

.login-form input:focus,
.admin-form input:focus,
.admin-form select:focus {
  outline: 2px solid var(--teal-200);
  border-color: var(--color-primary);
}

/* Password show/hide toggle (eye icon) */
.password-field {
  position: relative;
  display: block;
  width: 100%;
}

.password-field input {
  width: 100%;
  padding-right: 2.75rem;
  box-sizing: border-box;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted-fg);
  cursor: pointer;
  line-height: 0;
}

.password-toggle:hover {
  color: var(--color-primary);
  background: var(--teal-50);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--teal-200);
  outline-offset: 1px;
  color: var(--color-primary);
}

.password-toggle[aria-pressed="true"] {
  color: var(--color-primary);
}

.password-toggle svg {
  display: block;
  pointer-events: none;
}

.password-field input::-ms-reveal,
.password-field input::-ms-clear {
  display: none;
}

.btn-block {
  width: 100%;
  margin-top: var(--space-sm);
}

.login-error {
  background: var(--color-destructive-bg);
  color: var(--red-700);
  border: 1px solid var(--color-destructive-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  margin-bottom: var(--space-md);
}

.login-ok {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  margin-bottom: var(--space-md);
}

.login-hint {
  background: var(--color-muted);
  color: var(--color-foreground);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-top: var(--space-md);
}

.login-hint strong {
  color: var(--color-accent);
}

/* --- Topbar nav / user --- */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  row-gap: var(--space-sm);
  min-width: 0;
}

.ghost-link {
  color: var(--color-muted-fg);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.ghost-link:hover {
  color: var(--color-primary);
}

/* --- Language switch (EN / VI) --- */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.15rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--white);
  flex-shrink: 0;
}

.lang-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.28rem 0.55rem;
  border-radius: var(--radius-full);
  color: var(--color-muted-fg);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}

.lang-switch-btn:hover {
  color: var(--color-primary);
  background: var(--teal-50);
}

.lang-switch-btn.is-active {
  color: var(--white);
  background: var(--color-primary);
}

.login-page > .lang-switch {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.35rem 0.75rem;
  background: var(--teal-100);
  color: var(--teal-800);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.token-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5.5rem;
  padding: 0.35rem 0.85rem;
  background: var(--orange-50);
  color: var(--orange-700);
  border: 1px solid rgb(234 88 12 / 0.2);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-topup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 6rem;
  flex-shrink: 0;
  padding: 0.35rem 0.85rem;
  background: var(--green-50);
  color: var(--green-700);
  border: 1px solid rgb(4 120 87 / 0.25);
  border-radius: var(--radius-full);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: normal;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.btn-topup:hover:not(:disabled) {
  background: var(--green-100);
  border-color: rgb(4 120 87 / 0.4);
  color: #065f46;
  box-shadow: none;
  transform: none;
}

.btn-topup:active:not(:disabled) {
  transform: none;
  box-shadow: none;
}

.btn-topup:focus-visible {
  outline: 2px solid var(--green-700);
  outline-offset: 2px;
}

.token-badge[data-state="unlimited"] {
  background: var(--green-50);
  color: var(--green-700);
  border-color: rgb(4 120 87 / 0.2);
}

.token-badge[data-state="empty"] {
  background: var(--red-50);
  color: var(--red-700);
  border-color: rgb(220 38 38 / 0.2);
}

.token-cell {
  white-space: nowrap;
}

.token-cell .token-edit-btn {
  margin-left: 0.35rem;
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
}

/* --- Admin --- */
.admin-config-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  align-items: stretch;
}

.admin-config-grid > .panel-admin-config {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  min-width: 0;
  padding: 0.85rem 1rem;
}

.admin-config-grid .panel-head {
  margin-bottom: 0.45rem;
}

.admin-config-grid .panel-title {
  font-size: 0.9375rem;
}

.admin-config-grid .hint {
  margin: 0 0 0.65rem;
  font-size: 0.75rem;
  line-height: 1.35;
}

.admin-config-grid .admin-form {
  margin-top: auto;
}

.admin-config-grid .admin-form-row-compact {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  align-items: stretch;
}

.admin-config-grid .admin-form-row-compact .btn {
  width: 100%;
  justify-content: center;
  margin-top: 0.15rem;
}

.admin-config-grid .admin-form-row-compact .btn.ghost {
  margin-top: 0.35rem;
}

.admin-config-grid .field span {
  font-size: 0.75rem;
}

.admin-config-grid [role="status"].hint {
  margin: 0.5rem 0 0;
  min-height: 1.1em;
}

.admin-config-grid .panel-change-password .admin-form-row-compact .btn.ghost + .btn {
  margin-top: 0;
}

.admin-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: var(--space-md);
  align-items: end;
}

.admin-form-row-stack {
  grid-template-columns: repeat(3, 1fr) auto;
}

@media (max-width: 1400px) {
  .admin-config-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .admin-config-grid {
    grid-template-columns: 1fr;
  }
}

.panel-head-actions {
  align-items: center;
}

.panel-table-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.table-search {
  display: inline-flex;
  min-width: 0;
}

.table-search input {
  width: 13rem;
  height: 36px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-background);
  color: var(--color-foreground);
  font: inherit;
  font-size: 0.8125rem;
}

.table-search input:focus {
  border-color: var(--color-primary);
  outline: 2px solid rgb(13 115 119 / 0.16);
  outline-offset: 1px;
}

.panel-head-batch {
  position: relative;
  z-index: 5;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  margin-bottom: var(--space-sm);
}

.panel-head-batch .panel-title {
  white-space: nowrap;
  line-height: 1.2;
  margin: 0;
}

.batch-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.batch-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 0;
}

.batch-toolbar .btn-export {
  margin-left: auto;
  flex-shrink: 0;
}

.pay-view-toggles {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.batch-filters button.ghost,
.pay-view-toggles button.ghost {
  margin-top: 0;
}

.pay-view-btn.is-active {
  background: var(--color-primary, #0d7377);
  color: #fff;
  border-color: transparent;
}

.pay-view-btn.is-active:hover {
  background: var(--color-primary, #0d7377);
  color: #fff;
  opacity: 0.92;
}

.pay-agg-wrap {
  position: relative;
  display: inline-flex;
}

.pay-agg-caret {
  margin-left: 0.2rem;
  font-size: 0.7em;
  opacity: 0.85;
}

.pay-agg-menu {
  position: fixed;
  z-index: 1000;
  min-width: 9rem;
  padding: 0.3rem;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 22px rgba(15, 40, 50, 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.pay-agg-menu[hidden] {
  display: none !important;
}

/* Beat global `button` / `button:hover` (orange accent) */
button.pay-agg-option {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  min-height: 0;
  height: auto;
  margin: 0;
  border: 0;
  background: #fff;
  text-align: left;
  justify-content: flex-start;
  padding: 0.45rem 0.6rem;
  border-radius: calc(var(--radius-sm) - 2px);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: normal;
  line-height: 1.25;
  color: var(--color-foreground);
  cursor: pointer;
  box-shadow: none;
  transform: none;
}

button.pay-agg-option:hover:not(:disabled),
button.pay-agg-option:active:not(:disabled) {
  background: var(--teal-50, #f0fdfa);
  color: var(--color-primary, #0d7377);
  box-shadow: none;
  transform: none;
}

button.pay-agg-option.is-active,
button.pay-agg-option.is-active:hover:not(:disabled) {
  background: rgba(13, 115, 119, 0.12);
  color: var(--color-primary, #0d7377);
  font-weight: 600;
}

button.pay-agg-option:focus,
button.pay-agg-option:focus-visible {
  outline: 2px solid rgba(13, 115, 119, 0.35);
  outline-offset: 0;
}

.batch-filter-field input {
  height: 36px;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-background);
  color: var(--color-foreground);
  font-size: 0.8125rem;
  min-width: 11.5rem;
}

.batch-filter-sep {
  color: var(--color-muted-fg);
  font-weight: 600;
}

.admin-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

/* Wide account table: keep content-sized columns + horizontal scroll */
.table-wrap-users .admin-table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}

.admin-table th,
.admin-table td {
  padding: 0.45rem 0.65rem;
  white-space: nowrap;
  vertical-align: middle;
  border-bottom: 1px solid var(--slate-200);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table th:first-child,
.admin-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--teal-50);
  box-shadow: 1px 0 0 var(--slate-200);
}

.admin-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

.admin-table thead th:first-child {
  z-index: 4;
  left: 0;
}

.admin-table th.sortable-column {
  cursor: pointer;
  user-select: none;
}

.admin-table th.sortable-column::after {
  content: "↕";
  display: inline-block;
  margin-left: 0.35rem;
  color: var(--color-muted-fg);
  font-size: 0.7rem;
  opacity: 0.55;
}

.admin-table th.sortable-column[aria-sort="ascending"]::after {
  content: "↑";
  color: var(--color-primary);
  opacity: 1;
}

.admin-table th.sortable-column[aria-sort="descending"]::after {
  content: "↓";
  color: var(--color-primary);
  opacity: 1;
}

.admin-table th.sortable-column:focus-visible {
  outline: 2px solid rgb(13 115 119 / 0.35);
  outline-offset: -2px;
}

/* --- Admin SEO keyword × landing table --- */
.panel-seo-report .seo-toolbar {
  margin: 0 0 0.75rem;
}

.panel-seo-report .seo-toolbar input[type="search"] {
  width: min(100%, 28rem);
  max-width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md, 8px);
  font: inherit;
  background: var(--color-background);
}

.panel-seo-report .seo-table-wrap {
  max-height: min(70vh, 640px);
  overflow: auto;
}

.panel-seo-report .seo-table {
  min-width: 980px;
}

.panel-seo-report .seo-table th.num,
.panel-seo-report .seo-table td.num {
  text-align: right;
}

.panel-seo-report .seo-landing-row td,
.panel-seo-report .seo-landing-row td:first-child {
  background: #f8fbfb;
  font-weight: 650;
}

.panel-seo-report .seo-kw-row td:first-child {
  padding-left: 1.75rem;
  color: #334155;
  font-weight: 450;
}

.panel-seo-report .seo-up {
  color: var(--color-success, #157347);
}

.panel-seo-report .seo-down {
  color: var(--color-danger, #b42318);
}

.admin-table td:first-child {
  background: var(--color-background);
  z-index: 1;
}

.admin-table tbody tr:nth-child(even) td:first-child {
  background: #fafcfb;
}

.admin-table th.num-cell,
.admin-table td.num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Payment history columns — title & value share the same alignment */
.panel-payment-history .admin-table .col-pay-date {
  width: 34%;
  text-align: left;
}

.panel-payment-history .admin-table .col-pay-user {
  width: 22%;
  text-align: left;
}

.panel-payment-history .admin-table .col-pay-amount,
.panel-payment-history .admin-table .col-pay-tokens {
  width: 22%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.panel-payment-history .admin-table.is-pay-agg .col-pay-date {
  width: 40%;
}

.panel-payment-history .admin-table.is-pay-agg .col-pay-amount,
.panel-payment-history .admin-table.is-pay-agg .col-pay-tokens {
  width: 30%;
}

/* Scan batch history columns */
.panel-batch-history .admin-table .col-batch-user {
  width: 12%;
}

.panel-batch-history .admin-table .col-batch-file {
  width: 28%;
}

.panel-batch-history .admin-table .col-batch-started,
.panel-batch-history .admin-table .col-batch-finished {
  width: 16%;
}

.panel-batch-history .admin-table .col-batch-imei {
  width: 16%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.panel-batch-history .admin-table .col-batch-status {
  width: 12%;
}

.panel-batch-history .admin-table .col-batch-download {
  width: 7.5rem;
  text-align: center;
}

.panel-batch-history .admin-table .btn-batch-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.panel-batch-history .admin-table .btn-batch-download svg {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

.panel-batch-history .admin-table:not(:has(.col-batch-user)) .col-batch-file {
  width: 36%;
}

.admin-table .col-user {
  min-width: 8.5rem;
}

.admin-table .col-role,
.admin-table .col-status,
.admin-table .col-country {
  text-align: center;
  min-width: 4.5rem;
}

.admin-table .col-token {
  min-width: 6.5rem; /* fits 1,000,000 */
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table th.col-token,
.admin-table th.col-batches,
.admin-table th.col-imei {
  text-align: right;
}

.admin-table .col-batches {
  min-width: 4.25rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table .col-imei {
  min-width: 6.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table .col-date {
  min-width: 8.75rem;
  text-align: center;
}

.admin-table th.col-date {
  text-align: center;
}

.admin-table .col-actions,
.admin-table td.admin-actions {
  min-width: 22rem;
}

.admin-table .token-display {
  display: inline-block;
  min-width: 5.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table .file-cell {
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-actions {
  display: grid;
  grid-template-columns: max-content max-content max-content 4.75rem;
  gap: 0.35rem;
  align-items: center;
  justify-content: start;
}

.admin-actions .ghost {
  white-space: nowrap;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

.admin-actions .btn-deactive {
  color: #b45309;
  border-color: #fde68a;
}

.admin-actions .btn-deactive:hover {
  background: #fffbeb;
}

.admin-actions .btn-active {
  color: #047857;
  border-color: #a7f3d0;
}

.admin-actions .btn-active:hover {
  background: #ecfdf5;
}

.admin-action-spacer {
  display: block;
  width: 100%;
  height: 1px;
  visibility: hidden;
  pointer-events: none;
}

.panel-head .btn-export {
  flex-shrink: 0;
  white-space: nowrap;
  margin-left: auto;
}

@media (max-width: 768px) {
  .admin-form-row,
  .admin-form-row-stack {
    grid-template-columns: 1fr;
  }

  .batch-filter-field input {
    min-width: 0;
    width: 100%;
  }

  .batch-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-head-actions,
  .panel-table-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-table-actions {
    width: 100%;
    margin-left: 0;
  }

  .table-search,
  .table-search input {
    width: 100%;
  }

  .batch-toolbar .btn-export,
  .panel-head .btn-export {
    margin-left: 0;
    width: 100%;
  }
}

.muted-cell {
  text-align: center;
  color: var(--color-muted-fg);
  padding: var(--space-lg) !important;
}

button.ghost.danger {
  color: var(--red-600);
  border-color: var(--red-100);
}

button.ghost.danger:hover {
  background: var(--red-50);
}

.hint.ok {
  color: var(--green-700);
}

.hint.err {
  color: var(--red-700);
}

/* Top-up QR modal — only order + amount + QR (no STK / account name) */
.topup-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 1rem;
}

.topup-modal-card {
  /* Landscape phones: keep the card scrollable instead of overflowing */
  max-height: min(92vh, 92dvh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.topup-modal[hidden] {
  display: none !important;
}

.topup-modal-card {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem 1.75rem 1.75rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

.topup-modal-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--slate-800);
}

.topup-amount {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--teal-700);
}

.topup-hint,
.topup-tokens {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--slate-500);
}

.topup-qr-img {
  display: block;
  margin: 0 auto;
  width: 220px;
  height: 220px;
  image-rendering: pixelated;
}

.topup-qr-img[hidden] {
  display: none;
}

.topup-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--slate-400);
}

.topup-close:hover {
  color: var(--slate-800);
}

#topup-qr {
  display: inline-block;
  border-radius: 8px;
}

/* Package picker modal */
.topup-picker-card {
  max-width: 400px;
  text-align: left;
}

.topup-picker-sub {
  margin: 0 0 1.1rem;
  font-size: 0.8rem;
  color: var(--slate-500);
}

.topup-region-toggle {
  margin: 0 0 1rem;
  display: flex;
  justify-content: center;
}

.topup-region-btn {
  width: 100%;
  min-height: 42px;
  gap: 0.55rem;
  padding: 0.55rem 1rem;
  border: 1px solid rgb(234 88 12 / 0.35);
  border-radius: 11px;
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  color: var(--orange-700);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 1px 2px rgb(194 65 12 / 0.12);
  cursor: pointer;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.topup-region-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffedd5 0%, #fed7aa 100%);
  border-color: rgb(234 88 12 / 0.55);
  color: #9a3412;
  box-shadow: 0 2px 8px rgb(194 65 12 / 0.16);
  transform: translateY(-1px);
}

.topup-region-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgb(194 65 12 / 0.12);
}

.topup-region-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.topup-region-btn-icon {
  display: inline-flex;
  color: var(--orange-600);
}

.topup-region-btn-label {
  text-align: center;
}

.topup-region-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--teal-700, #0f766e);
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
}

.topup-region-link:hover {
  color: var(--teal-800, #115e59);
}

.topup-pkg-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.topup-pkg {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 0;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--slate-200);
  border-radius: 12px;
  background: var(--slate-50);
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  letter-spacing: normal;
  text-align: left;
  box-shadow: none;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}

.topup-pkg:hover:not(:disabled) {
  border-color: var(--teal-300);
  background: var(--teal-50);
  box-shadow: none;
  transform: none;
}

.topup-pkg:active:not(:disabled) {
  transform: none;
}

.topup-pkg.is-selected {
  border-color: var(--green-700);
  background: var(--green-50);
  box-shadow: 0 0 0 1px rgb(4 120 87 / 0.25);
}

.topup-pkg-tokens {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--slate-800);
}

.topup-pkg-price {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--green-700);
  white-space: nowrap;
}

.topup-custom {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1.5px dashed var(--slate-200);
  border-radius: 12px;
  background: #fff;
}

.topup-custom-label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--slate-600);
}

.topup-custom-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topup-custom-row input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--slate-800);
  background: var(--slate-50);
}

.topup-custom-row input:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgb(20 184 166 / 0.15);
}

.topup-custom-eq {
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green-700);
  white-space: nowrap;
}

.topup-custom-limit {
  margin: 0.45rem 0 0;
  color: var(--slate-500);
  font-size: 0.7rem;
}

.topup-picker-error {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--red-700);
}

.topup-continue {
  width: 100%;
  justify-content: center;
}

.topup-continue:disabled {
  opacity: 0.65;
  cursor: wait;
}

.topup-retry-zone {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--slate-200);
}

.topup-retry {
  min-height: 38px;
  padding: 0.45rem 1.2rem;
  border: 1px solid var(--teal-200);
  border-radius: 9px;
  background: var(--teal-50);
  color: var(--teal-700);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: normal;
  box-shadow: none;
}

.topup-retry:hover:not(:disabled) {
  border-color: var(--teal-400, var(--teal-300));
  background: var(--teal-100);
  box-shadow: none;
  transform: none;
}

.topup-retry:disabled {
  cursor: wait;
  opacity: 0.6;
}

.topup-retry-status {
  margin: 0.45rem 0 0;
  color: var(--slate-500);
  font-size: 0.72rem;
  line-height: 1.4;
}

/* --- SEO guides --- */
.guide-hero {
  padding-bottom: var(--space-lg);
}

.guide-list-panel {
  padding: var(--space-lg);
}

.guide-card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-md);
}

.guide-card a {
  display: block;
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.guide-card a:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
}

.guide-card h2 {
  margin: 0 0 var(--space-sm);
  font-size: 1.1rem;
  color: var(--color-foreground);
}

.guide-card p {
  margin: 0 0 var(--space-md);
  color: var(--color-muted-fg);
  font-size: 0.95rem;
  line-height: 1.55;
}

.guide-card-cta {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
}

.guide-article {
  max-width: 44rem;
  margin: 0 auto;
}

.guide-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: var(--space-lg) 0 var(--space-md);
  font-size: 0.85rem;
  color: var(--color-muted-fg);
}

.guide-breadcrumb a {
  color: var(--color-primary);
  text-decoration: none;
}

.guide-breadcrumb a:hover {
  text-decoration: underline;
}

.guide-header {
  margin-bottom: var(--space-lg);
}

.guide-header h1 {
  margin: 0 0 var(--space-sm);
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.25;
  color: var(--color-foreground);
}

.guide-tldr {
  margin: 0 0 var(--space-lg);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-success, #16a34a);
  border-radius: var(--radius-md, 12px);
  background: var(--color-surface-muted, #f6f8fa);
}

.guide-tldr-label {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-success, #16a34a);
}

.guide-tldr-text {
  margin: 0;
  line-height: 1.6;
  color: var(--color-foreground);
}

.blog-trust {
  margin: 0 0 var(--space-lg);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 12px);
  background: var(--color-surface-muted, #f6f8fa);
}

.blog-trust strong {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.blog-trust ul {
  margin: 0 0 0.65rem;
  padding-left: 1.15rem;
}

.blog-trust li {
  margin: 0.25rem 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--color-muted-fg);
}

.blog-trust p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-muted-fg);
}

.landing-trust-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
}

.landing-trust-grid h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

@media (max-width: 720px) {
  .landing-trust-grid {
    grid-template-columns: 1fr;
  }
}

.guide-section {
  margin-bottom: var(--space-md);
}

.guide-body {
  line-height: 1.65;
}

.guide-body p,
.guide-body ul,
.guide-body ol {
  margin: 0 0 0.85rem;
}

.guide-body ul,
.guide-body ol {
  padding-left: 1.25rem;
}

.guide-body li {
  margin-bottom: 0.35rem;
}

.guide-figure {
  margin: var(--space-lg) 0;
}

.guide-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.guide-figure figcaption {
  margin-top: var(--space-sm);
  color: var(--color-muted-fg);
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
}

.guide-example {
  margin-top: var(--space-md);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--slate-50);
}

.guide-example pre {
  margin: var(--space-sm) 0 0;
  overflow-x: auto;
  font: 0.85rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--color-foreground);
}

.guide-faq-q {
  margin: 1rem 0 0.35rem;
  font-size: 1rem;
  color: var(--color-foreground);
}

.guide-cta {
  margin: var(--space-xl) 0 var(--space-2xl);
}

.site-footer {
  margin-top: var(--space-xl);
  padding: var(--space-lg) 0 var(--space-xl);
  border-top: 1px solid var(--color-border);
  text-align: center;
  color: var(--color-muted-fg);
  font-size: 0.85rem;
}

.site-footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-lg);
  margin-bottom: var(--space-sm);
}

.site-footer-nav a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
}

.site-footer-nav a:hover {
  text-decoration: underline;
}

.site-footer p {
  margin: 0;
}

.about-header {
  margin-top: var(--space-xl);
}

/* --- Vietnamese SEO blog --- */
.blog-hero {
  margin-bottom: var(--space-lg);
}

.blog-eyebrow {
  margin: 0 0 var(--space-sm);
  color: var(--color-primary);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.blog-category-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
  margin: 0 0 var(--space-xl);
}

.blog-category-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 5.5rem;
  padding: 1.05rem 1.15rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-foreground);
  box-shadow: var(--shadow-sm);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.3;
  text-decoration: none;
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.blog-category-nav a span {
  color: var(--color-muted-fg);
  font-size: 0.85rem;
  font-weight: 600;
}

.blog-category-nav a:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--color-primary) 35%, var(--color-border));
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.blog-category-nav a:hover span {
  color: color-mix(in srgb, var(--color-primary) 70%, var(--color-muted-fg));
}

@media (min-width: 900px) {
  .blog-category-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.blog-group {
  margin: 0 0 var(--space-2xl);
  scroll-margin-top: var(--space-lg);
}

.blog-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.blog-group-head h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
}

.blog-group-head span {
  color: var(--color-muted-fg);
  font-size: 0.85rem;
}

.blog-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-lg);
}

.blog-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.blog-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.blog-card-media {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--slate-50);
}

.blog-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.blog-card-content {
  padding: var(--space-md);
}

.blog-card-meta,
.blog-byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  color: var(--color-muted-fg);
  font-size: 0.78rem;
}

.blog-card-meta span {
  color: var(--color-primary);
  font-weight: 700;
}

.blog-card h3 {
  margin: 0.55rem 0;
  font-size: 1.05rem;
  line-height: 1.35;
}

.blog-card h3 a {
  color: var(--color-foreground);
  text-decoration: none;
}

.blog-card p {
  display: -webkit-box;
  margin: 0 0 var(--space-md);
  overflow: hidden;
  color: var(--color-muted-fg);
  font-size: 0.9rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.blog-article {
  max-width: 48rem;
  margin: 0 auto;
}

.blog-post-header h1 {
  margin: 0 0 var(--space-md);
  font-size: clamp(1.75rem, 4vw, 2.65rem);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

.blog-lead {
  margin: 0 0 var(--space-md);
  color: var(--color-muted-fg);
  font-size: 1.08rem;
  line-height: 1.7;
}

.blog-hero-image {
  display: block;
  width: 100%;
  height: auto;
  margin: var(--space-lg) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--slate-50);
  box-shadow: var(--shadow-sm);
}

.blog-support-note,
.blog-inline-cta,
.blog-neutral-cta {
  margin: 0 0 var(--space-lg);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.blog-support-note {
  border-left: 4px solid var(--color-warning, #d97706);
  background: #fffbeb;
  color: #713f12;
  line-height: 1.6;
}

.blog-toc {
  margin: 0 0 var(--space-xl);
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--slate-50);
}

.blog-toc ol {
  margin: var(--space-sm) 0 0;
  padding-left: 1.25rem;
}

.blog-toc li {
  margin: 0.4rem 0;
}

.blog-toc a {
  color: var(--color-foreground);
  text-decoration: none;
}

.blog-toc a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.blog-section {
  margin: 0 0 var(--space-xl);
  scroll-margin-top: var(--space-lg);
}

.blog-section h2,
.blog-sources h2,
.blog-related h2 {
  margin: 0 0 var(--space-md);
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  line-height: 1.3;
}

.blog-section h3 {
  margin: var(--space-lg) 0 var(--space-sm);
  font-size: 1.08rem;
}

.blog-inline-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  background: var(--color-primary-subtle);
}

.blog-inline-cta p {
  margin: 0.35rem 0 0;
  color: var(--color-muted-fg);
  line-height: 1.5;
}

.blog-inline-cta .btn {
  flex: 0 0 auto;
}

.blog-faq {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border);
}

.blog-faq summary {
  cursor: pointer;
  color: var(--color-foreground);
  font-weight: 700;
  line-height: 1.45;
}

.blog-faq p {
  margin: var(--space-sm) 0 0;
  color: var(--color-muted-fg);
  line-height: 1.65;
}

.blog-sources {
  margin: var(--space-xl) 0;
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  background: var(--slate-50);
}

.blog-sources ul {
  margin: 0;
  padding-left: 1.2rem;
}

.blog-sources li {
  margin: 0.45rem 0;
  line-height: 1.55;
}

.blog-related {
  margin: var(--space-2xl) 0 var(--space-xl);
}

.blog-related-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
}

.blog-related-grid a {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-foreground);
  text-decoration: none;
}

.blog-related-grid a:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.blog-related-grid span {
  color: var(--color-primary);
  font-size: 0.75rem;
  font-weight: 700;
}

.blog-neutral-cta {
  text-align: center;
  background: var(--slate-50);
}

.blog-neutral-cta p {
  margin: 0 0 var(--space-sm);
  color: var(--color-muted-fg);
}

.blog-neutral-cta a {
  font-weight: 700;
}

@media (max-width: 900px) {
  .blog-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .blog-card-grid,
  .blog-related-grid {
    grid-template-columns: 1fr;
  }

  .blog-inline-cta {
    align-items: stretch;
    flex-direction: column;
  }

  .blog-inline-cta .btn {
    width: 100%;
  }
}

/* =========================================================
   Mobile / responsive — portrait, landscape and fold phones
   ========================================================= */

/* Tablets & landscape phones */
@media (max-width: 820px) {
  .page {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }

  .page-wide {
    max-width: 100%;
  }

  /* Title + timer / actions can share a row only if they fit */
  .panel-head {
    flex-wrap: wrap;
    row-gap: var(--space-sm);
  }
}

/* Portrait phones */
@media (max-width: 640px) {
  .page {
    padding: var(--space-md) var(--space-sm) var(--space-2xl);
  }

  .top-utility {
    margin-bottom: 0;
  }

  .panel {
    padding: var(--space-md);
  }

  .hero {
    margin-bottom: var(--space-lg);
  }

  .hero h1 {
    font-size: clamp(1.6rem, 7vw, 2.2rem);
  }

  .sub {
    font-size: 1rem;
  }

  /* Hero CTA buttons: stack full width */
  .hero-actions .hero-cta,
  .hero-actions .btn {
    flex: 1 1 100%;
    max-width: none;
    min-width: 0;
    white-space: normal;
  }

  /* Topbar: row 1 = brand + status pill, row 2 = one neat scrollable chip row */
  .topbar {
    margin-bottom: var(--space-lg);
    align-items: flex-start;
  }

  .panel-title {
    font-size: 1rem;
  }

  .panel-head-batch .panel-title {
    white-space: normal;
  }

  .topbar-nav {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    overflow: visible;
    padding: 0;
  }

  .topbar-nav > * {
    flex-shrink: 0;
  }

  /* Uniform chip height so every row stays straight */
  .topbar-nav .ghost-link {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
  }

  .topbar-nav .token-badge,
  .topbar-nav .btn-topup,
  .topbar-nav .user-chip {
    min-height: 32px;
  }

  .status-pill {
    min-width: 0;
  }

  /* Quick check: textarea on top, scan button full width below */
  .quick-row {
    flex-direction: column;
    align-items: stretch;
  }

  .quick-row textarea {
    width: 100%;
  }

  .quick-scan-btn {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
  }

  /* Import Excel: file picker on top, action button full width below */
  .upload-row {
    flex-direction: column;
    align-items: stretch;
  }

  .file-field {
    flex: 1 1 auto;
    width: 100%;
  }

  #action-btn {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
  }

  .worker-config {
    align-items: stretch;
  }

  /* Progress actions & export */
  .progress-actions form,
  .progress-actions .ghost {
    width: 100%;
  }

  .export-actions {
    justify-content: stretch;
  }

  .export-actions .btn-export {
    width: 100%;
  }

  /* Compact chips so token badge + top-up + user fit on one line */
  .token-badge,
  .btn-topup {
    min-width: 0;
  }

  /* Login / register card breathing room on small screens */
  .login-page {
    padding: var(--space-md);
  }

  .auth-global-header {
    margin-bottom: var(--space-lg);
  }

  .login-card {
    margin: 0 auto var(--space-lg);
    padding: var(--space-lg);
  }

  /* Top-up modal */
  .topup-modal {
    padding: 0.75rem;
  }

  .topup-modal-card {
    padding: 1.25rem 1rem 1.25rem;
  }

  .topup-qr-img,
  #topup-qr {
    width: min(220px, 70vw);
    height: auto;
  }
}

/* Landscape phones (short viewport): keep modals & login usable */
@media (max-height: 480px) {
  .topup-modal-card {
    max-height: min(88vh, 88dvh);
  }
}

/* --- Admin shell (sidebar tabs) --- */
.admin-shell {
  display: flex;
  gap: var(--space-lg);
  align-items: flex-start;
}

.admin-sidebar {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-sm);
  box-shadow: 0 4px 16px rgba(15, 118, 110, 0.06);
}

.admin-menu-label {
  padding: 0.5rem 0.875rem 0.65rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-muted-fg);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-nav-link {
  width: calc(100% - 0.5rem);
  margin: 0.125rem 0.25rem;
  padding: 0.65rem 0.875rem;
  border: 0;
  border-radius: 0.625rem;
  background: transparent;
  color: var(--color-muted-fg);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-weight: 500;
  transition: background var(--duration, 0.15s) var(--ease, ease), color var(--duration, 0.15s) var(--ease, ease);
}

.admin-nav-link svg {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.admin-nav-link:hover {
  background: #f0fdfa;
  color: var(--color-primary);
}

.admin-nav-link.is-active {
  background: rgba(15, 118, 110, 0.12);
  color: var(--color-primary);
}

.admin-main {
  flex: 1;
  min-width: 0;
}

.admin-tab-panel[hidden] {
  display: none !important;
}

.admin-table code {
  color: var(--color-primary);
  font-size: 0.8rem;
  background: #f0fdfa;
  padding: 0.125rem 0.4rem;
  border-radius: 0.25rem;
}

@media (max-width: 900px) {
  .admin-shell {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    position: static;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem;
    padding: 0.5rem;
  }

  .admin-menu-label {
    width: 100%;
    padding-bottom: 0.25rem;
  }

  .admin-nav-link {
    width: auto;
    flex: 1 1 auto;
    justify-content: center;
    margin: 0;
  }
}

/* Narrow fold cover screens (~280–360px) */
@media (max-width: 360px) {
  html {
    font-size: 15px;
  }

  .page {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
  }

  .brand-text span {
    font-size: 0.875rem;
  }

  .topbar-nav {
    gap: var(--space-xs) var(--space-sm);
  }

  .or-divider span {
    padding: 0.2rem 0.6rem;
  }

  th,
  td {
    padding: 0.55rem 0.65rem;
  }
}

/* ── Support FAB + modal (FAQ / Báo lỗi) ─────────────────────────────────── */
.support-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1100;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--teal-700);
  color: #fff;
  box-shadow: 0 8px 22px rgba(15, 118, 110, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.support-fab svg {
  width: 22px;
  height: 22px;
}

.support-fab:hover {
  background: var(--teal-800);
  transform: scale(1.05);
  color: #fff;
}

.support-modal {
  z-index: 1150;
}

.support-modal-card {
  max-width: 560px;
  width: 100%;
  text-align: left;
  padding: 1.25rem 1.35rem 1.35rem;
}

.support-modal-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--slate-800);
}

.support-modal-title svg {
  width: 20px;
  height: 20px;
  color: var(--teal-700);
  flex-shrink: 0;
}

.support-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--slate-200);
  margin-bottom: 0.9rem;
}

.support-tab {
  border: 0;
  background: transparent;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--slate-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.support-tab.is-active {
  color: var(--teal-700);
  font-weight: 600;
  border-bottom-color: var(--teal-700);
}

.support-pane[hidden] {
  display: none !important;
}

.support-topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.support-chip {
  border: 1px solid var(--teal-200);
  background: #fff;
  color: var(--teal-700);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}

.support-chip:hover {
  background: var(--teal-50);
  border-color: var(--teal-700);
}

.support-faq-chat {
  height: 240px;
  overflow-y: auto;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.9rem;
}

.support-msg {
  margin-bottom: 10px;
  max-width: 92%;
}

.support-msg.bot {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 10px 10px 10px 4px;
  padding: 8px 10px;
}

.support-msg.user {
  margin-left: auto;
  background: var(--teal-100);
  border-radius: 10px 10px 4px 10px;
  padding: 8px 10px;
  color: var(--teal-900);
}

.support-faq-input-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.support-faq-input-row input {
  flex: 1;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
}

.support-faq-send {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--teal-700);
  color: #fff;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.support-faq-send svg {
  width: 16px;
  height: 16px;
}

.support-faq-send:hover {
  background: var(--teal-800);
}

.support-faq-hint {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--slate-500);
}

.support-switch-bug {
  border: 1px solid #f59e0b;
  background: #fff;
  color: #b45309;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}

.support-label {
  display: block;
  margin: 0.65rem 0 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate-800);
}

.support-label .req {
  color: var(--red-600);
}

.support-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
}

.support-textarea {
  resize: vertical;
  min-height: 96px;
}

.support-file {
  width: 100%;
  font-size: 0.85rem;
}

.support-bug-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.support-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--slate-200);
}

.support-alert {
  margin: 0.65rem 0 0;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.support-alert[hidden] {
  display: none !important;
}

.support-alert-err {
  background: var(--red-50);
  color: var(--red-700);
  border: 1px solid var(--red-100);
}

.support-alert-ok {
  background: var(--green-50);
  color: var(--green-700);
  border: 1px solid var(--green-100);
}

.support-bug-submit {
  margin-top: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #d97706;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 0.95rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.support-bug-submit svg {
  width: 15px;
  height: 15px;
}

.support-bug-submit:hover:not(:disabled) {
  background: #b45309;
}

.support-bug-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

@media (max-width: 480px) {
  .support-fab {
    right: 14px;
    bottom: 14px;
  }

  .support-faq-chat {
    height: 200px;
  }

  .chat-fab {
    right: 14px;
    bottom: 70px;
  }

  .chat-panel {
    right: 14px;
    bottom: 126px;
  }
}

/* ── Live chat FAB + panel (user↔admin) ─────────────────────────────────── */
.chat-fab {
  position: fixed;
  right: 18px;
  bottom: 74px;
  z-index: 1101;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: #dc2626;
  color: #fff;
  box-shadow: 0 8px 22px rgba(220, 38, 38, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.chat-fab svg {
  width: 22px;
  height: 22px;
}

.chat-fab:hover {
  background: #b91c1c;
  transform: scale(1.05);
  color: #fff;
}

.chat-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font: 700 10px/18px system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

.chat-panel {
  position: fixed;
  right: 18px;
  bottom: 130px;
  z-index: 1151;
  width: min(420px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 160px));
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--slate-800);
}

.chat-panel[hidden] {
  display: none !important;
}

.chat-panel.is-user .chat-head {
  align-items: flex-start;
  padding: 14px;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--teal-700);
  color: #fff;
}

.chat-head-back,
.chat-head-close {
  border: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
}

.chat-head-back svg {
  width: 18px;
  height: 18px;
}

.chat-head-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.45);
}

.chat-head-avatar svg {
  width: 20px;
  height: 20px;
}

.chat-head-text {
  flex: 1;
  min-width: 0;
}

.chat-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-sub {
  font-size: 0.75rem;
  opacity: 0.88;
  margin-top: 2px;
  line-height: 1.35;
}

.chat-panel.is-user .chat-title,
.chat-panel.is-user .chat-sub {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--slate-50);
}

.chat-threads {
  flex: 1;
  overflow-y: auto;
  background: #fff;
}

/* Author `display:flex` on .chat-conversation beats UA [hidden]; force hide. */
.chat-threads[hidden],
.chat-conversation[hidden] {
  display: none !important;
}

.chat-thread {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--slate-100);
  background: #fff;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: inherit;
  font: inherit;
}

.chat-thread:hover {
  background: var(--teal-50);
}

.chat-thread-meta {
  flex: 1;
  min-width: 0;
}

.chat-thread-name {
  font-weight: 650;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread-preview {
  font-size: 0.78rem;
  color: var(--slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-thread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font: 700 10px/18px system-ui, sans-serif;
  text-align: center;
  flex-shrink: 0;
}

.chat-conversation {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--slate-400);
  padding: 24px;
  font-size: 0.88rem;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 260px;
}

.chat-welcome-ico {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--teal-100);
  color: var(--teal-700);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.chat-welcome-ico svg {
  width: 24px;
  height: 24px;
}

.chat-welcome-title {
  font-weight: 700;
  color: var(--slate-800);
  font-size: 0.95rem;
}

.chat-welcome-sub {
  font-size: 0.82rem;
  color: var(--slate-500);
  line-height: 1.4;
}

.chat-msg-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 88%;
}

.chat-msg-row.mine {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg-row.theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 2px;
}

.chat-msg-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal-100);
  color: var(--teal-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-msg-avatar svg {
  width: 14px;
  height: 14px;
}

.chat-msg-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--slate-500);
}

.chat-bubble {
  max-width: 100%;
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble.me {
  background: var(--teal-700);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.them {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-bottom-left-radius: 4px;
}

.chat-time {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  opacity: 0.72;
}

.chat-foot {
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid var(--slate-200);
}

.chat-send-err {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--red-600);
}

.chat-send-err[hidden] {
  display: none !important;
}

.chat-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  min-width: 0;
}

.chat-composer textarea {
  flex: 1;
  width: 100%;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 0.55rem 2.4rem 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  box-sizing: border-box;
}

.chat-attach-btn {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--slate-500);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-attach-btn svg {
  width: 18px;
  height: 18px;
}

.chat-attach-btn:hover:not(:disabled) {
  color: var(--teal-700);
  background: var(--teal-50);
}

.chat-attach-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.chat-bubble.has-img {
  padding: 6px;
}

.chat-img-link {
  display: block;
  line-height: 0;
}

.chat-img {
  display: block;
  max-width: min(220px, 100%);
  max-height: 240px;
  width: auto;
  height: auto;
  border-radius: 8px;
  object-fit: cover;
}

.chat-bubble.me .chat-img {
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-img-caption {
  margin-top: 6px;
  padding: 0 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--teal-700);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-send-btn svg {
  width: 16px;
  height: 16px;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--teal-800);
}

.chat-send-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.admin-otp-modal {
  z-index: 1200;
}

.admin-otp-card {
  max-width: 420px;
  width: min(420px, calc(100vw - 2rem));
  text-align: left;
  padding: 1.25rem 1.35rem 1.35rem;
}

.admin-otp-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  padding-right: 1.75rem;
}

.admin-otp-desc {
  margin: 0 0 0.85rem;
  line-height: 1.45;
}

.admin-otp-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  align-items: stretch;
}

.admin-otp-form .field {
  width: 100%;
}

.admin-otp-form .field span {
  font-size: 0.75rem;
}

.admin-otp-form .btn {
  width: 100%;
  justify-content: center;
  min-height: 42px;
}

.admin-otp-msg {
  margin: 0;
  min-height: 1.1em;
}

.admin-otp-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.15rem;
}

.admin-otp-actions .btn {
  width: 100%;
  min-height: 42px;
}

.admin-otp-msg.err {
  color: var(--red-600);
}
