/* ============================================================
   ForexVPS Pro — Design System
   ------------------------------------------------------------
   - CSS Variables driven (light/dark theme via [data-theme])
   - All component primitives live here: buttons, cards, badges,
     tables, forms, modals, alerts, etc.
   - Extend by adding new variables under :root or [data-theme="dark"]
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  /* Brand */
  --brand-500: #00E5A8;          /* primary accent — "trading green" */
  --brand-600: #00C994;
  --brand-400: #4FF0C4;
  --brand-300: #8FF6D8;

  --accent-500: #4F8CFF;          /* secondary accent — "low latency blue" */
  --accent-600: #2F6FE0;
  --accent-400: #7BA9FF;

  --warn-500:    #FFB020;
  --danger-500:  #FF4D6D;
  --success-500: #00D084;

  /* Light theme surface + text */
  --bg-app:        #F6F8FB;
  --bg-surface:    #FFFFFF;
  --bg-elevated:   #FFFFFF;
  --bg-subtle:     #EEF2F7;
  --bg-inverse:    #0B1220;

  --border:        #E1E7EF;
  --border-strong: #CBD4E0;

  --text-1: #0B1220;  /* primary text  */
  --text-2: #3A4658;  /* secondary     */
  --text-3: #6B7790;  /* muted         */
  --text-inv: #FFFFFF;

  --shadow-sm: 0 1px 2px rgba(15, 30, 60, .06), 0 1px 1px rgba(15,30,60,.04);
  --shadow-md: 0 6px 18px rgba(15, 30, 60, .08), 0 2px 6px rgba(15,30,60,.05);
  --shadow-lg: 0 24px 60px rgba(15, 30, 60, .14), 0 8px 24px rgba(15,30,60,.08);
  --shadow-glow: 0 0 0 1px rgba(0,229,168,.25), 0 12px 36px rgba(0,229,168,.18);

  /* Radius */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  /* Typography */
  --font-sans: 'Inter', 'Prompt', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  --fs-xs:   12px;
  --fs-sm:   13px;
  --fs-base: 15px;
  --fs-md:   17px;
  --fs-lg:   20px;
  --fs-xl:   26px;
  --fs-2xl:  34px;
  --fs-3xl:  48px;
  --fs-4xl:  64px;

  --lh-tight: 1.15;
  --lh-snug:  1.35;
  --lh-base:  1.6;

  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-black: 800;

  /* Layout */
  --container-max: 1240px;
  --nav-h: 72px;

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-fast: .15s;
  --t-base: .25s;
  --t-slow: .4s;

  --z-nav: 100;
  --z-dropdown: 200;
  --z-modal: 1000;
  --z-toast: 1100;
}

/* ---------- Dark theme overrides ---------- */
[data-theme="dark"] {
  --brand-500: #00E5A8;
  --brand-600: #00FFB8;
  --brand-400: #4FF0C4;
  --brand-300: #8FF6D8;

  --accent-500: #4F8CFF;
  --accent-600: #5C9BFF;
  --accent-400: #7BA9FF;

  --bg-app:        #060912;
  --bg-surface:    #0C1322;
  --bg-elevated:   #111A2D;
  --bg-subtle:     #131C30;
  --bg-inverse:    #FFFFFF;

  --border:        #1E2A42;
  --border-strong: #2B3A5A;

  --text-1: #F1F5FB;
  --text-2: #B8C3D6;
  --text-3: #7A8AA8;
  --text-inv: #0B1220;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 1px 1px rgba(0,0,0,.3);
  --shadow-md: 0 6px 18px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.65), 0 8px 24px rgba(0,0,0,.45);
  --shadow-glow: 0 0 0 1px rgba(0,229,168,.35), 0 12px 40px rgba(0,229,168,.25);
}

