/* ============================================================
   main.css — Polymarket Bot UI
   Light theme — màu nền chủ đạo #f9fafb
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f2faf7;
  --surface: #ffffff;
  --surface2: #eaf5f0;
  --border: #c5e3da;
  --border-dark: #9fcfc2;
  --primary: #046c53;
  --primary-hov: #035441;
  --primary-bg: #cdf0e5;
  --danger: #e53e3e;
  --danger-hov: #c53030;
  --danger-bg: #fff0f0;
  --success: #059669;
  --success-bg: #d1fae5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --info-bg: #cdf0e5;
  --text: #01241e;
  --text-muted: #3d6b5e;
  --text-light: #7aac9e;
  --radius: 10px;
  --sidebar-w: 220px;
  --shadow-sm: 0 1px 3px rgba(1, 36, 30, 0.08);
  --shadow: 0 4px 16px rgba(1, 36, 30, 0.12);
}

body {
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  /* Network nodes pattern + glow + depth gradient */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cline x1='0' y1='80' x2='30' y2='55' stroke='rgba(0,200,150,.12)' stroke-width='.8'/%3E%3Cline x1='30' y1='55' x2='55' y2='30' stroke='rgba(0,200,150,.12)' stroke-width='.8'/%3E%3Cline x1='55' y1='30' x2='100' y2='45' stroke='rgba(0,200,150,.08)' stroke-width='.8'/%3E%3Cline x1='30' y1='55' x2='70' y2='72' stroke='rgba(0,200,150,.07)' stroke-width='.6'/%3E%3Cline x1='70' y1='72' x2='100' y2='45' stroke='rgba(0,200,150,.08)' stroke-width='.6'/%3E%3Cline x1='0' y1='100' x2='30' y2='55' stroke='rgba(0,200,150,.06)' stroke-width='.6'/%3E%3Cline x1='100' y1='0' x2='55' y2='30' stroke='rgba(0,200,150,.06)' stroke-width='.6'/%3E%3Ccircle cx='0' cy='80' r='1.6' fill='rgba(0,200,150,.22)'/%3E%3Ccircle cx='30' cy='55' r='2.1' fill='rgba(0,200,150,.32)'/%3E%3Ccircle cx='55' cy='30' r='2.6' fill='rgba(0,200,150,.42)'/%3E%3Ccircle cx='70' cy='72' r='1.6' fill='rgba(0,200,150,.2)'/%3E%3Ccircle cx='100' cy='45' r='1.9' fill='rgba(0,200,150,.26)'/%3E%3Ccircle cx='0' cy='100' r='1.4' fill='rgba(0,200,150,.16)'/%3E%3Ccircle cx='100' cy='0' r='1.4' fill='rgba(0,200,150,.16)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 160% 22% at 50% 0%, rgba(0, 200, 150, 0.11) 0%, transparent 65%),
    radial-gradient(ellipse 100% 30% at 50% 108%, rgba(0, 0, 0, 0.28) 0%, transparent 65%),
    linear-gradient(175deg, #02352a 0%, #01241e 45%, #011a16 80%, #010c0a 100%);
  background-size: 100px 100px, 100% 100%, 100% 100%, 100% 100%;
  box-shadow: 2px 0 24px rgba(0, 0, 0, 0.42), inset -1px 0 0 rgba(0, 200, 150, 0.09);
}

.sidebar-brand {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0, 200, 150, 0.18);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-brand img {
  height: 44px;
  width: auto;
  min-width: 0;
  flex: 1;
  object-fit: contain;
  object-position: left center;
}

/* ── Desktop collapse button (inside sidebar-brand) ────────── */
.sidebar-collapse-btn {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid rgba(0, 200, 150, 0.2);
  border-radius: 6px;
  color: rgba(0, 200, 150, 0.5);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}
.sidebar-collapse-btn:hover {
  background: rgba(0, 200, 150, 0.1);
  border-color: rgba(0, 200, 150, 0.4);
  color: #00c896;
}

