/* Palette from DT Money Gateway: dark navy + sky cyan (dark is the default theme) */
:root {
  --bg: #0E1B29;
  --surface: #13263A;
  --surface-2: #10202F;
  --text: #E6EEF5;
  --text-2: #8FA3B8;
  --muted: #6A8197;
  --border: #22405A;
  --brand: #5CC8F0;
  --brand-2: #1593C4;
  --brand-soft: #1A3A52;
  --accent: #5CC8F0;
  --accent-ink: #06202E;
  --success: #4CC38A;
  --success-soft: #173D2E;
  --danger: #F07C7C;
  --danger-soft: #3A1E24;
  --warn: #F2B65C;
  --ring: rgba(92, 200, 240, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 24px 48px rgba(0, 0, 0, .4);
  --radius: 14px;
  --font-display: "Bricolage Grotesque", "Kantumruy Pro", system-ui, sans-serif;
  --font-body: "Kantumruy Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --chart-1: #2FA0D2;      /* single-series line, validated against the dark surface */
  --chart-grid: #1E3650;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F2F7FA; --surface: #FFFFFF; --surface-2: #F5FAFD; --text: #0F2233; --text-2: #5B7085; --muted: #8A9CAE;
    --border: #D6E3EC; --brand: #0F7FAE; --brand-2: #1593C4; --brand-soft: #E1F2FA; --accent: #1593C4; --accent-ink: #FFFFFF;
    --success: #1E9E62; --success-soft: #DDF3E7; --danger: #D64545; --danger-soft: #FDECEC; --warn: #C27A0E;
    --ring: rgba(21, 147, 196, .22); --chart-1: #1593C4; --chart-grid: #E3ECF2;
    --shadow: 0 1px 2px rgba(15, 34, 51, .04), 0 8px 24px rgba(15, 34, 51, .06);
    --shadow-lg: 0 2px 4px rgba(15, 34, 51, .04), 0 24px 48px rgba(15, 34, 51, .10);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #F2F7FA; --surface: #FFFFFF; --surface-2: #F5FAFD; --text: #0F2233; --text-2: #5B7085; --muted: #8A9CAE;
  --border: #D6E3EC; --brand: #0F7FAE; --brand-2: #1593C4; --brand-soft: #E1F2FA; --accent: #1593C4; --accent-ink: #FFFFFF;
  --success: #1E9E62; --success-soft: #DDF3E7; --danger: #D64545; --danger-soft: #FDECEC; --warn: #C27A0E;
  --ring: rgba(21, 147, 196, .22); --chart-1: #1593C4; --chart-grid: #E3ECF2;
  --shadow: 0 1px 2px rgba(15, 34, 51, .04), 0 8px 24px rgba(15, 34, 51, .06);
  --shadow-lg: 0 2px 4px rgba(15, 34, 51, .04), 0 24px 48px rgba(15, 34, 51, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
svg { display: block; flex-shrink: 0; }

/* --- Scrollbars: thin, rounded, theme-coloured --- */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-2) 35%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-2) 30%, transparent);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--brand) 60%, transparent); }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-resizer { background: transparent; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }

/* --- Brand mark --- */
.mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  color: var(--bg);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: .95rem;
  background: var(--brand);
}

/* --- Theme toggle --- */
.theme-btn {
  width: 36px; height: 36px; padding: 0;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color .2s, color .2s, transform .2s var(--ease-spring);
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.theme-btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.theme-btn svg { width: 18px; height: 18px; animation: spin-in .5s var(--ease-spring); }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: .92rem;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: background .2s, border-color .2s, box-shadow .25s, transform .2s var(--ease-spring), filter .2s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.97); transition-duration: .08s; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.btn:disabled { opacity: .5; }
.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  filter: brightness(1.06);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 38%, transparent);
}
/* Light sweep across primary buttons on hover */
.btn-primary::before {
  content: '';
  position: absolute; inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
  transform: translateX(-120%);
}
.btn-primary:hover:not(:disabled)::before { animation: sweep .9s ease; }
/* Click ripple (span added by JS) */
.ripple {
  position: absolute; z-index: -1;
  border-radius: 50%;
  background: currentColor;
  opacity: .18;
  transform: scale(0);
  animation: ripple .6s ease-out forwards;
  pointer-events: none;
}
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-block { width: 100%; height: 48px; font-size: 1rem; }

/* --- Form fields --- */
.label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.field { position: relative; }
.field > svg.icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--ring); }
.field:focus-within > svg.icon { color: var(--brand); }

/* --- Alerts --- */
.alert {
  display: none;
  align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: .9rem;
  background: var(--danger-soft);
  color: var(--danger);
}
.alert.show { display: flex; animation: fade-up .35s var(--ease-out); }