/* ---------- 2. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text-1);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; line-height: var(--lh-tight); font-weight: var(--fw-bold); }

::selection { background: var(--brand-500); color: var(--bg-inverse); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-subtle); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); border: 2px solid var(--bg-subtle); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---------- 3. Layout helpers ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--s-6);
}
.section { padding: var(--s-9) 0; }
.section-sm { padding: var(--s-7) 0; }
.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: var(--s-1); }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-5 { gap: var(--s-5); }
.gap-6 { gap: var(--s-6); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-mono { font-family: var(--font-mono); }
.text-brand { color: var(--brand-500); }
.text-accent { color: var(--accent-500); }
.text-warn { color: var(--warn-500); }
.text-danger { color: var(--danger-500); }
.text-success { color: var(--success-500); }
.text-muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.hidden { display: none !important; }
.mt-1 { margin-top: var(--s-1); }
.mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); }
.mt-6 { margin-top: var(--s-6); } .mt-7 { margin-top: var(--s-7); }
.mb-1 { margin-bottom: var(--s-1); }
.mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); }
.mb-6 { margin-bottom: var(--s-6); } .mb-7 { margin-bottom: var(--s-7); }

/* ---------- 4. Typography utilities ---------- */
.display { font-size: var(--fs-4xl); font-weight: var(--fw-black); letter-spacing: -.02em; line-height: 1.05; }
.h1 { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing: -.02em; }
.h2 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -.015em; }
.h3 { font-size: var(--fs-xl); font-weight: var(--fw-semibold); }
.h4 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.lead { font-size: var(--fs-md); color: var(--text-2); line-height: var(--lh-base); }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--brand-500);
  padding: var(--s-1) var(--s-3);
  background: rgba(0, 229, 168, .08);
  border: 1px solid rgba(0, 229, 168, .25);
  border-radius: var(--r-pill);
}
.mono { font-family: var(--font-mono); }

/* ---------- 5. Buttons ---------- */
.btn {
  --btn-bg: var(--brand-500);
  --btn-fg: var(--bg-inverse);
  --btn-border: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0 var(--s-5);
  height: 44px;
  border-radius: var(--r-sm);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-border);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease),
              background var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn svg { width: 18px; height: 18px; }

.btn-primary { --btn-bg: var(--brand-500); --btn-fg: #04140E; }
.btn-primary:hover { --btn-bg: var(--brand-400); }

.btn-accent { --btn-bg: var(--accent-500); --btn-fg: #fff; }
.btn-accent:hover { --btn-bg: var(--accent-400); }

.btn-dark { --btn-bg: var(--bg-inverse); --btn-fg: var(--bg-app); }

.btn-outline {
  --btn-bg: transparent;
  --btn-fg: var(--text-1);
  --btn-border: var(--border-strong);
}
.btn-outline:hover { --btn-bg: var(--bg-subtle); border-color: var(--brand-500); box-shadow: none; }

.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--text-2);
  --btn-border: transparent;
}
.btn-ghost:hover { --btn-bg: var(--bg-subtle); color: var(--text-1); box-shadow: none; }

