:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #EEF4FF;
  --background: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-secondary: #64748B;
  --muted: #94A3B8;
  --success: #10B981;
  --success-soft: #ECFDF5;
  --warning: #F59E0B;
  --warning-soft: #FFFBEB;
  --danger: #EF4444;
  --danger-soft: #FEF2F2;
  --sidebar: 236px;
  --header: 64px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 8px 20px rgba(15, 23, 42, .06);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--background); }
html, body { margin: 0; min-height: 100%; }
body, .app-body, body.admin-app {
  font-family: var(--font);
  background: var(--background);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Brand */
.brand-area {
  min-height: 0;
  padding: 4px 8px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .02em;
}
.brand-copy strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .12em;
  line-height: 1.1;
}
.brand-copy small {
  display: block;
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
}
.brand-tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}

/* Sidebar */
.app-sidebar, .admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar);
  padding: 14px 10px 18px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.side-label {
  margin: 16px 12px 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.side-nav, .tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-link, .tab {
  display: flex !important;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 8px 12px !important;
  border: 0 !important;
  border-radius: 9px !important;
  background: transparent !important;
  color: #475569 !important;
  font: 600 13.5px var(--font) !important;
  letter-spacing: 0 !important;
  text-align: left;
  text-decoration: none;
  box-shadow: none !important;
  transform: none !important;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.side-link svg, .tab svg, .side-link i, .tab i, .tab-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
}
.tab-icon { display: grid; place-items: center; }
.side-link:hover, .tab:hover {
  background: #F5F7FA !important;
  color: var(--text) !important;
  transform: none !important;
  box-shadow: none !important;
}
html[data-tab] .tab.active {
  background: transparent !important;
  color: #475569 !important;
  box-shadow: none !important;
}
.side-link.active,
html[data-tab="overview"] .tab[onclick="switchTab('overview')"],
html[data-tab="runmanager"] .tab[onclick="switchTab('runmanager')"],
html[data-tab="mail"] .tab[onclick="switchTab('mail')"],
html[data-tab="proxy"] .tab[onclick="switchTab('proxy')"],
html[data-tab="sim"] .tab[onclick="switchTab('sim')"],
html[data-tab="success"] .tab[onclick="switchTab('success')"],
html[data-tab="downloadtool"] .tab[onclick="switchTab('downloadtool')"],
html[data-tab="ops"] .tab[onclick="switchTab('ops')"],
html[data-tab="account"] .tab[onclick="switchTab('account')"] {
  background: #EEF4FF !important;
  color: #2563EB !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

/* Shell / header */
.app-shell, .admin-shell { margin-left: var(--sidebar); min-height: 100vh; }
.app-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(15, 23, 42, .35);
}
.top-header, .admin-top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header);
  min-height: var(--header);
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}
.top-header h1, .page-title {
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.35;
}
.top-header p, .page-sub, .top-copy p,
.top-header #pageSubtitle { display: none; }
.crumb {
  color: var(--text);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.header-identity { min-width: 0; flex: 1; }
.header-actions, .top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.header-link, .top-actions .btn {
  min-height: 36px;
  border-radius: 9px;
  font-size: 13px;
}
.menu-btn { display: none; }
.system-chip, .role-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #d1fae5;
  border-radius: 999px;
  background: var(--success-soft);
  color: #065f46;
  font-size: 12px;
  font-weight: 600;
}
.system-chip:before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
}

.app-main, .admin-main, .container {
  max-width: min(1760px, 96vw);
  margin: 0 auto !important;
  padding: 24px 28px 40px !important;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  min-height: calc(100vh - var(--header));
}
body.app-body .container { margin-left: 0 !important; width: auto !important; }

.title-box { display: none !important; }

.tab-content { display: none; }
.tab-content.active { display: block; }
html[data-tab] .tab-content { display: none !important; }
html[data-tab="overview"] #overview,
html[data-tab="runmanager"] #runmanager,
html[data-tab="mail"] #mail,
html[data-tab="proxy"] #proxy,
html[data-tab="sim"] #sim,
html[data-tab="success"] #success,
html[data-tab="downloadtool"] #downloadtool,
html[data-tab="ops"] #ops,
html[data-tab="account"] #account { display: block !important; }

