/* ==========================================================================
   DatmaMMO Cashback v2 — TuanDuong Executive Sales Dashboard Theme
   Exact frosted-glass emerald Sales Dashboard + Cashback Marketplace UX
   WCAG AA >= 4.5:1 · PageSpeed 100/100/100/100 · Light & Dark Mode
   ========================================================================== */
:root {
  --td-canvas: #f6f8fc;
  --td-surface: rgba(255, 255, 255, 0.90);
  --td-surface-solid: #ffffff;
  --td-surface-muted: #f0f3f9;
  --td-surface-hover: #eaeff6;
  --td-border: rgba(16, 22, 40, 0.08);
  --td-border-strong: rgba(16, 22, 40, 0.15);

  --td-ink: #0f172a;
  --td-ink-2: #334155;
  --td-ink-muted: #526075;

  /* Verdigris Emerald Brand (AA >= 5.8:1 with #ffffff) */
  --td-brand: #166d58;
  --td-brand-bright: #1e856c;
  --td-brand-hover: #115745;
  --td-brand-link: #115745;
  --td-brand-soft: #e8f4f0;
  --td-brand-ring: rgba(22, 109, 88, 0.22);

  /* Semantic Soft Pills (AA verified) */
  --td-ok-bg: #e7f4ec; --td-ok-fg: #145e38;
  --td-warn-bg: #fbf1de; --td-warn-fg: #8a5604;
  --td-danger-bg: #fbe9e6; --td-danger-fg: #b42d1f;
  --td-info-bg: #e6effa; --td-info-fg: #1d5799;
  --td-violet-bg: #efeafd; --td-violet-fg: #5535b8;

  --td-radius: 24px;
  --td-shadow: 0 18px 44px -22px rgba(16, 22, 40, 0.18), 0 2px 10px rgba(16, 22, 40, 0.05);
  --td-sidebar-w: 264px;
  --td-topbar-h: 62px;
  --td-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --td-font-display: 'Space Grotesk', 'Inter', -apple-system, sans-serif;
  --td-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --td-canvas: #0a0c11;
  --td-surface: rgba(22, 26, 35, 0.92);
  --td-surface-solid: #161a23;
  --td-surface-muted: #1b202c;
  --td-surface-hover: #232938;
  --td-border: rgba(255, 255, 255, 0.09);
  --td-border-strong: rgba(255, 255, 255, 0.17);
  --td-ink: #f1f5f9;
  --td-ink-2: #cbd5e1;
  --td-ink-muted: #94a3b8;
  --td-brand: #1c856b;
  --td-brand-bright: #34b394;
  --td-brand-hover: #229c7e;
  --td-brand-link: #5eead4;
  --td-brand-soft: rgba(52, 179, 148, 0.16);
  --td-ok-bg: rgba(34, 197, 94, 0.16); --td-ok-fg: #6ee7b7;
  --td-warn-bg: rgba(245, 158, 11, 0.16); --td-warn-fg: #fcd34d;
  --td-danger-bg: rgba(239, 68, 68, 0.16); --td-danger-fg: #fca5a5;
  --td-info-bg: rgba(59, 130, 246, 0.16); --td-info-fg: #93c5fd;
  --td-violet-bg: rgba(139, 92, 246, 0.18); --td-violet-fg: #c4b5fd;
  --td-shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.65), 0 2px 10px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--td-font-sans); font-size: 14px; line-height: 1.55;
  color: var(--td-ink); background: var(--td-canvas); min-height: 100vh; overflow-x: hidden;
}

.td-ambient {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(640px 440px at 14% 8%, rgba(255, 176, 120, 0.14), transparent 70%),
    radial-gradient(660px 460px at 88% 12%, rgba(120, 130, 246, 0.14), transparent 70%),
    radial-gradient(720px 520px at 56% 86%, rgba(30, 133, 108, 0.09), transparent 72%);
}
[data-theme="dark"] .td-ambient {
  background:
    radial-gradient(640px 440px at 16% 8%, rgba(30, 133, 108, 0.14), transparent 70%),
    radial-gradient(660px 460px at 88% 12%, rgba(99, 102, 241, 0.12), transparent 70%);
}