.btn-danger { --btn-bg: var(--danger-500); --btn-fg: #fff; }
.btn-warn { --btn-bg: var(--warn-500); --btn-fg: #0B1220; }

.btn-lg { height: 54px; padding: 0 var(--s-6); font-size: var(--fs-md); border-radius: var(--r-md); }
.btn-sm { height: 34px; padding: 0 var(--s-3); font-size: var(--fs-sm); }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }

/* ---------- 6. Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-1);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
  background: var(--bg-subtle);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-brand   { background: rgba(0,229,168,.12); color: var(--brand-500); border-color: rgba(0,229,168,.3); }
.badge-accent,
.badge-info    { background: rgba(79,140,255,.12); color: var(--accent-500); border-color: rgba(79,140,255,.3); }
.badge-warn    { background: rgba(255,176,32,.12); color: var(--warn-500); border-color: rgba(255,176,32,.3); }
.badge-danger  { background: rgba(255,77,109,.12); color: var(--danger-500); border-color: rgba(255,77,109,.3); }
.badge-success { background: rgba(0,208,132,.12); color: var(--success-500); border-color: rgba(0,208,132,.3); }

.chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-1);
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.2;
}
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-500); flex-shrink: 0; }
.chip-dot.warn { background: var(--warn-500); }
.chip-dot.danger { background: var(--danger-500); }

/* ---------- 7. Cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
}
.card-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--brand-500); }

.card-glow {
  position: relative;
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-elevated) 100%);
}
.card-glow::before {
  content: '';
  position: absolute; inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}

/* ---------- 8. Forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.input, .select, .textarea {
  width: 100%;
  height: 44px;
  padding: 0 var(--s-4);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-size: var(--fs-base);
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), background var(--t-base) var(--ease);
}
.input[type="file"] {
  padding: 8px var(--s-3);
  height: auto;
}
.textarea { height: auto; padding: var(--s-3) var(--s-4); min-height: 120px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(0,229,168,.18);
}
.input::placeholder { color: var(--text-3); }
.input-group {
  display: flex; align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  overflow: hidden;
}
.input-group .input { border: none; background: transparent; }
.input-group .addon {
  display: flex; align-items: center; padding: 0 var(--s-4);
  background: var(--bg-surface); border-right: 1px solid var(--border);
  color: var(--text-3); font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.checkbox {
  display: inline-flex; align-items: center; gap: var(--s-2);
  cursor: pointer; user-select: none;
}
.checkbox input { width: 18px; height: 18px; accent-color: var(--brand-500); }

/* ---------- 9. Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; background: var(--bg-surface); }
.table th, .table td {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  vertical-align: middle;
}
.table th { background: var(--bg-subtle); font-weight: var(--fw-semibold); color: var(--text-2); text-transform: uppercase; font-size: var(--fs-xs); letter-spacing: .06em; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-subtle); }

/* ---------- 10. Alerts ---------- */
.alert {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: var(--fs-sm);
}
.alert-brand   { border-color: rgba(0,229,168,.35); background: rgba(0,229,168,.06); }
.alert-warn    { border-color: rgba(255,176,32,.35); background: rgba(255,176,32,.06); }
.alert-danger  { border-color: rgba(255,77,109,.35); background: rgba(255,77,109,.06); }
.alert-accent  { border-color: rgba(79,140,255,.35); background: rgba(79,140,255,.06); }

/* ---------- 11. Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 14, 28, .65);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center; justify-content: center;
  z-index: var(--z-modal);
  padding: var(--s-5);
  animation: fadeIn .2s var(--ease);
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%; max-width: 480px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp .25s var(--ease-out);
}
.modal-header { padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: var(--s-6); max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: var(--s-4) var(--s-6); border-top: 1px solid var(--border); display: flex; gap: var(--s-3); justify-content: flex-end; }
.modal-close { width: 36px; height: 36px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; color: var(--text-3); transition: background var(--t-fast); }
.modal-close:hover { background: var(--bg-subtle); color: var(--text-1); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

/* ---------- 12. Stat blocks ---------- */
.stat {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-5);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.stat-value { font-size: var(--fs-2xl); font-weight: var(--fw-bold); font-family: var(--font-mono); letter-spacing: -.01em; }
.stat-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); font-weight: var(--fw-semibold); }
.stat-trend { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: var(--fw-semibold); }
.stat-trend.up { color: var(--success-500); }
.stat-trend.down { color: var(--danger-500); }