.page-intro { margin-bottom: 16px; }
.page-intro h2, .page-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -.03em;
  line-height: 1.2;
}
.page-intro p, .page-head p { margin: 6px 0 0; color: var(--text-secondary); font-size: 13.5px; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-head .btn-primary { min-height: 40px; border-radius: 9px; }

/* Buttons */
.btn, .header-link, .button-container button, .button-container .btn,
.account-actions button, .btn-action, .pw-btn, .na-btn-primary, .na-btn-ghost,
#runmanager .start-btn, #runmanager .stop-btn, #runmanager .update-btn,
#runmanager .starttool-btn, #runmanager .stoptool-btn,
#runmanager .schedule-row button, .token-create button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--surface);
  color: #334155;
  font: 600 13px var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: none;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.btn svg, .header-link svg { width: 16px; height: 16px; }
.btn-primary, .button-container button:not(.delete-btn):not(.download-sim-btn):not(.secondary-btn),
.account-actions button, .pw-btn, .na-btn-primary, #runmanager .start-btn,
#runmanager #saveAutoStopBtn, .token-create button, .btn-action--success {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover, .button-container button:not(.delete-btn):not(.download-sim-btn):not(.secondary-btn):hover,
.account-actions button:hover, #runmanager .start-btn:hover, #runmanager #saveAutoStopBtn:hover,
.token-create button:hover {
  background: var(--primary-hover);
  color: #fff;
}
.btn-secondary, .btn-ghost, .header-link, .na-btn-ghost, .pw-btn-light,
.auto-stop-controls .secondary-btn, .schedule-row .secondary-btn, .download-sim-btn {
  background: #fff;
  border-color: var(--border);
  color: #334155;
}
.btn-ghost:hover, .header-link:hover, .btn-secondary:hover,
.schedule-row .secondary-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-danger, .delete-btn, .pw-btn.danger, .btn-action--danger, #runmanager .stop-btn,
#runmanager .stoptool-btn, .na-btn-primary.is-danger {
  background: #fff !important;
  color: var(--danger) !important;
  border: 1px solid #fecaca !important;
}
.na-btn-primary.is-danger {
  background: var(--danger) !important;
  color: #fff !important;
  border-color: var(--danger) !important;
}
.btn-danger:hover, .delete-btn:hover, #runmanager .stop-btn:hover,
#runmanager .stoptool-btn:hover { background: var(--danger-soft) !important; }
.btn-danger-soft, .btn-action--danger-soft {
  background: var(--danger-soft);
  color: #b91c1c;
  border-color: #fecaca;
}
.btn-action--warning, #runmanager .update-btn {
  background: var(--warning-soft) !important;
  color: #b45309 !important;
  border: 1px solid #fde68a !important;
}
#runmanager .update-btn:hover { background: #FEF3C7 !important; }
#runmanager .starttool-btn {
  background: var(--success-soft) !important;
  color: #047857 !important;
  border: 1px solid #a7f3d0 !important;
}
#runmanager .starttool-btn:hover { background: #d1fae5 !important; }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: 12px; }
.btn-block { width: 100%; min-height: 42px; }
.btn:disabled, .btn.is-loading, button:disabled { opacity: .6; cursor: wait; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.icon-btn:hover { background: #f1f5f9; }
.icon-btn.danger { color: var(--danger); border-color: #fecaca; }
.header-link.warn { border-color: #fde68a; background: var(--warning-soft); color: #92400e; }

/* Forms */
.field { display: grid; gap: 7px; }
.field label, .field > span {
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}
input[type=text], input[type=password], input[type=number], input[type=time],
select, textarea, .field input, .field select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: 500 14px var(--font);
  outline: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea, .import-textarea {
  min-height: 132px;
  max-height: 320px;
  padding: 12px 14px !important;
  resize: vertical;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  border-color: #93c5fd !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
  background: #fff !important;
}
.input-wrap { position: relative; }
.input-wrap input { padding-right: 78px; }
.input-tool {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.input-tool:first-of-type { right: 38px; }
.input-tool:hover { background: #f1f5f9; }

/* Cards */
.panel-card, .account-card, .card {
  padding: 18px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
#runmanager, #proxy, #sim {
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.panel-heading, .card-head, .account-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.heading-icon, .card-icon, .kpi-icon, .stat-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}
.panel-heading .heading-icon, .card-head .card-icon { margin-bottom: 0; }
.heading-icon svg, .kpi-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.panel-heading h3, .card-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.panel-heading p, .card-head p { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; }

/* KPI */
.kpi-grid, .overview-grid, .stat-row, .stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card, .overview-card, .stat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 0;
  padding: 14px 16px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  appearance: none;
  font-family: inherit;
  color: inherit;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.stat-card { cursor: default; }
button.kpi-card, button.overview-card { cursor: pointer; }
.kpi-card:hover, .overview-card:hover, .management-card:hover, .report-list button:hover,
.download-actions .btn:hover, #downloadtool .download-item:hover {
  border-color: #D7E3F4;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.kpi-card-header, .kpi-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.kpi-title, .stat-label, .stat-card small {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.kpi-value, .stat-value, .stat-card strong {
  display: block;
  margin: 6px 0 2px;
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--text);
}
.kpi-label, .stat-note { display: block; color: var(--text-secondary); font-size: 12px; }
.kpi-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.kpi-icon svg, .stat-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.85; }
.kpi-mail .kpi-icon, .stat-icon.mail { background: var(--primary-soft); color: var(--primary); }
.kpi-proxy .kpi-icon, .stat-icon.db { background: #EEF2FF; color: #4F46E5; }
.kpi-sim .kpi-icon { background: var(--success-soft); color: #059669; }
.kpi-completed .kpi-icon, .stat-icon.used { background: var(--warning-soft); color: #D97706; }

.mgmt-board { margin-top: 4px; }
.mgmt-board-head { margin-bottom: 18px; }
.mgmt-board-head h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.mgmt-board-head p { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; }
.mgmt-section:last-child { margin-bottom: 0; }
.mgmt-section h3 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.management-grid, .report-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
.management-grid.data-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.management-card, .report-list button {
  position: relative;
  display: flex;
  height: 100%;
  min-height: 124px;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px 20px 16px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.mgmt-ico {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 4px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}
.mgmt-ico svg, .heading-icon i, .heading-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
}
.management-card:hover, .report-list button:hover {
  border-color: #D7E3F4;
}
.management-card:after, .report-list button:after {
  content: "→";
  position: absolute;
  right: 14px;
  top: 14px;
  color: var(--muted);
}
.management-card > span:not(.mgmt-ico), .report-list button > span:not(.mgmt-ico) {
  padding-right: 22px;
  font-size: 14px;
  font-weight: 700;
}
.management-card small, .report-list small { color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.management-card b, .report-list b {
  margin-top: auto;
  padding: 0;
  background: none;
  color: var(--primary);
  font-size: 12px;
}

/* Tables */
.table-responsive {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  overflow: auto;
}
.table { margin: 0; font-size: 13px; }
.table th {
  position: sticky;
  top: 0;
  padding: 14px 16px;
  background: #f8fafc !important;
  color: #475569 !important;
  border-color: var(--border);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.table td {
  padding: 16px;
  border-color: #f1f5f9;
  color: #334155;
  vertical-align: middle;
}
.table tbody tr:hover { background: #f8fafc; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.data-table th, .table th {
  color: #64748B !important;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: #F8FAFC !important;
}
.data-table td {
  height: 68px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8fafc; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge-green { background: var(--success-soft); color: #065f46; }
.badge-red { background: var(--danger-soft); color: #991b1b; }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-slate { background: #f1f5f9; color: #475569; }

/* Alerts / empty / toast */
.form-message, .alert, .impersonate-banner, .stock-alert, .security-notice {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
}
.form-message.success, .toast-success { border: 1px solid #a7f3d0; background: var(--success-soft); color: #065f46; }
.form-message.error, .alert-danger { border: 1px solid #fecaca; background: var(--danger-soft); color: #991b1b; }
.impersonate-banner, .stock-alert.warning { border: 1px solid #fde68a; background: var(--warning-soft); color: #92400e; }
.stock-alert.danger { border: 1px solid #fecaca; background: var(--danger-soft); color: #991b1b; }
.security-notice { display: flex; gap: 12px; border: 1px solid #dbeafe; background: var(--primary-soft); color: #1e40af; }
.empty-state {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: 28px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
}
.empty-state h3 { margin: 0; font-size: 16px; }
.empty-state p { margin: 6px 0 16px; color: var(--text-secondary); max-width: 360px; }

.toasts, .na-toast-wrap {
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 90;
  display: grid;
  gap: 8px;
}
.toast, .na-toast {
  min-width: 260px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}
.toast { opacity: 0; transform: translateY(-6px); transition: .18s ease; }
.toast.show { opacity: 1; transform: none; }

/* Modals */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  z-index: 60;
}
/* Backdrop phải NẰM DƯỚI thẻ nội dung (.pw-dialog z-index:1), nếu để z-index:60 nó
   sẽ đè lên trên làm modal bị xám và chặn hết click (không gõ/bấm được). */
.pw-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  z-index: 0;
}
.na-modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(15, 23, 42, .35);
}
.modal, .pw-modal, .na-modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 80;
  padding: 20px;
}
.modal:not([hidden]), .pw-modal.show, .na-modal:not([hidden]) { display: grid; }
.na-modal[hidden] {
  display: none !important;
  pointer-events: none !important;
}
/* ===== Data table "Danh sách tài khoản" (Mail đã làm) — SaaS style ===== */
.dt-scroll { max-height: 620px; overflow: auto; scrollbar-width: thin; }
.dt-scroll::-webkit-scrollbar { height: 10px; width: 10px; }
.dt-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid #fff; }
/* table-layout: fixed + width 100% → toàn bộ cột co vừa khung, KHÔNG cần kéo ngang để xem Status */
.accounts-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.accounts-table th,
.accounts-table td {
  padding: 9px 10px;
  font-size: 12.5px;
  /* Mọi ô cắt gọn 1 dòng (…) để bảng vừa khung; dữ liệu đầy đủ xem qua tooltip / bấm copy */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.accounts-table thead th { position: sticky; top: 0; z-index: 2; }
.accounts-table td.col-num, .accounts-table th.col-num { text-align: center; }

/* Bề rộng từng cột (table-layout: fixed sẽ co theo tỉ lệ cho vừa 100% khung) */
.accounts-table [data-col="stt"]       { width: 42px; }
.accounts-table [data-col="email"]     { width: 190px; }
.accounts-table [data-col="password"]  { width: 120px; }
.accounts-table [data-col="2fa"]       { width: 120px; }
.accounts-table [data-col="country"]   { width: 110px; }
.accounts-table [data-col="yeargmail"] { width: 78px; }
.accounts-table [data-col="link"]      { width: 150px; }
.accounts-table [data-col="video"]     { width: 66px; }
.accounts-table [data-col="sub"]       { width: 66px; }
.accounts-table [data-col="view"]      { width: 74px; }
.accounts-table [data-col="year"]      { width: 66px; }
.accounts-table [data-col="voice"]     { width: 84px; }
.accounts-table [data-col="ads"]       { width: 74px; }
.accounts-table [data-col="phone"]     { width: 110px; }
.accounts-table [data-col="api"]       { width: 120px; }
.accounts-table [data-col="status"]    { width: 150px; }

/* Các ô có span copy/mask bên trong cũng cắt gọn theo bề rộng cột (bấm/hover vẫn lấy đủ) */
.accounts-table td[data-col="email"] .cell-copy,
.accounts-table td[data-col="link"] .cell-copy,
.accounts-table td[data-col="password"] .cell-copy,
.accounts-table td[data-col="2fa"] .cell-copy,
.accounts-table td[data-col="api"] .cell-copy {
  display: inline-block; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
}
.accounts-table tbody tr:hover { background: #f8fafc; }
/* Mail đã làm xong (status = worker/success) → hàng xanh lá nhạt; lỗi → hồng nhạt */
.accounts-table tbody tr.row-success { background: #ecfdf5; }
.accounts-table tbody tr.row-success:hover { background: #d1fae5; }
.accounts-table tbody tr.row-success td[data-col="email"] { color: #047857; font-weight: 600; }
.accounts-table tbody tr.row-danger { background: #fff5f5; }
.accounts-table tbody tr.row-danger:hover { background: #fee2e2; }
.cell-empty { color: var(--muted); }
.cell-copy { cursor: pointer; border-bottom: 1px dashed transparent; transition: color .12s, border-color .12s; }
.cell-copy:hover { color: var(--primary); border-bottom-color: rgba(37,99,235,.35); }
.cell-copy.copied { color: var(--success); }
.cell-mask { cursor: pointer; letter-spacing: 1px; color: var(--text-secondary); user-select: none; }
.cell-mask[data-shown="1"] { letter-spacing: 0; color: var(--text); font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }

/* Status badges */
.badge-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.4;
  max-width: none; overflow: visible; text-overflow: clip; white-space: nowrap;
}
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge-success { background: var(--success-soft); color: #047857; }
.badge-danger  { background: var(--danger-soft);  color: #b91c1c; }
.badge-warning { background: var(--warning-soft); color: #b45309; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* Stat description */
.stat-desc { margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 500; }

/* Data table toolbar */
.dt-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 4px 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.dt-search {
  position: relative; display: flex; align-items: center; flex: 1 1 280px; max-width: 420px;
}
.dt-search > i { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.dt-search input {
  width: 100%; height: 40px; padding: 0 36px 0 36px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  font: 500 13.5px var(--font); color: var(--text); outline: none; transition: border-color .12s, box-shadow .12s;
}
.dt-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.dt-search-clear {
  position: absolute; right: 8px; width: 24px; height: 24px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer;
}
.dt-search-clear:hover { background: #f1f5f9; color: var(--text); }
.dt-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  color: var(--text-secondary); font: 600 13px var(--font); text-decoration: none; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn-ghost:hover { background: #f8fafc; border-color: #cbd5e1; color: var(--text); }
.btn-ghost i { width: 16px; height: 16px; }
.btn-ghost.sm { height: 32px; padding: 0 10px; font-size: 12px; }

/* Columns dropdown */
.dt-dropdown { position: relative; }
.dt-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 210px; padding: 8px; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md);
  animation: dtPop .12s ease;
}
@keyframes dtPop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dt-menu-title { padding: 4px 8px 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.dt-check {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
.dt-check:hover { background: #f8fafc; }
.dt-check input { width: 15px; height: 15px; accent-color: var(--primary); }
.dt-menu-foot { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* Data table footer / pagination */
.dt-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.dt-footer-info { display: flex; align-items: center; gap: 16px; color: var(--text-secondary); font-size: 13px; }
.dt-perpage { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 13px; }
.dt-perpage select {
  height: 34px; padding: 0 26px 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font: 500 13px var(--font); color: var(--text); cursor: pointer;
}
.dt-pager { display: inline-flex; align-items: center; gap: 4px; }
.dt-page {
  display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  color: var(--text-secondary); font: 600 13px var(--font); text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.dt-page:hover { background: #f8fafc; border-color: #cbd5e1; color: var(--text); }
.dt-page.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.dt-page.disabled { opacity: .45; pointer-events: none; }
.dt-page i { width: 16px; height: 16px; }
.dt-gap { padding: 0 4px; color: var(--muted); }

.modal-card, .pw-dialog, .na-modal-box {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  padding: 24px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-md);
  animation: popIn .18s ease;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.modal-card h3, .na-modal-box h3, .pw-title { margin: 0; font-size: 18px; }
.modal-card p, .na-modal-box p { margin: 8px 0 0; color: var(--text-secondary); }
.modal-actions, .na-modal-actions, .pw-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.pw-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -22px -22px 16px;
  padding: 16px 18px;
  background: #f8fafc !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border);
}
.pw-header.danger { background: var(--danger-soft) !important; color: #991b1b !important; }
.pw-close { margin-left: auto; border: 0; background: transparent; color: var(--text-secondary); font-size: 20px; cursor: pointer; }
.reveal-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  background: var(--success-soft);
}
.reveal-box code { display: block; margin: 6px 0 10px; word-break: break-all; }
.api-key-box {
  margin-top: 0;
  margin-bottom: 14px;
}
.api-key-box small {
  display: block;
  color: #047857;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.api-key-box code {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.5;
}
.api-key-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.api-key-copy {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
}

/* Workspace extras */
.button-container, .import-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.import-card .import-hint {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}
.import-footer {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.import-footer .delete-btn { margin-left: auto; }
.download-actions, #downloadtool .download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.download-actions .btn, #downloadtool .download-item, .download-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  white-space: normal;
  text-align: left;
}
.download-actions .btn:hover, #downloadtool .download-item:hover, .download-card:hover {
  border-color: #bfdbfe;
  background: #f8fbff;
  color: var(--primary);
}
.download-actions strong, .download-card strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
  color: inherit;
}
.download-actions small, #downloadtool .download-item span, .download-card small {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  line-height: 1.45;
}
#downloadtool .download-item .mgmt-ico,
.download-actions .mgmt-ico { margin-bottom: 6px; }
.download-header p { max-width: 640px; color: var(--text-secondary); }
.account-form { display: grid; gap: 14px; }
.account-form .field input { max-width: 480px; }
.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.ops-grid .field input,
.token-create .field input { max-width: none; }
.ops-checks {
  display: grid;
  gap: 8px;
}
.ops-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ops-checks label:has(input:checked) {
  border-color: #93c5fd;
  background: var(--primary-soft);
  color: var(--primary);
}
.token-create {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}
.token-create .field {
  flex: 1 1 220px;
  max-width: 360px;
}
.success-actions {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}
.success-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.success-actions .btn-action { min-height: 38px; gap: 7px; }
.success-actions .btn-action i { width: 16px; height: 16px; flex: 0 0 auto; }
.success-actions .btn-action--danger { margin-left: auto; }
.action-sep { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--border); }
@media (max-width: 640px) { .action-sep { display: none; } }
@media (max-width: 640px) {
  .ops-grid { grid-template-columns: 1fr; }
  .token-create .field { max-width: none; }
  .success-actions .btn-action { width: 100%; }
  .success-actions .btn-action--danger { margin-left: 0; }
}
.form-section-title {
  margin: 8px 0 0;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.api-sample {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}
.mail-file-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.mail-file-name { color: var(--text-secondary); font-size: 13px; }
.mail-file-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}
.mail-file-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.mail-upload-progress { margin-top: 12px; }
.mail-upload-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.mail-upload-bar span { display: block; height: 100%; width: 0; background: var(--primary); }
.auto-stop-card {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.auto-stop-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.auto-stop-controls input { width: auto; min-width: 140px; }
.cmd-row {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}
.cmd-tag {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

/* Control Center — run manager */
.run-section { margin-bottom: 14px; }
.run-section .panel-heading { margin-bottom: 14px; }
.choice-block + .choice-block { margin-top: 16px; }
.choice-block h4, .task-group h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.choice-grid, .task-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 8px;
}
.choice-grid-sm { max-width: 180px; }
.choice-grid label, .task-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, color .15s ease;
}
.choice-grid label:hover, .task-options label:hover {
  border-color: #bfdbfe;
  background: var(--primary-soft);
}
.choice-grid label:has(input:checked),
.task-options label:has(input:checked) {
  border-color: #93c5fd;
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
  color: var(--primary);
}
.choice-grid input, .task-options input { accent-color: var(--primary); }
.task-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.task-group {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #F8FAFC;
}
.run-actions {
  position: sticky;
  bottom: 12px;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-md);
}
.status-banner:empty { display: none; }
.status-banner {
  margin: 0 0 14px;
  padding: 12px 16px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: var(--primary-soft);
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}
.status-banner.is-live {
  border-color: #a7f3d0;
  background: var(--success-soft);
  color: #065f46;
}
.status-banner.is-warn {
  border-color: #fde68a;
  background: var(--warning-soft);
  color: #92400e;
}
.cmd-copy { min-width: 0; }
.cmd-copy strong { display: block; font-size: 13px; font-weight: 700; color: var(--text); }
.cmd-copy p { margin: 4px 0 0; }
.schedule-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}
.schedule-row .field {
  flex: 1 1 180px;
  max-width: 240px;
}
.schedule-row button { min-height: 42px; }
.schedule-status {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}
input.is-invalid, textarea.is-invalid {
  border-color: #fecaca !important;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, .12);
}
.stock-alerts { display: grid; gap: 8px; margin: 0 0 16px; }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.help-details {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 12px;
}
.help-details summary { cursor: pointer; font-weight: 600; }

.user-identity { display: flex; gap: 12px; align-items: center; }
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
}
.avatar + div h4 { margin: 0; font-size: 15px; font-weight: 650; }
.avatar + div p { margin: 2px 0 0; color: var(--text-secondary); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 600; }
.action-menu { position: relative; }
.action-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  min-width: 212px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-md);
  animation: popIn .16s ease;
}
.action-menu-list[hidden] { display: none; }
.action-menu-list .btn, .action-menu-list form { width: 100%; margin: 0; }
.action-menu-list .btn {
  justify-content: flex-start;
  min-height: 36px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-weight: 600;
}
.action-menu-list .btn:hover { background: #F5F7FA; }
.action-menu-list .btn.menu-danger { color: var(--danger); }
.action-menu-list .btn.menu-danger:hover { background: var(--danger-soft); }
.toolbar {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.search-field {
  position: relative;
  width: min(100%, 360px);
}
.search-field svg, .search-field i {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.search-field input,
.toolbar input,
input.user-search {
  width: 100%;
  max-width: 360px;
  min-height: 40px;
  padding: 0 12px 0 38px;
  border: 1px solid #E2E8F0;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font: 500 14px var(--font);
  appearance: none;
  -webkit-appearance: none;
}
.search-field input:focus,
.toolbar input:focus,
input.user-search:focus {
  border-color: #93c5fd !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}
.stock-metrics, .mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 20px;
  color: var(--text-secondary);
  font-size: 12px;
}
.stock-metrics span {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #F8FAFC;
  white-space: nowrap;
}
.stock-metrics small, .mini-stats small { color: var(--muted); font-weight: 600; }
.stock-metrics b, .mini-stats b { color: var(--text); font-size: 13px; font-weight: 700; }

@media (max-width: 1200px) {
  .kpi-grid, .overview-grid, .stat-row, .stats-grid,
  .management-grid.data-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .management-grid, .report-list, .download-actions, #downloadtool .download-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-main, .admin-main, .container { padding: 24px !important; }
}
@media (max-width: 900px) {
  .menu-btn { display: inline-grid; }
  .app-sidebar, .admin-sidebar {
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  body.sidebar-open .app-sidebar,
  body.sidebar-open .admin-sidebar { transform: none; }
  body.sidebar-open .app-overlay { display: block; }
  .app-shell, .admin-shell { margin-left: 0; }
  .top-header, .admin-top, .app-main, .admin-main, .container { padding-left: 16px; padding-right: 16px; }
  .app-main, .admin-main, .container { padding: 16px !important; }
  .tab-label { display: inline; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn-primary { width: 100%; }
  .task-board { grid-template-columns: 1fr; }
  .import-footer .delete-btn { margin-left: 0; }
}
@media (max-width: 640px) {
  .kpi-grid, .overview-grid, .stat-row, .stats-grid,
  .management-grid, .report-list, .download-actions, #downloadtool .download-grid {
    grid-template-columns: 1fr;
  }
  .page-intro h2, .page-head h2 { font-size: 22px; }
  .button-container button, .button-container .btn, .account-actions button,
  .import-footer button, .import-footer .btn, .run-actions button { width: 100%; }
  .header-actions .header-link:not(.warn) { display: none; }
  .data-table, .users-table { min-width: 760px; }
  .management-grid.data-grid { grid-template-columns: 1fr; }
  .run-actions { position: static; }
  .choice-grid, .task-options { grid-template-columns: 1fr; }
}

.stats-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats-grid-6 .stat-value { font-size: 22px; margin-top: 8px; }
@media (max-width: 900px) {
  .stats-grid-3, .stats-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .stats-grid-2, .stats-grid-3, .stats-grid-6 { grid-template-columns: 1fr; }
}
.modal-form { display: grid; gap: 12px; margin-top: 14px; }
.user-row.is-disabled { opacity: .62; }
.users-table td:last-child { width: 56px; text-align: right; }
.toast.toast-success { background: #fff; color: #065f46; border: 1px solid #a7f3d0; }
.toast.toast-error { background: #fff; color: #991b1b; border: 1px solid #fecaca; }
.toast.toast-warning { background: #fff; color: #92400e; border: 1px solid #fde68a; }
.toast.toast-info { background: #fff; color: #1e40af; border: 1px solid #bfdbfe; }
.login-visual .brand-area { min-height: 0; margin: 0 0 28px; padding: 0; border: 0; }
.login-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: #fff;
}
.login-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 56px;
  background: #F4F7FB;
  overflow: hidden;
}
.login-visual:before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(37, 99, 235, .18) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}
.login-visual-inner {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
}
.login-visual h1 {
  margin: 0;
  max-width: 420px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.15;
  color: var(--text);
}
.login-lead {
  margin: 12px 0 28px;
  max-width: 420px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
}
.login-features { display: grid; gap: 10px; }
.login-features article {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.86);
}
.login-feat-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}
.login-feat-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.login-features h3 { margin: 0; font-size: 14px; font-weight: 700; }
.login-features p { margin: 3px 0 0; color: var(--text-secondary); font-size: 13px; line-height: 1.45; }
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background: #fff;
}
.login-card { width: min(100%, 400px); }
.login-card h2 { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.login-card .subtitle { margin: 0 0 24px; color: var(--text-secondary); font-size: 14px; line-height: 1.5; }
.login-card .field { margin-bottom: 14px; }
.login-error { display: none; margin: 0 0 14px; padding: 10px 12px; border: 1px solid #fecaca; border-radius: 10px; background: var(--danger-soft); color: #991b1b; font-size: 13px; text-align: left; }
.login-error.is-visible { display: block; }
.login-card .btn-block { margin-top: 4px; min-height: 44px; }
.login-card .btn.is-loading { pointer-events: none; }
@media (max-width: 960px) {
  .login-app { grid-template-columns: 1fr; }
  .login-visual { padding: 28px 24px 20px; }
  .login-visual h1 { font-size: 26px; }
  .login-features { grid-template-columns: 1fr; }
  .login-panel { padding: 12px 20px 40px; background: var(--background); }
  .login-card {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow);
  }
}
@media (min-width: 961px) {
  .login-card { padding: 0; border: 0; box-shadow: none; background: transparent; }
}
.na-modal-icon.is-danger, .pw-header.danger .pw-icon { background: var(--danger-soft); color: var(--danger); }
.na-modal-icon.is-success { background: var(--success-soft); color: var(--success); }
.na-btn-primary.is-danger { background: var(--danger) !important; color: #fff !important; border-color: var(--danger) !important; }
.na-modal-icon:empty, .pw-icon:empty { display: none; }
.na-toast.toast-success { background: #fff; color: #065f46; border: 1px solid #a7f3d0; }
.na-toast.toast-error { background: #fff; color: #991b1b; border: 1px solid #fecaca; }
.na-toast.toast-info { background: #fff; color: #1e40af; border: 1px solid #bfdbfe; }
.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
  background-size: 400% 100%;
  animation: skeleton 1.2s ease infinite;
}
@keyframes skeleton { to { background-position: -400% 0; } }

@media (max-width: 1200px) {
  .stats-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .stats-grid-6 { grid-template-columns: 1fr 1fr; }
}

/* Vận hành */
#ops { display: grid; gap: 20px; }
#ops .page-intro { margin-bottom: 0; }
#ops .ops-token-flash { margin: 0; }
#ops .ops-stock {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
#ops .ops-stock-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  transition: border-color .16s ease, box-shadow .16s ease;
}
#ops .ops-stock-card:hover { border-color: #D7E3F4; box-shadow: var(--shadow-md); }
#ops .ops-stock-ico {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}
#ops .ops-stock-card.is-warn .ops-stock-ico { background: var(--warning-soft); color: #D97706; }
#ops .ops-stock-card.is-danger .ops-stock-ico { background: var(--danger-soft); color: var(--danger); }
#ops .ops-stock-ico svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
#ops .ops-stock-copy { min-width: 0; flex: 1; }
#ops .ops-stock-label {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}
#ops .ops-stock-value {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.1;
  color: var(--text);
}
#ops .ops-stock-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: #B45309;
  font-size: 11px;
  font-weight: 700;
}
#ops .ops-stock-card.is-danger .ops-stock-badge {
  background: var(--danger-soft);
  color: #B91C1C;
}
#ops .ops-card {
  padding: 20px 20px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  transition: border-color .16s ease, box-shadow .16s ease;
}
#ops .ops-card:hover { border-color: #E8EEF6; }
#ops .ops-card-pad { padding: 24px; }
#ops .ops-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
#ops .ops-card-head .panel-heading { margin: 0; }
#ops .ops-card > .panel-heading { margin-bottom: 16px; }
#ops .ops-count-badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #F8FAFC;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
#ops .ops-table-wrap { position: relative; }
#ops .ops-skeleton {
  display: none;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 8px 0 4px;
}
#ops .ops-table-wrap.is-loading .ops-skeleton { display: grid; }
#ops .ops-table-wrap.is-loading .table-responsive { opacity: .35; pointer-events: none; }
#ops .ops-skeleton span {
  display: block;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
  background-size: 400% 100%;
  animation: skeleton 1.2s ease infinite;
}
#ops .table { font-size: 12.5px; }
#ops .table th {
  background: #F8FAFC !important;
  font-size: 11px;
}
#ops .table td { padding: 12px 14px; }
#ops .ops-empty-row td { padding: 0; border: 0; }
#ops .ops-empty {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: 40px 20px;
}
#ops .ops-empty-ico {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: #F8FAFC;
  color: #94A3B8;
  border: 1px solid var(--border);
}
#ops .ops-empty-ico svg { width: 22px; height: 22px; stroke: currentColor; fill: none; }
#ops .ops-empty h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
#ops .ops-empty p {
  margin: 6px 0 0;
  max-width: 360px;
  color: var(--text-secondary);
  font-size: 13px;
}
#ops .ops-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #F1F5F9;
  color: #475569;
}
#ops .ops-pill:before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
#ops .ops-pill.is-online { background: var(--success-soft); color: #047857; }
#ops .ops-pill.is-idle { background: #F1F5F9; color: #64748B; }
#ops .ops-form { display: grid; gap: 16px; }
#ops .ops-grid { gap: 16px; }
#ops .field input,
#ops .token-create input {
  min-height: 44px;
  border-color: #DCE3EC;
  border-radius: 8px;
}
#ops .ops-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
#ops .ops-option:hover { background: #F8FAFC; }
#ops .ops-option:has(input:checked) {
  border-color: #93c5fd;
  background: var(--primary-soft);
}
#ops .ops-option input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin-top: 2px;
  accent-color: #2563EB;
  flex: 0 0 18px;
}
#ops .ops-option strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
#ops .ops-option small {
  display: block;
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}
#ops .ops-form-actions { margin-top: 4px; }
#ops .ops-form-actions button,
#ops .token-create button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font: 600 13px var(--font);
  cursor: pointer;
  transition: background .16s ease;
}
#ops .ops-form-actions button:hover,
#ops .token-create button:hover { background: var(--primary-hover); }
#ops .ops-form-actions button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }
#ops .token-create { margin: 0; }
@media (max-width: 640px) {
  #ops .ops-stock,
  #ops .ops-card-head { grid-template-columns: 1fr; display: grid; }
  #ops .ops-form-actions button,
  #ops .token-create button { width: 100%; }
}