a { color: var(--td-brand-link); text-decoration: none; }
a:hover { text-decoration: underline; }
p a, li a { text-decoration: underline; text-underline-offset: 2px; }
img, svg { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

.td-skip-link { position: absolute; left: -9999px; top: 8px; z-index: 9999; background: var(--td-brand); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; }
.td-skip-link:focus { left: 12px; }

/* App Shell */
.td-shell { position: relative; z-index: 1; display: flex; min-height: 100vh; }

/* Frosted Glass Sidebar (264px Desktop) */
.td-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--td-sidebar-w);
  background: var(--td-surface); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--td-border); display: flex; flex-direction: column; z-index: 40;
  transition: transform 0.24s ease;
}
.td-shell.is-collapsed .td-sidebar { transform: translateX(-100%); }
.td-shell.is-collapsed .td-main-wrap { margin-left: 0; }

.td-brand-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; color: var(--td-ink); text-decoration: none; }
.td-brand-head:hover { text-decoration: none; }
.td-brand-title { font-family: var(--td-font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.02em; line-height: 1.1; }
.td-brand-sub { font-size: 11px; color: var(--td-ink-muted); font-weight: 500; }

.td-side-search { padding: 4px 14px 10px; }
.td-side-search-box { position: relative; display: flex; align-items: center; }
.td-side-search-box svg { position: absolute; left: 12px; width: 15px; height: 15px; color: var(--td-ink-muted); pointer-events: none; }
.td-side-search-box input {
  width: 100%; height: 38px; padding: 0 12px 0 34px; border-radius: 12px;
  border: 1px solid var(--td-border); background: var(--td-surface-muted); color: var(--td-ink); font-size: 13px; outline: none;
}
.td-side-search-box input:focus { border-color: var(--td-brand); box-shadow: 0 0 0 3px var(--td-brand-ring); }

.td-side-nav { flex: 1; overflow-y: auto; padding: 2px 12px 16px; }
.td-nav-section { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--td-ink-muted); padding: 12px 10px 5px; }
.td-nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.td-nav-link {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px;
  color: var(--td-ink-2); font-weight: 500; font-size: 13.5px; text-decoration: none; min-height: 39px;
}
.td-nav-link:hover { background: var(--td-surface-hover); color: var(--td-ink); text-decoration: none; }
.td-nav-link svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.75; }
.td-nav-link.is-active {
  background: linear-gradient(90deg, rgba(22, 109, 88, 0.13) 0%, rgba(22, 109, 88, 0.03) 100%);
  color: var(--td-brand-link); font-weight: 600; border: 1px solid rgba(22, 109, 88, 0.16);
}
.td-nav-link.is-active::before {
  content: ''; position: absolute; left: -6px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 99px; background: var(--td-brand-bright);
  box-shadow: 0 0 10px rgba(30, 133, 108, 0.55);
}

.td-badge { margin-left: auto; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; line-height: 1.4; }
.td-badge-hot { background: var(--td-danger-bg); color: var(--td-danger-fg); }
.td-badge-new { background: var(--td-ok-bg); color: var(--td-ok-fg); }
.td-badge-pro { background: var(--td-violet-bg); color: var(--td-violet-fg); }
.td-badge-num { background: var(--td-surface-muted); color: var(--td-ink-muted); }