/* ── Desktop expand button (fixed, appears when collapsed) ──── */
.sidebar-expand-btn {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 50;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  transition: background 0.12s, box-shadow 0.12s;
}
.sidebar-expand-btn:hover {
  background: var(--surface2);
  box-shadow: var(--shadow);
  color: var(--primary);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.nav-section {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #3a7060;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  color: #5a9e8f;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition:
    background 0.12s,
    color 0.12s;
  border-right: 3px solid transparent;
}

.nav-link:hover {
  background: rgba(0, 200, 150, 0.07);
  color: #a8ddd4;
}
.nav-link.active {
  background: rgba(0, 200, 150, 0.14);
  color: #00e5a0;
  border-right-color: #00c896;
  font-weight: 600;
}
.nav-link .icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(0, 200, 150, 0.18);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-footer .avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-footer .user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-footer .uname {
  font-size: 13px;
  font-weight: 600;
  color: #d4ece7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-badge {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  display: inline-block;
  margin-top: 2px;
  font-weight: 600;
}
.role-badge.user {
  background: rgba(0, 200, 150, 0.1);
  color: #5a9e8f;
  border: 1px solid rgba(0, 200, 150, 0.2);
}

.sidebar-footer a.logout {
  color: #3a7060;
  text-decoration: none;
  font-size: 18px;
  transition: color 0.12s;
}
.sidebar-footer a.logout:hover {
  color: var(--danger);
}

/* ── Main ──────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  width: 0; /* force flex shrink to work, flex:1 overrides */
  padding: 28px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Page header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}
.page-actions {
  display: flex;
  gap: 10px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title.space-between {
  justify-content: space-between;
}

/* ── Stats ─────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 20px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}
.stat-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* ── Form ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-dark);
  border-radius: 7px;
  color: var(--text);
  font-size: 13.5px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 108, 83, 0.12);
}

.form-control[readonly] {
  background: var(--surface2);
  color: var(--text-muted);
  cursor: not-allowed;
}

select.form-control {
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hov);
  border-color: var(--primary-hov);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-hov);
  border-color: var(--danger-hov);
}
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover {
  opacity: 0.88;
}
.btn-ghost {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border-dark);
}
.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
}
.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 0 4px;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--danger-bg);
  border-color: #fca5a5;
  color: #991b1b;
}
.alert-success {
  background: var(--success-bg);
  border-color: #86efac;
  color: #166534;
}
.alert-warning {
  background: var(--warning-bg);
  border-color: #fcd34d;
  color: #92400e;
}
.alert-info {
  background: var(--info-bg);
  border-color: #a7ddd2;
  color: #01241e;
}

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  background: #c8e3d8;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}
tr:hover td {
  background: var(--surface2);
}

/* ── Badge ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
}
.badge-inactive {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-admin {
  background: var(--primary-bg);
  color: var(--primary);
}
.badge-user {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-ok {
  background: var(--success-bg);
  color: var(--success);
}

/* ── Radio / Checkbox group ────────────────────────────────── */
.radio-group,
.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.radio-group label,
.check-group label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  transition: all 0.12s;
  color: var(--text-muted);
  background: var(--surface);
  font-weight: 500;
}

.radio-group label:has(input:checked),
.check-group label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.radio-group input,
.check-group input {
  accent-color: var(--primary);
}

/* ── Coin row ──────────────────────────────────────────────── */
.coin-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.coin-row:last-child {
  border-bottom: none;
}

.coin-label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 70px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 700;
}

.tf-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tf-label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--border-dark);
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  background: var(--surface);
  transition: all 0.12s;
  font-weight: 500;
}

.tf-label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.tf-label.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Divider / Section label ───────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Log container ─────────────────────────────────────────── */
.log-container {
  background: var(--surface);
  border-radius: 8px;
  height: 300px;
  overflow-y: auto;
  padding: 12px 14px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.7;
  border: 1px solid var(--border);
}

.log-line .ts {
  color: #9ca3af;
}
.log-line .lvl-info {
  color: #2563eb;
}
.log-line .lvl-warn {
  color: #d97706;
}
.log-line .lvl-error {
  color: #dc2626;
}
.log-line .lvl-success {
  color: #16a34a;
}
.log-line .msg {
  color: #111827;
}

.trade-entry {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--border);
  border-radius: 4px;
  background: var(--surface2);
}
.trade-entry.buy {
  border-left: 3px solid var(--success) !important;
}

.trade-entry.sell {
  border-left: 3px solid var(--danger) !important;
}

