/* ===========================
   IMPORT
=========================== */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700&display=swap');

/* ===========================
   DESIGN TOKENS
=========================== */
:root {
  /* Background */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;

  /* Border - Đậm hơn một chút để dễ nhìn */
  --border: #cbd5e1;
  --border-strong: #94a3b8;

  /* Text - Đen sậm và xám đậm để có độ tương phản cao */
  --text: #0f172a;
  --text-soft: #334155;
  --text-muted: #475569;
  --text-faint: #64748b;

  /* Sidebar - Nền tối, chữ trắng sáng */
  --sidebar-bg: #0f172a;
  --sidebar-text: rgba(255, 255, 255, 0.85);
  --sidebar-text-hover: #ffffff;
  --sidebar-active-bg: rgba(255, 255, 255, 0.15);
  --sidebar-active-border: rgba(255, 255, 255, 0.25);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
  --sidebar-divider: rgba(255, 255, 255, 0.1);

  /* Accent - Màu xanh dương đậm, rõ ràng rành mạch */
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-soft: #eff6ff;
  --primary-ring: rgba(29, 78, 216, 0.18);

  /* Semantic - Sáng và phân biệt rõ màu */
  --success: #15803d;
  --success-soft: #f0fdf4;
  --success-border: #bbf7d0;

  --gold: #b45309;
  --gold-soft: #fffbeb;
  --gold-border: #fde68a;

  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;

  --warning: #c2410c;
  --warning-soft: #fff7ed;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);

  /* Geometry - Cong mượt nhẹ */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Layout */
  --sidebar-w: 240px;
  --content-pad: 28px;
  --transition: 0.15s ease;
}

/* ===========================
   DARK MODE TOKENS
=========================== */
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --surface-3: #475569;

  --border: #334155;
  --border-strong: #475569;

  --text: #f8fafc;
  --text-soft: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --sidebar-bg: #020617;
  --sidebar-text: rgba(255, 255, 255, 0.75);
  --sidebar-text-hover: #ffffff;
  --sidebar-active-bg: rgba(255, 255, 255, 0.12);
  --sidebar-active-border: rgba(255, 255, 255, 0.2);

  --primary-ring: rgba(59, 130, 246, 0.3);

  --success-soft: rgba(22, 101, 52, 0.3);
  --success-border: rgba(22, 101, 52, 0.5);

  --gold-soft: rgba(180, 83, 9, 0.2);
  --gold-border: rgba(180, 83, 9, 0.4);

  --danger-soft: rgba(153, 27, 27, 0.3);
  --danger-border: rgba(153, 27, 27, 0.5);

  --warning-soft: rgba(194, 65, 12, 0.2);
}

.theme-float-btn {
  position: absolute;
  top: 14px;
  right: var(--content-pad);
  z-index: 1000;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.theme-float-btn:hover {
  background: var(--surface-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  overflow: hidden;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 15px; /* Chữ to và dễ đọc hơn */
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* ===========================
   LAYOUT
=========================== */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===========================
   SIDEBAR
=========================== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0, 0, 0, 0.20);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-divider);
}

.sidebar-brand-logo-only {
  min-height: 96px;
}

.sidebar-main-logo {
  width: 136px;
  height: auto;
  object-fit: contain;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.nav-item .nav-icon {
  width: 16px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
  opacity: 0.70;
}

.nav-item:hover {
  color: var(--sidebar-text-hover);
  background: var(--sidebar-hover-bg);
}

.nav-item.active {
  color: #fff;
  background: var(--sidebar-active-bg);
  border-color: var(--sidebar-active-border);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 9px 8px;
  border-top: 1px solid var(--sidebar-divider);
}

.sidebar-footer-note {
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.30);
  font-size: 11px;
  line-height: 1.55;
  margin-bottom: 7px;
}

.auth-user-badge {
  padding: 7px 9px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}

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

.tab-panel {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.tab-panel.active {
  display: flex;
}

/* ===========================
   PANEL HEADER
=========================== */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px calc(var(--content-pad) + 40px) 13px var(--content-pad);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-heading {
  min-width: 0;
}

.panel-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.3;
}