/* ===================== Motion ===================== */
:root {
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

/* Smooth colour change when switching theme */
body, .card, .topbar, .side, .modal, .pill, th, td {
  transition-property: background-color, border-color, color, box-shadow, transform, filter, opacity;
  transition-duration: .3s;
  transition-timing-function: var(--ease-out);
}

@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes scale-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes slide-in-left { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes sweep { to { transform: translateX(120%); } }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }
@keyframes spin-in { from { transform: rotate(-90deg) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(30px, -24px) scale(1.06); } 66% { transform: translate(-22px, 18px) scale(.96); } }
@keyframes grow-up { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18) rotate(-6deg); } 100% { transform: scale(1); } }

/* Staggered entrance: JS sets --i on each element */
.reveal { animation: fade-up .55s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
.reveal-scale { animation: scale-in .5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }

.skeleton {
  border-radius: 10px;
  background: linear-gradient(90deg, var(--surface-2) 0%, color-mix(in srgb, var(--border) 70%, var(--surface-2)) 50%, var(--surface-2) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.3s linear infinite;
}

.shake { animation: shake .45s ease both; }

/* ===================== Custom dropdown (enhances <select>) ===================== */
.dd { position: relative; display: inline-block; width: 100%; }
.dd > select { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.dd-btn {
  width: 100%; height: 42px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: .9rem; text-align: left;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.dd-btn:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); }
.dd-btn:focus-visible, .dd.open .dd-btn { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--ring); }
.dd-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-chev { color: var(--text-2); transition: transform .35s var(--ease-spring), color .2s; }
.dd.open .dd-chev { transform: rotate(180deg); color: var(--brand); }

.dd-menu {
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 50;
  min-width: 100%; width: max-content; max-width: min(340px, 90vw);
  max-height: 420px; overflow-y: auto;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--brand) 18%, var(--border));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,.04);
  transform-origin: top left;
  opacity: 0; visibility: hidden;
  transform: translateY(-6px) scale(.96);
  transition: opacity .18s ease, transform .3s var(--ease-spring), visibility 0s .3s;
}
.dd.up .dd-menu { top: auto; bottom: calc(100% + 8px); transform-origin: bottom left; transform: translateY(6px) scale(.96); }
.dd.open .dd-menu { opacity: 1; visibility: visible; transform: none; transition: opacity .18s ease, transform .35s var(--ease-spring), visibility 0s; }
.dd-menu.dd-right { left: auto; right: 0; transform-origin: top right; }
.dd.up .dd-menu.dd-right { transform-origin: bottom right; }

/* Highlight pill that glides between items */
.dd-hl {
  position: absolute; left: 6px; right: 6px; top: 0; height: 38px; z-index: 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--brand) 13%, transparent);
  opacity: 0;
  transition: transform .28s var(--ease-spring), height .2s, opacity .15s;
  pointer-events: none;
}
.dd-hl.on { opacity: 1; }

.dd-opt {
  position: relative; z-index: 1;
  width: 100%; min-height: 38px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--text);
  font: inherit; font-size: .9rem; text-align: left; white-space: nowrap;
  cursor: pointer;
}
.dd.open .dd-opt { animation: dd-item .32s var(--ease-out) both; animation-delay: calc(var(--i) * 22ms); }
@keyframes dd-item { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.dd-opt .dd-ico { width: 22px; text-align: center; flex-shrink: 0; color: var(--brand); transition: transform .3s var(--ease-spring); }
.dd-opt:hover .dd-ico, .dd-opt:focus .dd-ico { transform: scale(1.18); }
.dd-opt:focus { outline: none; }
.dd-opt .dd-txt { flex: 1; }
.dd-opt .dd-check { color: var(--brand); opacity: 0; transform: scale(.4); transition: opacity .2s, transform .35s var(--ease-spring); }
.dd-opt.sel { color: var(--brand); font-weight: 600; }
.dd-opt.sel .dd-check { opacity: 1; transform: none; }
.dd-sep { height: 1px; margin: 4px 6px; background: var(--border); }
/* Options with an SVG icon (data-icon) and a muted hint on the right (data-hint) */
.dd-opt .dd-ico.svg {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
  transition: color .2s, background .2s, border-color .2s, transform .3s var(--ease-spring);
}
.dd-opt:hover .dd-ico.svg, .dd-opt:focus .dd-ico.svg { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
.dd-opt.sel .dd-ico.svg { color: var(--accent-ink); background: var(--brand); border-color: transparent; }
.dd-opt .dd-hint { font-size: .74rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.dd-opt.sel .dd-hint { color: color-mix(in srgb, var(--brand) 70%, var(--muted)); }
.dd-menu:has(.dd-hint) { min-width: 250px; }
.dd-label { display: inline-flex; align-items: center; gap: 8px; }
.dd-label-ico { display: inline-flex; color: var(--brand); flex: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
}