/* ── Tab buttons ───────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
}
.tab-btn:hover {
  color: var(--text);
  border-color: var(--border-dark);
}
.tab-btn.active {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.modal-alert {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
  border: 1px solid transparent;
}
.modal-alert.show {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-alert.error {
  background: var(--danger-bg);
  border-color: #fca5a5;
  color: #991b1b;
}
.modal-alert.success {
  background: var(--success-bg);
  border-color: #86efac;
  color: #166534;
}

/* ── Global alert nổi trên modal ──────────────────────────── */
#globalAlert {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  min-width: 320px;
  max-width: 560px;
  display: none;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ── Login ─────────────────────────────────────────────────── */
body.login-page {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 110% 65% at 50% 115%, rgba(0, 200, 150, 0.13) 0%, transparent 60%),
    radial-gradient(ellipse 55% 45% at 4% 6%, rgba(0, 200, 150, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse 40% 40% at 96% 8%, rgba(4, 108, 83, 0.09) 0%, transparent 55%),
    radial-gradient(ellipse 35% 35% at 90% 92%, rgba(0, 200, 150, 0.05) 0%, transparent 55%),
    linear-gradient(155deg, #010d0a 0%, #01241e 42%, #022d24 72%, #010c09 100%);
}

/* Grid overlay */
body.login-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 200, 150, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 200, 150, 0.032) 1px, transparent 1px);
  background-size: 52px 52px;
  pointer-events: none;
  z-index: 0;
}

/* Ambient glow orbs */
body.login-page::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle 300px at 7% 93%, rgba(0, 200, 150, 0.055) 0%, transparent 70%),
    radial-gradient(circle 220px at 94% 7%, rgba(0, 200, 150, 0.045) 0%, transparent 70%),
    radial-gradient(circle 180px at 93% 92%, rgba(4, 108, 83, 0.065) 0%, transparent 70%),
    radial-gradient(circle 140px at 50% 50%, rgba(0, 200, 150, 0.02) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  animation: loginAura 9s ease-in-out infinite alternate;
}

@keyframes loginAura {
  from { opacity: 0.65; }
  to   { opacity: 1; }
}

.login-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  padding: 16px;
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  filter: drop-shadow(0 0 22px rgba(0, 200, 150, 0.32));
}
.login-brand .logo img {
  height: 96px;
  width: auto;
  max-width: 360px;
  object-fit: contain;
}
.login-brand h1 {
  font-size: 20px;
  font-weight: 700;
  color: #e0f5ef;
}
.login-brand p {
  font-size: 13px;
  color: rgba(190, 235, 222, 0.6);
  margin-top: 4px;
}

/* Card trên nền dark login */
body.login-page .card {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(0, 200, 150, 0.14);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(0, 200, 150, 0.08);
}

@media (max-width: 480px) {
  .login-brand .logo img {
    height: 78px;
    max-width: 290px;
  }
}
@media (max-width: 360px) {
  .login-brand .logo img {
    height: 64px;
    max-width: 240px;
  }
}

/* ── Pass cell ─────────────────────────────────────────────── */
.pass-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pass-text {
  font-family: monospace;
  font-size: 13px;
  color: var(--text);
  min-width: 80px;
  display: inline-block;
}

.eye-btn {
  background: var(--surface2);
  border: 1px solid var(--border-dark);
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  padding: 3px 7px;
  line-height: 1;
  transition: all 0.12s;
  flex-shrink: 0;
  font-family: inherit;
}
.eye-btn:hover {
  background: var(--border);
  color: var(--text);
  border-color: var(--primary);
}
.eye-btn.active {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-bg);
}

/* ── Whale select modal ────────────────────────────────────── */
.whale-check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
  background: var(--surface);
  user-select: none;
}
.whale-check-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.whale-check-item input[type='checkbox'] {
  accent-color: var(--primary);
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}
.whale-check-info {
  flex: 1;
}
.whale-check-addr {
  font-family: monospace;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}
.whale-check-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Cred display ──────────────────────────────────────────── */
.cred-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.cred-row:last-child {
  border-bottom: none;
}
.cred-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.cred-value {
  font-family: monospace;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  word-break: break-all;
}
.cred-masked {
  color: var(--text-light);
  letter-spacing: 2px;
}
.reveal-btn {
  background: var(--surface2);
  border: 1px solid var(--border-dark);
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  white-space: nowrap;
  transition: all 0.12s;
  font-family: inherit;
}
.reveal-btn:hover {
  color: var(--text);
  border-color: var(--primary);
}
.tag-ok {
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
}
.tag-miss {
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: var(--surface2);
}
::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}
/* ── Profile ─────────────────────────────────── */
.cred-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.cred-row:last-child {
  border-bottom: none;
}
.cred-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}
.cred-value {
  font-family: monospace;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  word-break: break-all;
}
.cred-masked {
  color: var(--text-muted);
  letter-spacing: 2px;
}
.reveal-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  white-space: nowrap;
  transition: all 0.15s;
}
.reveal-btn:hover {
  color: var(--text);
  border-color: var(--primary);
}
.tag-ok {
  color: var(--success);
  font-size: 12px;
}
.tag-miss {
  color: var(--danger);
  font-size: 12px;
}
/* Dashboard */
#globalAlert {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  min-width: 320px;
  max-width: 560px;
  display: none;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Whale select trong modal */