.panel-sub {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

/* ===========================
   SUB-TABS BAR
=========================== */
.sub-tabs-bar {
  display: flex;
  gap: 8px;
  width: 100%;
}

.sub-tab-btn {
  appearance: none;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

.sub-tab-btn:hover {
  color: var(--text);
}

.sub-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.sub-tab-content {
  display: none;
}
.sub-tab-content.active {
  display: flex !important;
}

.panel-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===========================
   FORM GRID
=========================== */
.form-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(380px, 1.1fr);
  gap: 16px;
  padding: 16px var(--content-pad) var(--content-pad);
  overflow: hidden;
}

.form-col {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.form-col::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 4px;
}

.form-col::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.form-col::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

/* ===========================
   CARDS
=========================== */
.form-card,
.toolbar-card,
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.form-card {
  padding: 18px;
}

.toolbar-card {
  margin: 14px var(--content-pad) 0;
  overflow: hidden;
}

.table-card {
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-label {
  margin: 0 0 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--text-faint);
}

.card-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.card-note {
  margin: 0;
  max-width: 210px;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.5;
}

/* ===========================
   FORM
=========================== */
form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.field.has-error label {
  color: var(--danger);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

input,
select {
  width: 100%;
  min-height: 44px; /* Cao hơn, dễ ấn trên màn hình cảm ứng */
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

input:hover,
select:hover {
  border-color: #b0b8c8;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.field.has-error input,
.field.has-error select,
input.input-error,
select.input-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.10);
}

.field-error {
  font-size: 11.5px;
  color: var(--danger);
  font-weight: 600;
  margin-top: 1px;
}

input[readonly] {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
  cursor: default;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 13px) calc(50% - 2px),
    calc(100% - 8px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* ===========================
   ASSET PANELS
=========================== */
.asset-panel {
  padding: 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gold-border);
  background: var(--gold-soft);
}

.asset-panel.hidden {
  display: none !important;
}

.asset-panel-title {
  margin: 0 0 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ===========================
   BUTTONS
=========================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px; /* Cao hơn, dễ thao tác */
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background-color var(--transition), border-color var(--transition),
    color var(--transition), box-shadow var(--transition);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.22);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-soft);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-secondary.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text-soft);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

.btn-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.btn-sm {
  min-height: 36px; /* Thay vì 28px để nút nhỏ cũng dễ bấm */
  padding: 6px 12px;
  font-size: 13.5px;
}

.btn-full {
  width: 100%;
}

.form-actions-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 4px;
}

.form-actions-inline .btn {
  min-height: 40px;
  font-size: 13.5px;
  font-weight: 700;
}

#btnCreateAccount,
#btnLogout {
  margin-top: 5px;
  width: 100%;
  justify-content: flex-start;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
}

.checkbox-inline input[type="checkbox"] {
  width: auto;
  min-height: 14px;
  margin: 0;
}

/* ===========================
   AUTH GATE
=========================== */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 12, 22, 0.72);
  backdrop-filter: blur(4px);
}

.auth-card {
  width: min(390px, 100%);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: 26px 22px 20px;
}

.auth-logo {
  width: 105px;
  height: auto;
  margin: 0 auto 10px;
}

.auth-card h2 {
  margin: 0;
  font-size: 21px;
  text-align: center;
  font-weight: 700;
  color: var(--text);
}

.auth-card p {
  margin: 5px 0 0;
  color: var(--text-muted);
  text-align: center;
  font-size: 12.5px;
}

.auth-form {
  margin-top: 16px;
}

.auth-form .btn {
  margin-top: 4px;
  width: 100%;
}

.auth-message {
  margin-top: 8px;
  min-height: 17px;
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
  text-align: center;
}

.auth-message.success {
  color: var(--success);
}

.auth-message.info {
  color: var(--primary);
}

/* ===========================
   SEARCH / FILTER
=========================== */
.search-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 11px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap::before {
  content: "⌕";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

.search-input-wrap input {
  padding-left: 32px;
}

.transaction-filter-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr)) auto;
  gap: 10px;
  padding: 0 14px 11px;
  background: var(--surface);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-field label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.filter-field input,
.filter-field select {
  min-height: 34px;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-actions .btn {
  margin-top: 0;
  min-width: 96px;
}

.scan-toolbar-card {
  margin-bottom: 0;
}

.scan-result-wrap {
  padding-top: 11px;
}

.scan-result-empty {
  border: 1px dashed var(--border-strong);
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 13px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.scan-result-empty.error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.scan-result-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 8px 13px 11px;
}

/* ===========================
   STATS / TOOLBAR
=========================== */
.stats-toolbar-card {
  margin-bottom: 0;
}

.stats-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
}

.stats-toolbar-sub {
  margin-top: 4px;
}