/* ---------- 13. Avatar ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
  color: #04140E; font-weight: var(--fw-bold); font-size: var(--fs-sm);
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: var(--fs-xs); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--fs-lg); }

/* ---------- 14. Progress / meter ---------- */
.meter, .progress { height: 7px; background: var(--bg-subtle); border-radius: var(--r-pill); overflow: hidden; }
.meter-fill, .progress-bar { height: 100%; background: linear-gradient(90deg, var(--brand-500), var(--accent-500)); border-radius: inherit; transition: width .6s var(--ease); }
.meter-fill.warn, .progress-bar.warn { background: linear-gradient(90deg, var(--warn-500), #ff7a45); }
.meter-fill.danger, .progress-bar.danger { background: linear-gradient(90deg, var(--danger-500), #ff8a3c); }

/* ---------- 15. Latency pill (signature element) ---------- */
.latency {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
}
.latency-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success-500);
  box-shadow: 0 0 0 0 rgba(0,208,132,.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0,208,132,.5); }
  70% { box-shadow: 0 0 0 8px rgba(0,208,132,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,208,132,0); }
}

/* ---------- 16. Code block ---------- */
.code-block {
  background: #0B1220;
  color: #d6e1ff;
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  overflow-x: auto;
  line-height: 1.6;
  white-space: pre;
}
.code-block .k { color: #ff7b9c; }
.code-block .s { color: #c3e88d; }
.code-block .c { color: #6b7790; font-style: italic; }
.code-block .n { color: #82aaff; }
.code-block .ok { color: #28c840; }

/* ---------- 17. Divider ---------- */
.divider { height: 1px; background: var(--border); border: none; margin: var(--s-5) 0; }
.divider-v { width: 1px; background: var(--border); align-self: stretch; }

/* ---------- 18. Skeleton loader ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--bg-surface) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

/* ---------- 19. Toast ---------- */
.toast-stack {
  position: fixed; bottom: var(--s-5); right: var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-3);
  z-index: var(--z-toast);
}
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-500);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  animation: slideInRight .3s var(--ease-out);
}
.toast.success { border-left-color: var(--success-500); }
.toast.warn { border-left-color: var(--warn-500); }
.toast.error { border-left-color: var(--danger-500); }
@keyframes slideInRight { from { transform: translateX(120%); opacity: 0 } to { transform: translateX(0); opacity: 1 } }

/* ---------- 20. Tabs ---------- */
.tabs { display: inline-flex; flex-wrap: wrap; gap: var(--s-1); border-bottom: 1px solid var(--border); padding: 0 var(--s-2); }
.tab {
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-3);
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}
.tab:hover { color: var(--text-1); }
.tab.active { color: var(--brand-500); border-bottom-color: var(--brand-500); }

/* ---------- 21. Switch (toggle) ---------- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider,
.switch .switch-track {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border-strong); border-radius: var(--r-pill);
  transition: var(--t-base) var(--ease);
}
.switch .slider::before,
.switch .switch-track::before {
  content: ''; position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: var(--bg-surface);
  border-radius: 50%;
  transition: var(--t-base) var(--ease);
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider,
.switch input:checked + .switch-track { background: var(--brand-500); }
.switch input:checked + .slider::before,
.switch input:checked + .switch-track::before { transform: translateX(20px); }

/* ---------- 22. Layout Grid Helpers & Responsive ---------- */
.grid-main-side {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--s-5);
}
.grid-half {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
}
.table-wrap {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-main-side,
  .grid-half { grid-template-columns: 1fr; }
  .display { font-size: var(--fs-3xl); }
  .h1 { font-size: var(--fs-2xl); }
}
@media (max-width: 768px) {
  /* ป้องกัน iOS Safari ซูมหน้าจออัตโนมัติเวลาแตะช่องกรอกข้อมูล */
  .input, .select, .textarea {
    font-size: 16px;
  }
  .card {
    padding: var(--s-4);
  }
  .modal-backdrop {
    padding: var(--s-3);
    align-items: flex-end;
  }
  .modal {
    max-width: 100%;
    border-radius: var(--r-lg) var(--r-lg) var(--r-md) var(--r-md);
  }
  .toast-stack {
    left: var(--s-4);
    right: var(--s-4);
    bottom: 80px;
  }
  .toast {
    min-width: 0;
    width: 100%;
  }
}
@media (max-width: 640px) {
  .container { padding: 0 var(--s-4); }
  .grid-2, .grid-3, .grid-4, .grid-main-side, .grid-half { grid-template-columns: 1fr; }
  .section { padding: var(--s-6) 0; }
  .display { font-size: 28px; }
  .h1 { font-size: 24px; }
  .h2 { font-size: 20px; }
  .h3 { font-size: 18px; }
  .lead { font-size: var(--fs-base); }
  .hide-sm { display: none !important; }
  .table th, .table td {
    padding: 10px 12px;
    font-size: var(--fs-xs);
  }
  .alert {
    padding: var(--s-3) var(--s-4);
  }
}