.whale-check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
  background: var(--surface2);
  user-select: none;
}

.whale-check-item:has(input:checked) {
  border-color: var(--primary);
  background: rgba(4, 108, 83, 0.1);
}

.whale-check-item input[type='checkbox'] {
  accent-color: var(--primary);
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.whale-check-info {
  flex: 1;
}

.whale-check-addr {
  font-family: monospace;
  font-size: 13px;
  color: var(--text);
}

.whale-check-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
/* Accounts/index */
.pass-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pass-text {
  font-family: 'Consolas', monospace;
  font-size: 13px;
  color: var(--text);
  min-width: 80px;
  display: inline-block;
}
.eye-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  padding: 3px 7px;
  line-height: 1;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
  flex-shrink: 0;
}
.eye-btn:hover {
  background: var(--border);
  color: var(--text);
  border-color: var(--primary);
}
.eye-btn.active {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(4, 108, 83, 0.1);
}

.hidden {
  display: none;
}

/* ===== ERROR PAGES (404 / 403 / 500) ===== */

.error-page-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f6f8;
  font-family: Arial, sans-serif;
  padding: 20px;
  box-sizing: border-box;
}

.error-page-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 48px 40px 40px;
  max-width: 560px;
  width: 100%;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Badge trạng thái */
.error-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f4f6f8;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 5px 14px;
  margin-bottom: 28px;
}

.error-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.error-badge-dot.dot-red {
  background: #e74c3c;
}
.error-badge-dot.dot-amber {
  background: #f39c12;
}
.error-badge-dot.dot-blue {
  background: #3498db;
}

.error-badge-text {
  font-size: 11px;
  font-weight: bold;
  color: #6c757d;
  letter-spacing: 0.07em;
}

/* Icon tròn */
.error-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  border: 1px solid;
}

.error-icon-wrap.icon-red {
  background: #fdf2f2;
  border-color: #f5c6cb;
}
.error-icon-wrap.icon-amber {
  background: #fef9ec;
  border-color: #fce5a3;
}
.error-icon-wrap.icon-blue {
  background: #f0f8ff;
  border-color: #b8d9f5;
}

.error-icon-wrap svg {
  width: 28px;
  height: 28px;
}

/* Số status lớn */
.error-status-code {
  font-size: 80px;
  font-weight: bold;
  line-height: 1;
  letter-spacing: -3px;
  color: #2c3e50;
  margin-bottom: 12px;
}

.error-status-code .accent-red {
  color: #e74c3c;
}
.error-status-code .accent-amber {
  color: #f39c12;
}
.error-status-code .accent-blue {
  color: #3498db;
}

/* Tiêu đề & mô tả */
.error-title {
  font-size: 20px;
  font-weight: bold;
  color: #2c3e50;
  margin: 0 0 10px;
}

.error-desc {
  font-size: 14px;
  color: #6c757d;
  line-height: 1.7;
  margin: 0 0 24px;
}

/* Info grid */
.error-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
  text-align: left;
}

.error-info-cell {
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 5px;
  padding: 10px 12px;
  overflow: hidden;
}

.error-info-cell.full {
  grid-column: 1 / -1;
}

.error-info-label {
  font-size: 10px;
  font-weight: bold;
  color: #aaa;
  letter-spacing: 0.07em;
  margin-bottom: 3px;
}

.error-info-val {
  font-size: 12px;
  font-family: monospace;
  color: #34495e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Divider */
.error-divider {
  height: 1px;
  background: #eee;
  margin-bottom: 24px;
}

/* Action buttons */
.error-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.error-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid #ddd;
  background: #fff;
  color: #34495e;
  transition: background 0.15s;
  margin: 0;
}

.error-btn:hover {
  background: #f4f6f8;
}