.stats-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dev-log-toolbar-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.dev-log-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dev-log-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.dev-log-field select {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.dev-log-box {
  margin-top: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #d8e2ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  min-height: 320px;
  max-height: 62vh;
  overflow: auto;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.statistics-wrap {
  padding-top: 11px;
}

.statistics-grid {
  display: grid;
  gap: 10px;
}

.stats-generated-at {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 9px;
}

.stats-kpi-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 13px 14px;
}

.stats-kpi-label {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-faint);
}

.stats-kpi-value {
  margin: 5px 0 0;
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stats-kpi-note {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.stats-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.stats-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.stats-section-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}

.stats-table-wrap {
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table.excel-preview-table {
  min-width: 1220px;
  table-layout: fixed;
}

.stats-table th {
  padding: 9px 13px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.stats-table td {
  padding: 9px 13px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.stats-table tbody tr:last-child td {
  border-bottom: none;
}

.stats-table td strong {
  font-weight: 700;
}

.stats-table.excel-preview-table th[data-col="1"],
.stats-table.excel-preview-table td[data-col="1"] {
  width: 56px;
  text-align: center;
}

.stats-table.excel-preview-table th[data-col="2"],
.stats-table.excel-preview-table td[data-col="2"] {
  width: 170px;
}

.stats-table.excel-preview-table th[data-col="3"],
.stats-table.excel-preview-table td[data-col="3"] {
  width: 140px;
}

.stats-table.excel-preview-table th[data-col="4"],
.stats-table.excel-preview-table td[data-col="4"] {
  width: 220px;
}

.stats-table.excel-preview-table th[data-col="5"],
.stats-table.excel-preview-table td[data-col="5"] {
  width: 220px;
}

.stats-table.excel-preview-table th[data-col="6"],
.stats-table.excel-preview-table td[data-col="6"],
.stats-table.excel-preview-table th[data-col="7"],
.stats-table.excel-preview-table td[data-col="7"] {
  width: 120px;
  white-space: nowrap;
}

.stats-table.excel-preview-table th[data-col="8"],
.stats-table.excel-preview-table td[data-col="8"],
.stats-table.excel-preview-table th[data-col="10"],
.stats-table.excel-preview-table td[data-col="10"] {
  width: 140px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.stats-table.excel-preview-table th[data-col="9"],
.stats-table.excel-preview-table td[data-col="9"] {
  width: 110px;
  text-align: center;
  white-space: nowrap;
}

.stats-table.excel-preview-table td {
  word-break: break-word;
}

.stats-empty-cell {
  color: var(--text-muted);
  text-align: center;
  font-weight: 500;
}

.stats-edit-table input {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13px;
}

.stats-edit-table td {
  white-space: nowrap;
}

.stats-edit-table td:nth-child(3),
.stats-edit-table td:nth-child(4),
.stats-edit-table td:nth-child(5),
.stats-edit-table td:nth-child(6),
.stats-edit-table td:nth-child(7) {
  min-width: 180px;
}

.stats-customer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===========================
   ACCOUNT TABLE
=========================== */
.account-table td:nth-child(5) {
  white-space: nowrap;
}

.account-table td:nth-child(6) {
  min-width: 150px;
}

.account-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.account-role-admin {
  color: var(--primary);
  border-color: #bfdbfe;
  background: var(--primary-soft);
}

.account-role-staff {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--surface-2);
}

.account-state-active {
  color: var(--success);
  border-color: var(--success-border);
  background: var(--success-soft);
}

.account-state-inactive {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.error-text {
  color: var(--danger) !important;
}

/* ===========================
   TABLE
=========================== */
.table-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px var(--content-pad) var(--content-pad);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

thead {
  background: var(--surface-2);
}

th {
  padding: 12px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 14px 14px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #fafbfc;
}

td small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.actions-cell {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

/* ===========================
   DYNAMIC ACTION BUTTONS
=========================== */
.btnDetail,
.btnPrint,
.btnDeleteTx,
.page-btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 36px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-soft);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.btnDetail:hover,
.btnDetail.active {
  color: var(--primary);
  border-color: #93c5fd;
  background: var(--primary-soft);
}

.btnPrint {
  color: var(--success);
  border-color: var(--success-border);
  background: var(--success-soft);
}

.btnPrint:hover {
  border-color: #6ee7b7;
}

.btnDeleteTx {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.btnDeleteTx:hover {
  border-color: #f87171;
}

.pagination-bar {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 11px;
}

.page-btn {
  min-width: 28px;
  text-align: center;
}

.page-btn.active {
  color: var(--primary);
  border-color: #93c5fd;
  background: var(--primary-soft);
}

.page-btn:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

/* ===========================
   STATUS BADGES
=========================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.status-dang_cam {
  background: #ecfdf5;
  color: #065f46;
}

.status-da_chuoc {
  background: var(--success-soft);
  color: var(--success);
}

.status-qua_han {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-sap_den_han {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-da_thanh_ly {
  background: var(--surface-3);
  color: var(--text-muted);
}

/* ===========================
   CUSTOMER SEARCH
=========================== */
.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
  margin-bottom: 8px;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.result-item {
  width: 100%;
  border: 1px solid #bfdbfe;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--radius-md);
  padding: 8px 11px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition);
}

.result-item:hover {
  background: #dbeafe;
}

.selected-customer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: 8px 11px;
  border-radius: var(--radius-md);
  border: 1px solid #bfdbfe;
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: 8px;
}

.selected-customer.hidden {
  display: none;
}

/* ===========================
   DETAIL PANEL
=========================== */
.transaction-detail-wrap {
  margin-top: 11px;
}

.transaction-detail-card {
  background: var(--surface);
}

.detail-placeholder {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-muted);
}

#detailText {
  color: var(--text-soft);
}

.tx-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tx-detail-item {
  padding: 10px 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.tx-detail-label {
  margin-bottom: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.tx-detail-value {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.45;
}

.tx-detail-value.is-strong {
  color: var(--text);
  font-weight: 700;
}

.tx-detail-item.tx-dev-metric {
  border-color: #c7d2fe;
  background: #eef2ff;
}

.tx-detail-actions {
  margin-top: 9px;
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  gap: 6px;
}

.btnTxAction {
  min-height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.btnTxAction:hover {
  border-color: #93c5fd;
  background: var(--primary-soft);
  color: var(--primary);
}

.btnTxAction:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.tx-actions-locked {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 500;
}

.tx-expand-row td {
  background: #fafbfc;
  padding-top: 0;
  border-top: none;
}

.tx-inline-detail {
  padding: 11px 0 6px;
  animation: txDetailReveal 0.16s ease-out;
}

@keyframes txDetailReveal {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================
   MODAL
=========================== */
body.modal-open {
  overflow: hidden;
}

.tx-edit-modal {
  position: fixed;
  inset: 0;
  z-index: 3200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.tx-edit-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 22, 0.55);
  backdrop-filter: blur(2px);
}

.tx-edit-dialog {
  position: relative;
  width: min(920px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: 18px;
}

.tx-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border);
}

.tx-edit-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.tx-edit-close {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 10px;
  transition: background var(--transition), color var(--transition);
}

.tx-edit-close:hover {
  background: var(--surface-3);
  color: var(--text-soft);
}

.tx-edit-form {
  display: grid;
  gap: 10px;
}

.tx-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.tx-edit-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 4px;
}

.tx-edit-asset-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px;
  background: var(--surface-2);
}

.tx-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 6px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

.tx-interest-dialog {
  width: min(700px, calc(100vw - 24px));
}

.tx-interest-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 11px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tx-interest-value {
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ===========================
   TOAST
=========================== */
.toast {
  position: fixed;
  top: 13px;
  right: 13px;
  z-index: 3000;
  min-width: 250px;
  max-width: min(400px, calc(100vw - 22px));
  padding: 9px 13px;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  pointer-events: none;
  animation: toastSlideIn 0.16s ease-out;
}

.toast.hidden {
  display: none !important;
}

.toast.success {
  background: #f0fdf4;
  color: #166534;
  border-color: var(--success-border);
}

.toast.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

.toast.info {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #bfdbfe;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================
   UTILITIES
=========================== */
.hidden {
  display: none !important;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 3px;
}

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

/* ===========================
   RESPONSIVE
=========================== */
@media (min-width: 1700px) {
  :root {
    --content-pad: 28px;
  }

  .panel-title {
    font-size: 19px;
  }

  .form-grid {
    grid-template-columns: minmax(360px, 1fr) minmax(480px, 1.12fr);
  }
}

@media (max-width: 1320px) {
  :root {
    --content-pad: 18px;
  }

  .form-grid {
    grid-template-columns: minmax(280px, 1fr) minmax(330px, 1.05fr);
  }
}

@media (max-width: 1180px) {
  .form-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .form-col {
    overflow: visible;
  }

  .card-note {
    max-width: none;
  }
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app-shell {
    flex-direction: column;
    min-height: 100dvh;
    height: auto;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  .sidebar-brand-logo-only {
    min-height: 72px;
  }

  .sidebar-main-logo {
    width: 116px;
  }

  .sidebar-nav {
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 6px 8px;
    gap: 4px;
    scrollbar-width: thin;
  }

  .sidebar-nav::-webkit-scrollbar {
    height: 3px;
  }

  .sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
  }

  .nav-item {
    flex: 0 0 auto;
    min-width: 108px;
    justify-content: center;
    padding: 8px 9px;
    font-size: 12.5px;
  }

  .sidebar-footer {
    border-top: none;
    padding: 5px 8px 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }

  .sidebar-footer-note {
    display: none;
  }

  .auth-user-badge {
    margin-bottom: 0;
    flex: 1 1 230px;
  }

  #btnCreateAccount,
  #btnLogout {
    width: auto;
    margin-top: 0;
    min-height: 28px;
    padding: 5px 9px;
    justify-content: center;
  }

  .main-content {
    overflow: visible;
  }

  .tab-panel {
    height: auto;
    overflow: visible;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-top: 13px;
    padding-bottom: 10px;
  }

  .panel-badge {
    align-self: flex-start;
  }

  .form-grid {
    padding: 11px var(--content-pad) var(--content-pad);
    gap: 11px;
  }

  .field-row,
  .form-actions-inline,
  .tx-detail-grid,
  .tx-detail-actions,
  .tx-edit-grid,
  .search-bar,
  .transaction-filter-bar,
  .stats-overview-grid {
    grid-template-columns: 1fr;
  }

  .card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .card-note {
    text-align: left;
  }

  .stats-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-toolbar .btn {
    width: 100%;
  }

  .stats-toolbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .dev-log-toolbar-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .tx-interest-summary {
    display: block;
  }

  .toolbar-card {
    margin: 9px var(--content-pad) 0;
  }

  .table-wrap {
    padding: 9px var(--content-pad) var(--content-pad);
    overflow: auto;
  }

  .table-card {
    overflow-x: auto;
  }

  table {
    min-width: 700px;
  }

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

  .tx-edit-dialog {
    width: min(920px, calc(100vw - 10px));
    max-height: calc(100dvh - 10px);
    padding: 13px;
  }

  .toast {
    left: 8px;
    right: 8px;
    top: 8px;
    min-width: auto;
    max-width: none;
  }
}

@media (max-width: 768px) {
  :root {
    --content-pad: 12px;
  }

  .panel-title {
    font-size: 16px;
  }

  .panel-sub {
    margin-top: 3px;
    font-size: 11.5px;
  }

  .form-card {
    padding: 12px;
    border-radius: var(--radius-md);
  }

  .asset-panel {
    padding: 10px;
  }

  .tx-detail-item {
    padding: 9px 10px;
  }

  .tx-detail-value {
    font-size: 13px;
  }

  .tx-edit-head h2 {
    font-size: 14px;
  }

  .tx-edit-actions {
    flex-direction: column-reverse;
  }

  .tx-edit-actions .btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  :root {
    --content-pad: 10px;
  }

  .sidebar-brand {
    padding: 9px 10px 8px;
  }

  .panel-title {
    font-size: 15px;
  }

  .form-card {
    padding: 10px;
  }

  .search-bar,
  .transaction-filter-bar,
  .stats-toolbar {
    padding: 8px;
  }

  th,
  td {
    padding-left: 9px;
    padding-right: 9px;
  }

  table {
    min-width: 700px;
  }
}

@media (max-width: 480px) {
  .sidebar-main-logo {
    width: 106px;
  }

  .nav-item {
    min-width: 100px;
    font-size: 12px;
  }

  input,
  select {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 13.5px;
  }

  .btn {
    min-height: 34px;
    font-size: 12.5px;
    padding: 6px 10px;
  }

  .form-actions-inline .btn {
    min-height: 38px;
    font-size: 13px;
  }

  .tx-detail-actions {
    gap: 5px;
  }
}

@media (max-height: 780px) and (min-width: 961px) {
  .sidebar-brand-logo-only {
    min-height: 80px;
  }

  .sidebar-brand {
    padding-top: 9px;
    padding-bottom: 8px;
  }

  .sidebar-nav {
    padding-top: 7px;
    padding-bottom: 7px;
    gap: 1px;
  }

  .nav-item {
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .panel-header {
    padding-top: 10px;
    padding-bottom: 9px;
  }
}