.td-side-foot { padding: 12px 14px; border-top: 1px solid var(--td-border); display: flex; align-items: center; gap: 10px; }
.td-avatar {
  width: 38px; height: 38px; border-radius: 999px; background: linear-gradient(135deg, #166d58, #0ea5e9);
  color: #fff; font-family: var(--td-font-display); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.td-side-user { min-width: 0; flex: 1; }
.td-side-user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-side-user-sub { font-size: 11.5px; color: var(--td-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main Wrapper & Topbar */
.td-main-wrap { flex: 1; margin-left: var(--td-sidebar-w); min-width: 0; display: flex; flex-direction: column; transition: margin-left 0.22s ease; }

.td-topbar {
  position: sticky; top: 0; z-index: 30; height: var(--td-topbar-h);
  background: var(--td-surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--td-border); padding: 0 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.td-top-left, .td-top-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.td-icon-btn {
  width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--td-border);
  background: var(--td-surface-solid); color: var(--td-ink-2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.td-icon-btn:hover { border-color: var(--td-brand); color: var(--td-brand-link); background: var(--td-brand-soft); }
.td-icon-btn.is-menu { border: 1.5px solid var(--td-brand); color: var(--td-brand-link); }
.td-icon-btn svg { width: 18px; height: 18px; }

.td-cmd-trigger {
  display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--td-border); background: var(--td-surface-muted);
  color: var(--td-ink-muted); cursor: pointer; min-width: 230px; font-size: 13px;
}
.td-cmd-kbd {
  margin-left: auto; font-family: var(--td-font-mono); font-size: 11px; padding: 2px 7px;
  border-radius: 6px; background: var(--td-surface-solid); border: 1px solid var(--td-border);
}
.td-pill-tag {
  display: inline-flex; align-items: center; justify-content: center; height: 36px; min-width: 92px;
  padding: 0 12px; border-radius: 999px; border: 1px solid var(--td-border); background: var(--td-surface-solid);
  font-size: 12.5px; font-weight: 700; color: var(--td-brand-link); white-space: nowrap;
}

/* Content */
.td-content { width: 100%; max-width: 1320px; margin: 0 auto; padding: 22px 24px 56px; flex: 1; }
.td-breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--td-ink-muted); margin-bottom: 8px; }
.td-breadcrumb a { color: var(--td-ink-muted); }

.td-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.td-page-title { margin: 0; font-family: var(--td-font-display); font-size: clamp(23px, 3vw, 31px); font-weight: 700; letter-spacing: -0.025em; line-height: 1.18; }
.td-page-sub { margin: 6px 0 0; color: var(--td-ink-muted); font-size: 14px; max-width: 680px; }
.td-head-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Buttons */
.td-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px;
  padding: 0 18px; border-radius: 999px; border: 1px solid transparent; font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.td-btn:hover { text-decoration: none; }
.td-btn-primary { background: var(--td-brand); color: #ffffff; box-shadow: 0 8px 20px -8px rgba(22, 109, 88, 0.5); }
.td-btn-primary:hover { background: var(--td-brand-hover); color: #ffffff; }
.td-btn-outline { background: var(--td-surface-solid); color: var(--td-ink); border-color: var(--td-border-strong); }
.td-btn-outline:hover { border-color: var(--td-brand); color: var(--td-brand-link); background: var(--td-brand-soft); }
.td-btn-sm { min-height: 36px; padding: 0 13px; font-size: 12.5px; }

/* Grids */
.td-grid { display: grid; gap: 20px; }
.td-grid-hero { grid-template-columns: minmax(0, 1.95fr) minmax(0, 1fr); }
.td-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.td-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.td-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.td-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.td-mt-20 { margin-top: 20px; }
.td-mt-12 { margin-top: 12px; }
.td-mb-16 { margin-bottom: 16px; }

/* Glass Cards */
.td-card {
  background: var(--td-surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--td-border); border-radius: var(--td-radius); box-shadow: var(--td-shadow); padding: 24px;
}
.td-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.td-card-title { margin: 0; font-family: var(--td-font-display); font-size: 17px; font-weight: 700; letter-spacing: -0.015em; }
.td-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--td-ink-muted); margin: 0 0 8px; }

/* Hero Overview Glass Card (with emerald radial aura) */
.td-hero-overview { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; }
.td-hero-overview::after {
  content: ''; position: absolute; top: -60px; right: -60px; width: 280px; height: 280px;
  border-radius: 999px; background: radial-gradient(circle, rgba(30, 133, 108, 0.16) 0%, transparent 70%); pointer-events: none;
}
.td-hero-h2 { margin: 0 0 8px; font-family: var(--td-font-display); font-size: clamp(20px, 2.3vw, 25px); font-weight: 700; letter-spacing: -0.02em; }

/* Converter Bar inside Hero Glass Card */
.td-conv-bar {
  display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 16px;
  background: var(--td-surface-solid); border: 1.5px solid var(--td-border-strong);
  box-shadow: 0 6px 20px -10px rgba(16, 22, 40, 0.12);
}
.td-conv-bar:focus-within { border-color: var(--td-brand); box-shadow: 0 0 0 3px var(--td-brand-ring); }
.td-conv-bar input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; padding: 9px 12px; font-size: 14px; }

/* Solid Emerald Gradient Hero Card */
.td-hero-emerald {
  background: linear-gradient(135deg, #166d58 0%, #104f40 100%);
  color: #ffffff; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: var(--td-radius);
  box-shadow: 0 22px 44px -20px rgba(16, 79, 64, 0.55); padding: 24px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.td-hero-emerald .td-eyebrow { color: rgba(255, 255, 255, 0.86); }
.td-hero-big-num { font-family: var(--td-font-display); font-size: clamp(28px, 3vw, 38px); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 4px 0 10px; }
.td-hero-delta { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); color: #ffffff; font-size: 12.5px; font-weight: 600; align-self: flex-start; }

/* Flat KPI Strip (#f0f3f9) */
.td-kpi-strip {
  background: var(--td-surface-muted); border: 1px solid var(--td-border); border-radius: var(--td-radius);
  padding: 18px 20px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
}
.td-kpi-item { display: flex; align-items: center; gap: 12px; padding-right: 12px; border-right: 1px solid var(--td-border); }
.td-kpi-item:last-child { border-right: none; padding-right: 0; }
.td-kpi-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 700; }
.td-ic-blue { background: var(--td-info-bg); color: var(--td-info-fg); }
.td-ic-violet { background: var(--td-violet-bg); color: var(--td-violet-fg); }
.td-ic-amber { background: var(--td-warn-bg); color: var(--td-warn-fg); }
.td-ic-green { background: var(--td-ok-bg); color: var(--td-ok-fg); }
.td-ic-rose { background: var(--td-danger-bg); color: var(--td-danger-fg); }
.td-kpi-lbl { font-size: 12px; color: var(--td-ink-muted); font-weight: 500; }
.td-kpi-val { font-family: var(--td-font-display); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }

/* Virtual Purple-Pink Referral & Checkin Card */
.td-virtual-card {
  background: linear-gradient(135deg, #4361ee 0%, #7c3aed 52%, #db2777 100%);
  color: #ffffff; border-radius: var(--td-radius); padding: 24px; position: relative; overflow: hidden;
  box-shadow: 0 22px 44px -20px rgba(124, 58, 237, 0.45); display: flex; flex-direction: column; justify-content: space-between;
}

/* Quick Shortcuts (Lối tắt nhanh) */
.td-shortcut {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 10px; border-radius: 18px; background: var(--td-surface); border: 1px solid var(--td-border);
  color: var(--td-ink); text-decoration: none; text-align: center; font-weight: 600; font-size: 13px;
  box-shadow: var(--td-shadow);
}
.td-shortcut:hover { border-color: var(--td-brand); color: var(--td-brand-link); text-decoration: none; }

/* Countdown & Voucher Cards */
.td-clock-boxes { display: inline-flex; align-items: center; gap: 6px; font-family: var(--td-font-mono); font-weight: 700; }
.td-clock-num { background: var(--td-brand); color: #fff; padding: 4px 8px; border-radius: 8px; min-width: 32px; text-align: center; }

.td-voucher {
  display: flex; background: var(--td-surface-solid); border: 1px solid var(--td-border);
  border-radius: 18px; overflow: hidden; box-shadow: 0 6px 18px -12px rgba(16,22,40,0.14);
}
.td-voucher-stub {
  width: 100px; flex-shrink: 0; padding: 14px 10px;
  background: linear-gradient(155deg, #166d58, #0f4d3d); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  border-right: 2px dashed rgba(255,255,255,0.4);
}
.td-voucher-stub.is-hot { background: linear-gradient(155deg, #c73415, #9f230a); }
.td-voucher-body { flex: 1; padding: 14px 16px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; min-width: 0; }
.td-voucher-title { margin: 0; font-weight: 700; font-size: 14px; line-height: 1.35; }

/* Segmented Tabs (WCAG role="tablist") */
.td-seg-tabs { display: inline-flex; flex-wrap: wrap; padding: 4px; border-radius: 16px; background: var(--td-surface-muted); border: 1px solid var(--td-border); gap: 4px; }
.td-seg-btn { border: none; background: transparent; padding: 7px 13px; border-radius: 12px; font-size: 13px; font-weight: 600; color: var(--td-ink-muted); cursor: pointer; min-height: 36px; }
.td-seg-btn.is-active { background: var(--td-surface-solid); color: var(--td-brand-link); box-shadow: 0 2px 6px rgba(0,0,0,0.06); }

/* Forms & Tables */
.td-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.td-field { display: flex; flex-direction: column; gap: 6px; }
.td-field label { font-size: 12.5px; font-weight: 600; color: var(--td-ink-2); }
.td-input, .td-select, .td-textarea {
  width: 100%; min-height: 42px; padding: 9px 13px; border-radius: 12px;
  border: 1px solid var(--td-border-strong); background: var(--td-surface-solid); color: var(--td-ink); outline: none;
}
.td-select { cursor: pointer; }
.td-input:focus, .td-select:focus, .td-textarea:focus { border-color: var(--td-brand); box-shadow: 0 0 0 3px var(--td-brand-ring); }
.td-mono { font-family: var(--td-font-mono); font-variant-numeric: tabular-nums; }

.td-status { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.td-status-ok { background: var(--td-ok-bg); color: var(--td-ok-fg); }
.td-status-warn { background: var(--td-warn-bg); color: var(--td-warn-fg); }
.td-status-err { background: var(--td-danger-bg); color: var(--td-danger-fg); }
.td-status-info { background: var(--td-info-bg); color: var(--td-info-fg); }

.td-table-wrap { width: 100%; overflow-x: auto; border-radius: 16px; border: 1px solid var(--td-border); }
.td-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.td-table th { text-align: left; padding: 11px 14px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: var(--td-ink-muted); background: var(--td-surface-muted); border-bottom: 1px solid var(--td-border); white-space: nowrap; }
.td-table td { padding: 11px 14px; border-bottom: 1px solid var(--td-border); }
.td-table tbody tr:last-child td { border-bottom: none; }
.td-num { text-align: right; font-family: var(--td-font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

.td-alert { padding: 12px 16px; border-radius: 14px; font-size: 13.5px; font-weight: 500; margin-bottom: 14px; }
.td-alert-ok { background: var(--td-ok-bg); color: var(--td-ok-fg); }
.td-alert-err { background: var(--td-danger-bg); color: var(--td-danger-fg); }
.td-alert-info { background: var(--td-info-bg); color: var(--td-info-fg); }
.td-code { background: #0f172a; color: #e2e8f0; padding: 15px; border-radius: 14px; overflow-x: auto; font-family: var(--td-font-mono); font-size: 12.5px; line-height: 1.6; margin: 0; }

/* FAQ */
.td-faq-list { display: flex; flex-direction: column; gap: 10px; }
.td-faq-item { border: 1px solid var(--td-border); border-radius: 16px; background: var(--td-surface-solid); }
.td-faq-item summary { padding: 14px 18px; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.td-faq-item summary::-webkit-details-marker { display: none; }
.td-faq-item summary::after { content: '+'; font-size: 18px; color: var(--td-brand-link); font-weight: 700; }
.td-faq-item[open] summary::after { content: '−'; }
.td-faq-body { padding: 10px 18px 16px; color: var(--td-ink-2); border-top: 1px solid var(--td-border); }

/* Modals (Ctrl+K + Guide + Rules) */
.td-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.52); backdrop-filter: blur(4px);
  z-index: 80; display: none; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; overflow-y: auto;
}
.td-modal-backdrop.is-open { display: flex; }
.td-modal {
  width: 100%; max-width: 580px; background: var(--td-surface-solid); border: 1px solid var(--td-border-strong);
  border-radius: 22px; box-shadow: 0 28px 64px -16px rgba(0, 0, 0, 0.35); overflow: hidden;
}
.td-modal-head { padding: 14px 18px; border-bottom: 1px solid var(--td-border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.td-modal-body { padding: 18px; max-height: 70vh; overflow-y: auto; }
.td-cmd-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 12px; color: var(--td-ink); text-decoration: none; }
.td-cmd-item:hover { background: var(--td-surface-hover); text-decoration: none; }

/* Ecosystem & Footer */
.td-eco-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.td-eco-card { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 16px; border: 1px solid var(--td-border); background: var(--td-surface-solid); color: var(--td-ink); text-decoration: none; }
.td-eco-card:hover { border-color: var(--td-brand); text-decoration: none; }
.td-footer { margin-top: auto; border-top: 1px solid var(--td-border); padding: 20px 24px; background: var(--td-surface); font-size: 13px; color: var(--td-ink-muted); }
.td-footer-inner { max-width: 1320px; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.td-footer-links { display: flex; flex-wrap: wrap; gap: 14px; }
.td-footer-links a { color: var(--td-ink-muted); }

.td-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 35; }
.td-overlay.is-open { display: block; }

/* Rich Multi-Type Toast Stack (Success / Error / Warning / Info / Promo) */
.td-toast-stack {
  position: fixed; top: 76px; right: 20px; z-index: 120;
  display: flex; flex-direction: column; gap: 10px;
  width: min(380px, calc(100vw - 24px)); pointer-events: none;
}
.td-toast-item {
  pointer-events: auto; position: relative; overflow: hidden;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 14px 15px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(14px);
  border: 1px solid var(--td-border-strong);
  box-shadow: 0 18px 42px -12px rgba(15, 23, 42, 0.22);
  color: var(--td-ink); font-size: 13.5px; line-height: 1.45;
  transform: translateX(115%); opacity: 0;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
}
[data-theme="dark"] .td-toast-item {
  background: rgba(15, 23, 42, 0.96); border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 20px 48px -12px rgba(0, 0, 0, 0.65);
}
.td-toast-item.is-in { transform: translateX(0); opacity: 1; }
.td-toast-item.is-out { transform: translateX(115%); opacity: 0; }
.td-toast-ico {
  flex: 0 0 34px; height: 34px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}
.td-toast-body { flex: 1; min-width: 0; }
.td-toast-title { font-weight: 700; font-size: 13.5px; color: var(--td-ink); margin-bottom: 2px; }
.td-toast-msg { font-size: 12.8px; color: var(--td-ink-2); word-break: break-word; }
.td-toast-close {
  flex: 0 0 auto; background: transparent; border: none; color: var(--td-ink-muted);
  cursor: pointer; width: 26px; height: 26px; border-radius: 8px; font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.td-toast-close:hover { background: var(--td-surface-hover); color: var(--td-ink); }
.td-toast-bar {
  position: absolute; left: 0; bottom: 0; height: 3.5px; width: 100%;
  transform-origin: left center; animation: tdToastBar linear forwards;
}
.td-toast-item:hover .td-toast-bar { animation-play-state: paused; }
@keyframes tdToastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.td-toast-success { border-left: 4px solid #16a34a; }
.td-toast-success .td-toast-ico { background: rgba(22, 163, 74, 0.14); color: #15803d; }
.td-toast-success .td-toast-bar { background: linear-gradient(90deg, #16a34a, #10b981); }
[data-theme="dark"] .td-toast-success .td-toast-ico { color: #4ade80; }

.td-toast-error { border-left: 4px solid #dc2626; }
.td-toast-error .td-toast-ico { background: rgba(220, 38, 38, 0.14); color: #b91c1c; }
.td-toast-error .td-toast-bar { background: linear-gradient(90deg, #dc2626, #f43f5e); }
[data-theme="dark"] .td-toast-error .td-toast-ico { color: #f87171; }

.td-toast-warning { border-left: 4px solid #d97706; }
.td-toast-warning .td-toast-ico { background: rgba(217, 119, 6, 0.15); color: #b45309; }
.td-toast-warning .td-toast-bar { background: linear-gradient(90deg, #f59e0b, #d97706); }
[data-theme="dark"] .td-toast-warning .td-toast-ico { color: #fbbf24; }

.td-toast-info { border-left: 4px solid #2563eb; }
.td-toast-info .td-toast-ico { background: rgba(37, 99, 235, 0.14); color: #1d4ed8; }
.td-toast-info .td-toast-bar { background: linear-gradient(90deg, #3b82f6, #2563eb); }
[data-theme="dark"] .td-toast-info .td-toast-ico { color: #60a5fa; }

.td-toast-promo { border-left: 4px solid #7c3aed; }
.td-toast-promo .td-toast-ico { background: linear-gradient(135deg, rgba(124,58,237,0.18), rgba(236,72,153,0.18)); color: #6d28d9; }
.td-toast-promo .td-toast-bar { background: linear-gradient(90deg, #7c3aed, #ec4899); }
[data-theme="dark"] .td-toast-promo .td-toast-ico { color: #c084fc; }

/* In-app Confirm / Gift Modal Styling */
.td-modal-sm { max-width: 440px; }
.td-modal-foot { padding: 12px 18px; border-top: 1px solid var(--td-border); display: flex; justify-content: flex-end; gap: 10px; background: var(--td-surface-muted); }

/* Notification unread dot */
.td-notif-btn { position: relative; }
.td-notif-dot {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: #dc2626; color: #fff; font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}

/* pSEO Rich Editorial Table & Formula */
.td-formula-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 14px 16px; border-radius: 16px; background: var(--td-surface-muted);
  border: 1px dashed var(--td-brand); font-weight: 600; font-size: 13.5px;
}
.td-formula-pill {
  padding: 5px 11px; border-radius: 999px; background: var(--td-surface-solid);
  border: 1px solid var(--td-border-strong); color: var(--td-ink);
}
@media (max-width: 640px) {
  .td-toast-stack { top: auto; bottom: 74px; right: 12px; left: 12px; width: auto; }
}

/* Mobile Floating Bottom Navigation Bar (like top cashback apps) */
.td-bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 32;
  background: var(--td-surface-solid); border-top: 1px solid var(--td-border);
  height: 62px; padding: 0 6px; align-items: center; justify-content: space-around;
  box-shadow: 0 -8px 24px -10px rgba(15, 23, 42, 0.14);
}
.td-bnav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--td-ink-muted); text-decoration: none; min-width: 58px; height: 48px;
  background: transparent; border: none; cursor: pointer;
}
.td-bnav-item.is-active { color: var(--td-brand-link); }
.td-bnav-fab {
  background: var(--td-brand); color: #ffffff !important; border-radius: 999px;
  padding: 0 14px; height: 40px; flex-direction: row; gap: 5px; font-size: 12px;
  box-shadow: 0 8px 18px -6px rgba(22, 109, 88, 0.55);
}

@media (max-width: 1180px) {
  .td-kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .td-kpi-item { border-right: none; padding-right: 0; }
  .td-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .td-eco-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 991px) {
  .td-sidebar { width: 284px; background: var(--td-surface-solid); transform: translateX(-100%); }
  .td-shell.is-mobile-open .td-sidebar { transform: translateX(0); }
  .td-main-wrap { margin-left: 0 !important; }
  .td-grid-hero, .td-grid-2, .td-grid-3, .td-grid-4 { grid-template-columns: minmax(0, 1fr); }
  .td-cmd-trigger { min-width: 0; padding: 0 12px; }
  .td-cmd-text, .td-cmd-kbd { display: none; }
}
@media (max-width: 768px) {
  .td-bottom-nav { display: flex; }
  .td-footer { padding-bottom: 82px; }
}
@media (max-width: 640px) {
  .td-topbar { padding: 0 12px; }
  .td-content { padding: 16px 12px 36px; }
  .td-card, .td-hero-emerald, .td-virtual-card { padding: 18px; border-radius: 20px; }
  .td-conv-bar { flex-direction: column; align-items: stretch; }
  .td-form-grid, .td-eco-grid { grid-template-columns: minmax(0, 1fr); }
  .td-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .td-pill-hide-sm { display: none; }
}