.error-btn-primary {
  background: #046c53;
  color: #fff;
  border-color: #046c53;
}

.error-btn-primary:hover {
  background: #035441;
  border-color: #035441;
}

/* Hint text */
.error-hint {
  font-size: 13px;
  color: #aaa;
}

.error-hint a {
  color: #046c53;
  text-decoration: underline;
}

/* Stack trace - chỉ hiện khi dev */
.error-stack-box {
  margin-top: 24px;
  text-align: left;
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 5px;
  padding: 12px 14px;
}

.error-stack-label {
  font-size: 10px;
  font-weight: bold;
  color: #aaa;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

.error-stack-code {
  font-family: monospace;
  font-size: 12px;
  color: #6c757d;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  margin: 0;
}
/* stastic page */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  max-width: 100%;
  box-sizing: border-box;
}
.filter-bar label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 4px;
}
.pill-group {
  display: flex;
  gap: 4px;
}
.pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-dark);
  background: var(--surface);
  color: var(--text-muted);
  transition: all 0.12s;
  user-select: none;
}
.pill:hover {
  background: var(--surface2);
  color: var(--text);
}
.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.filter-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
}
.date-inputs {
  display: flex;
  gap: 8px;
  align-items: center;
}
.date-inputs input {
  padding: 5px 10px;
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}
.date-inputs input:focus {
  border-color: var(--primary);
}
.filter-spacer {
  flex: 1;
}
.view-toggle {
  display: flex;
  gap: 4px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.ov-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.ov-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.ov-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.ov-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.ov-value.positive {
  color: var(--success);
}
.ov-value.negative {
  color: var(--danger);
}

.section-content {
  display: none;
}
.section-content.active {
  display: block;
}
.chart-wrap {
  position: relative;
  height: 320px;
}
.chart-wrap-sm {
  position: relative;
  height: 260px;
}

.pnl-positive {
  color: var(--success);
  font-weight: 600;
}
.pnl-negative {
  color: var(--danger);
  font-weight: 600;
}
.pnl-zero {
  color: var(--text-muted);
}

.loading-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 28px !important;
  font-style: italic;
}

#customDateRange {
  display: none;
}
#customDateRange.visible {
  display: flex;
}

/* ── Mobile sidebar toggle (hamburger / close) ─────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 202;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  /* Animate left position when sidebar opens */
  transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.12s;
  padding: 0;
}
.sidebar-toggle:hover {
  background: var(--surface2);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 99;
  cursor: pointer;
}
.sidebar-backdrop.open {
  display: block;
}

/* ── Table wrap — scroll ngang, không overflow .main */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  width: 100%;
}
.table-wrap table {
  min-width: 520px;
}

/* ── Màn hình trung bình (tablet landscape ~1200px) ────────── */
@media (max-width: 1200px) {
  .main {
    padding: 20px;
  }
}

/* ── Tablet (~900–1200px): sidebar vẫn hiện nhưng thu nhỏ ──── */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 200px;
  }
  .main {
    padding: 18px;
  }
  /* Filter bar: ẩn separator và spacer để không bị tràn */
  .filter-sep {
    display: none;
  }
  .filter-spacer {
    display: none;
  }
  .filter-bar {
    gap: 8px;
  }
}

/* ── Sidebar overlay — bắt đầu từ 900px ────────────────────── */
@media (max-width: 900px) {
  /* Sidebar trượt ra từ trái (handled in responsive-fixes @900px) */
  /* Main: bỏ margin-left, giảm padding */
  .main {
    margin-left: 0;
    padding: 16px;
    padding-top: 62px;
  }

  /* Page header */
  .page-header {
    gap: 8px;
  }
  .page-actions {
    flex-wrap: wrap;
  }

  /* Overview & stats grids */
  .stats-grid,
  .overview-grid {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 12px;
  }

  /* Cred row — stack dọc */
  .cred-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .cred-label {
    padding-top: 8px;
  }

  /* Filter bar */
  .filter-bar {
    padding: 10px 14px;
    gap: 8px;
  }
  .date-inputs {
    flex-wrap: wrap;
    gap: 6px;
  }
  .date-inputs input {
    flex: 1;
    min-width: 120px;
  }

  /* Chart heights */
  .chart-wrap {
    height: 260px;
  }
  .chart-wrap-sm {
    height: 220px;
  }

  /* Modal */
  .modal-box {
    padding: 18px;
    width: 100%;
  }

  /* Global alert */
  #globalAlert {
    min-width: unset;
    width: calc(100% - 24px);
    max-width: unset;
    left: 12px;
    transform: none;
  }
}

/* ── Mobile nhỏ (≤600px) ────────────────────────────────────── */
@media (max-width: 600px) {
  .main {
    padding: 12px;
    padding-top: 50px;
  }

  .stats-grid,
  .overview-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .ov-value {
    font-size: 18px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .page-subtitle {
    font-size: 12px;
    word-break: break-all;
  }

  .pill-group {
    flex-wrap: wrap;
  }

  .tab-bar {
    gap: 4px;
  }
  .tab-btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .chart-wrap {
    height: 220px;
  }
  .chart-wrap-sm {
    height: 180px;
  }

  .card {
    padding: 14px 16px;
  }

  .modal-box {
    padding: 14px 16px;
  }
}

/* ── Rất nhỏ (≤400px) ─────────────────────────────────────── */
@media (max-width: 400px) {
  .stats-grid,
  .overview-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .ov-value {
    font-size: 16px;
  }

  .ov-label {
    font-size: 10px;
  }
}

/* ============================================================
   responsive-fixes.css
   Paste vào CUỐI file main.css (ghi đè các media query cũ)
   Fixes: Sidebar, Table, Form/Card, Chart — tất cả breakpoints
   ============================================================ */

/* ============================================================
   DESKTOP SIDEBAR COLLAPSE
   ============================================================ */

/* Smooth transitions for sidebar & main */
@media (min-width: 901px) {
  .sidebar {
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .main {
    transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                padding-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Show collapse button inside sidebar on desktop */
  .sidebar-collapse-btn {
    display: flex;
  }

  /* Show expand button only when collapsed */
  body.sidebar-collapsed .sidebar-expand-btn {
    display: flex;
  }

  /* Collapsed state */
  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }
  body.sidebar-collapsed .main {
    margin-left: 0;
  }
}

/* Suppress transitions on initial page load (no flash) */
.notransition .sidebar,
.notransition .main,
.notransition .sidebar-expand-btn {
  transition: none !important;
}

/* ── Reset mobile-safe defaults ────────────────────────────── */
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

img,
video,
canvas,
svg {
  max-width: 100%;
  display: block;
}

/* ============================================================
   DESKTOP LỚN ≥ 1400px
   ============================================================ */
@media (min-width: 1400px) {
  :root {
    --sidebar-w: 240px;
  }

  .main {
    padding: 32px;
  }

  .stats-grid,
  .overview-grid {
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  }

  .form-row {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .chart-wrap {
    height: 380px;
  }

  .chart-wrap-sm {
    height: 300px;
  }

  .modal-box {
    width: 560px;
  }
}

/* ============================================================
   DESKTOP VỪA 1200px–1400px
   ============================================================ */
@media (max-width: 1400px) and (min-width: 1200px) {
  .main {
    padding: 24px;
  }

  .stats-grid,
  .overview-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .chart-wrap {
    height: 340px;
  }
}

/* ============================================================
   DESKTOP NHỎ 1024px–1200px
   ============================================================ */
@media (max-width: 1200px) {
  :root {
    --sidebar-w: 210px;
  }

  .main {
    padding: 22px;
  }

  .stats-grid,
  .overview-grid {
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 16px;
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .chart-wrap {
    height: 300px;
  }

  .chart-wrap-sm {
    height: 240px;
  }

  /* Table: bắt đầu scroll ngang */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
  }

  .table-wrap table {
    min-width: 680px;
  }
}

/* ============================================================
   TABLET LANDSCAPE 900px–1024px
   ============================================================ */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 190px;
  }

  .main {
    padding: 18px;
  }

  /* Sidebar thu nhỏ: ẩn text labels, chỉ icon */
  .nav-link span:not(.icon) {
    font-size: 12px;
  }

  .sidebar-brand {
    font-size: 13px;
    padding: 12px 12px;
    border-bottom-color: rgba(0, 200, 150, 0.15);
  }
  .sidebar-brand img {
    height: 38px;
  }

  .stats-grid,
  .overview-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
  }

  /* Filter bar wrap xuống */
  .filter-bar {
    padding: 10px 14px;
    gap: 8px;
  }

  .filter-sep {
    display: none;
  }

  .filter-spacer {
    display: none;
  }

  .pill-group {
    flex-wrap: wrap;
    gap: 4px;
  }

  /* Form: 2 cột */
  .form-row {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* Chart */
  .chart-wrap {
    height: 280px;
  }

  .chart-wrap-sm {
    height: 220px;
  }

  /* Card padding nhỏ lại */
  .card {
    padding: 16px 18px;
  }

  /* Modal */
  .modal-box {
    width: calc(100% - 32px);
    max-width: 520px;
  }
}

/* ============================================================
   SIDEBAR OVERLAY — bắt đầu từ 900px
   ============================================================ */
@media (max-width: 900px) {
  /* ── Sidebar: overlay từ trái ── */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    width: 270px;
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.45);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Ẩn desktop collapse button trên mobile */
  .sidebar-collapse-btn {
    display: none !important;
  }

  /* Backdrop */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 199;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    cursor: pointer;
    animation: fadeIn 0.2s ease;
  }
  .sidebar-backdrop.open {
    display: block;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  /* Hamburger hiện ra */
  .sidebar-toggle {
    display: flex;
  }

  /* Main: bỏ margin-left */
  .main {
    margin-left: 0;
    padding: 16px;
    padding-top: 62px;
  }

  /* Page header */
  .page-header {
    gap: 10px;
  }

  .page-title {
    font-size: 17px;
  }

  /* Stats/overview: auto-fit */
  .stats-grid,
  .overview-grid {
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 10px;
  }

  .ov-value {
    font-size: 20px;
  }

  /* Form: 2 cột */
  .form-row {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* Cred row: stack dọc */
  .cred-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px 0;
  }

  .cred-label {
    padding-top: 0;
    margin-bottom: 2px;
  }

  /* Table */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .table-wrap table {
    min-width: 600px;
  }

  th,
  td {
    padding: 9px 12px;
    white-space: nowrap;
  }

  /* Chart */
  .chart-wrap {
    height: 250px;
  }

  .chart-wrap-sm {
    height: 200px;
  }

  /* Card */
  .card {
    padding: 14px 16px;
    margin-bottom: 14px;
  }

  /* Modal */
  .modal-overlay {
    align-items: flex-end; /* slide up từ dưới trên mobile */
    padding: 0;
  }

  .modal-box {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 85vh;
    padding: 20px 18px;
    animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  @keyframes slideUp {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  /* Log container */
  .log-container {
    height: 220px;
    font-size: 11.5px;
  }

  /* Filter bar */
  .filter-bar {
    gap: 6px;
  }

  .date-inputs {
    flex-wrap: wrap;
  }

  .date-inputs input {
    flex: 1;
    min-width: 110px;
  }

  /* Global alert */
  #globalAlert {
    left: 12px;
    right: 12px;
    top: 16px;
    min-width: unset;
    max-width: unset;
    width: auto;
    transform: none;
  }

  /* Tab bar */
  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    gap: 4px;
    scrollbar-width: none;
  }

  .tab-bar::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    flex-shrink: 0;
  }

  /* Pagination */
  .pagination {
    gap: 6px;
  }
}

/* ============================================================
   MOBILE ≤ 600px
   ============================================================ */
@media (max-width: 600px) {
  .main {
    padding: 12px;
    padding-top: 56px;
  }

  /* Stats/overview: 2 cột */
  .stats-grid,
  .overview-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .ov-value {
    font-size: 18px;
  }

  .ov-label {
    font-size: 10px;
  }

  .ov-sub {
    font-size: 10px;
  }

  .ov-card {
    padding: 12px 14px;
  }

  /* Form: 1 cột */
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-group {
    margin-bottom: 14px;
  }

  /* Page header: stack dọc */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .page-actions {
    width: 100%;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .page-actions .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .page-subtitle {
    font-size: 12px;
  }

  /* Table: scroll với shadow hint */
  .table-wrap {
    position: relative;
  }

  .table-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.9));
    pointer-events: none;
    border-radius: 0 var(--radius) var(--radius) 0;
  }

  .table-wrap table {
    min-width: 520px;
  }

  th {
    font-size: 10px;
    padding: 8px 10px;
  }

  td {
    padding: 9px 10px;
    font-size: 12.5px;
  }

  /* Badge nhỏ lại */
  .badge {
    font-size: 10px;
    padding: 2px 7px;
  }

  /* Buttons */
  .btn {
    font-size: 12.5px;
    padding: 7px 14px;
  }

  .btn-sm {
    padding: 4px 10px;
    font-size: 11.5px;
  }

  /* Card */
  .card {
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  .card-title {
    font-size: 13px;
    margin-bottom: 12px;
  }

  /* Chart: giảm chiều cao */
  .chart-wrap {
    height: 200px;
  }

  .chart-wrap-sm {
    height: 170px;
  }

  /* Chart wrapper cần overflow hidden để không vỡ */
  .chart-wrap canvas,
  .chart-wrap-sm canvas {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Log container */
  .log-container {
    height: 180px;
    font-size: 11px;
  }

  /* Modal */
  .modal-box {
    max-height: 88vh;
    padding: 16px 14px;
  }

  .modal-title {
    font-size: 14px;
    margin-bottom: 14px;
  }

  .modal-footer {
    gap: 8px;
  }

  .modal-footer .btn {
    flex: 1;
  }

  /* Whale check items */
  .whale-check-item {
    padding: 10px 12px;
  }

  /* Pill group: scroll ngang */
  .pill-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
    gap: 4px;
  }

  .pill-group::-webkit-scrollbar {
    display: none;
  }

  .pill {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 11px;
  }

  /* Filter bar */
  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 12px;
    gap: 8px;
  }

  /* Coin row */
  .coin-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 0;
  }

  .tf-group {
    width: 100%;
  }

  /* Divider */
  .divider {
    margin: 14px 0;
  }

  /* Pagination */
  .pagination {
    gap: 4px;
    padding: 8px 0 2px;
  }

  .pagination .btn {
    padding: 5px 10px;
    font-size: 12px;
  }
}

/* ============================================================
   MOBILE RẤT NHỎ ≤ 400px
   ============================================================ */
@media (max-width: 400px) {
  .main {
    padding: 10px;
    padding-top: 52px;
  }

  .stats-grid,
  .overview-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .ov-value {
    font-size: 15px;
  }

  .ov-label {
    font-size: 9px;
    letter-spacing: 0.3px;
  }

  .ov-card {
    padding: 10px 11px;
  }

  .page-title {
    font-size: 15px;
  }

  .card {
    padding: 10px 12px;
  }

  .btn {
    font-size: 12px;
    padding: 6px 12px;
  }

  .chart-wrap {
    height: 180px;
  }

  .chart-wrap-sm {
    height: 150px;
  }

  .tab-btn {
    padding: 4px 9px;
    font-size: 11px;
  }

  /* Badge: dạng chấm tròn trên màn rất nhỏ */
  .badge {
    font-size: 9px;
    padding: 2px 6px;
  }

  .form-control {
    font-size: 13px;
    padding: 7px 10px;
  }

  .log-container {
    height: 150px;
    font-size: 10.5px;
  }

  .modal-box {
    padding: 14px 12px;
    max-height: 90vh;
  }
}

/* ============================================================
   UTILITY: Chart responsive (Chart.js / ApexCharts)
   Đảm bảo canvas/svg không overflow container
   ============================================================ */
.chart-wrap,
.chart-wrap-sm {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.chart-wrap > *,
.chart-wrap-sm > * {
  width: 100% !important;
}

/* Chart.js specific */
.chart-wrap canvas {
  display: block;
  width: 100% !important;
}

/* ApexCharts specific */
.chart-wrap .apexcharts-canvas,
.chart-wrap-sm .apexcharts-canvas {
  width: 100% !important;
}

.chart-wrap .apexcharts-canvas svg,
.chart-wrap-sm .apexcharts-canvas svg {
  width: 100% !important;
}

/* ============================================================
   UTILITY: Table mobile hints
   ============================================================ */
@media (max-width: 768px) {
  /* Hiện label "Scroll →" hint khi table overflow */
  .table-wrap[data-scroll-hint]::before {
    content: 'Vuốt ngang để xem thêm →';
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    padding: 0 4px 6px;
  }
}

/* ============================================================
   UTILITY: Safe area (notch / dynamic island)
   ============================================================ */
@supports (padding: max(0px)) {
  .sidebar {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }

  /* Safe-area cho mobile (notch / dynamic island) — chỉ áp dụng ≤900px */
  @media (max-width: 900px) {
    .main {
      padding-bottom: max(16px, env(safe-area-inset-bottom));
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
  }

  .modal-box {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  #globalAlert {
    top: max(16px, env(safe-area-inset-top));
  }

  .sidebar-toggle {
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
  }
}
