/* Shared tokens, reset and small components (buttons, tags, inputs, dialogs, toasts). Used by index.html and login.html. */

@font-face {
  font-family: "Plex";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("../vendor/fonts/ibm-plex-sans/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Plex";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("../vendor/fonts/ibm-plex-sans/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Plex";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("../vendor/fonts/ibm-plex-sans/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

:root {
  --bg: #0b0e11;
  --panel: #181a20;
  --panel-2: #1e2329;
  --line: #2b3139;
  --line-soft: #22272e;
  --hover: #2b3139;
  --hover-2: #363c45;
  --text: #eaecef;
  --text-2: #b7bdc6;
  --text-3: #848e9c;
  --text-4: #5e6673;
  --accent: #fcd535;
  --accent-2: #f0b90b;
  --accent-ink: #202630;
  --up: #0ecb81;
  --down: #f6465d;
  --up-bg: rgba(14, 203, 129, 0.12);
  --down-bg: rgba(246, 70, 93, 0.12);
  --accent-bg: rgba(252, 213, 53, 0.1);
  --font: "Plex", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", system-ui, sans-serif;
  --radius: 8px;
  --topbar-h: 56px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
::selection { background: rgba(252, 213, 53, 0.3); }

* { scrollbar-width: thin; scrollbar-color: #474d57 transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #474d57; border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* direction colours win over whatever text colour the component sets */
.up { color: var(--up) !important; }
.down { color: var(--down) !important; }
.muted { color: var(--text-3); }
.warn { color: var(--accent-2); }
.nowrap { white-space: nowrap; }
.icon { width: 16px; height: 16px; flex: none; display: block; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 6px;
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--line); color: var(--text);
  transition: background-color 0.12s, color 0.12s, border-color 0.12s, opacity 0.12s;
  user-select: none;
}
.btn:hover { background: var(--hover-2); }
.btn:disabled { opacity: 0.45; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); }
.btn-up { background: var(--up); color: #fff; }
.btn-up:hover { background: #32d993; }
.btn-danger { background: var(--down); color: #fff; }
.btn-danger:hover { background: #ff707e; }
.btn-danger-ghost { background: transparent; color: var(--down); box-shadow: inset 0 0 0 1px rgba(246, 70, 93, 0.55); }
.btn-danger-ghost:hover { background: var(--down-bg); }
.btn-ghost { background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 1px #474d57; }
.btn-ghost:hover { background: var(--line); color: var(--text); }
.btn-text { background: transparent; color: var(--text-2); padding: 0 6px; }
.btn-text:hover { background: transparent; color: var(--accent); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 4px; }
.btn-lg { height: 44px; padding: 0 16px; font-size: 15px; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: 32px; padding: 0; background: transparent; color: var(--text-3); }
.btn-icon:hover { background: var(--line); color: var(--text); }
.btn.is-busy { pointer-events: none; opacity: 0.7; }
.btn.is-busy::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- tags, pills */
.tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 5px; border-radius: 3px;
  font-size: 11px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--line); color: var(--text-2);
}
.tag-accent { background: var(--accent-bg); color: var(--accent); }
.tag-up { background: var(--up-bg); color: var(--up); }
.tag-down { background: var(--down-bg); color: var(--down); }
.tag-warn { background: rgba(240, 185, 11, 0.14); color: var(--accent-2); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--line); color: var(--text-2);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-up { background: var(--up-bg); color: var(--up); }
.pill-down { background: var(--down-bg); color: var(--down); }
.pill-idle { background: rgba(240, 185, 11, 0.14); color: var(--accent-2); }

/* ---------------------------------------------------------------- inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; color: var(--text-2); display: flex; justify-content: space-between; gap: 8px; }
.input-wrap {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 8px;
  background: transparent; box-shadow: inset 0 0 0 1px #474d57; transition: box-shadow 0.12s;
}
.input-wrap:hover, .input-wrap:focus-within { box-shadow: inset 0 0 0 1px var(--accent); }
.input-wrap input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text);
  font-size: 16px; font-weight: 500;
}
.input-wrap input::placeholder { color: var(--text-4); font-weight: 400; }
.input-wrap .suffix { color: var(--text-3); font-size: 13px; white-space: nowrap; }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 28px; padding: 0 10px; border-radius: 4px; font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--line); color: var(--text-2); transition: background-color 0.12s, color 0.12s;
}
.chip:hover { color: var(--text); background: var(--hover-2); }
.chip.is-active { background: #474d57; color: var(--text); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; color: var(--text); user-select: none; }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; margin: 1px 0 0; border-radius: 3px;
  box-shadow: inset 0 0 0 1.5px #5e6673; background: transparent; cursor: pointer; display: grid; place-content: center; }
.check input:checked { background: var(--accent); box-shadow: none; }
.check input:checked::after { content: ""; width: 9px; height: 5px; border: solid var(--accent-ink); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.check small { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; }

/* ---------------------------------------------------------------- dialog / bottom sheet */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0, 0, 0, 0.6); animation: fade-in 0.14s ease-out;
}
.modal {
  width: min(420px, 100%); max-height: min(86vh, 760px); display: flex; flex-direction: column;
  background: var(--panel-2); border-radius: 16px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: pop-in 0.16s ease-out;
}
.modal.is-wide { width: min(720px, 100%); }
.modal-grip { display: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 12px; }
.modal-title { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
.modal-close { width: 28px; height: 28px; display: grid; place-content: center; border-radius: 6px; color: var(--text-3); flex: none; }
.modal-close:hover { color: var(--text); background: var(--line); }
.modal-body { padding: 4px 24px 8px; overflow: auto; display: flex; flex-direction: column; gap: 16px; font-size: 14px; color: var(--text-2); }
.modal-body p { margin: 0; }
.modal-foot { display: flex; gap: 12px; padding: 16px 24px 24px; }
.modal-foot .btn { flex: 1; height: 44px; font-size: 15px; border-radius: 8px; }
.kv { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 8px; background: rgba(11, 14, 17, 0.5); }
.kv-row { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; }
.kv-row > :first-child { color: var(--text-3); }
.kv-row > :last-child { color: var(--text); text-align: right; font-weight: 500; }
.note { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.note-danger { color: var(--down); }
.note-box { padding: 10px 12px; border-radius: 8px; background: var(--down-bg); color: #ff8a98; font-size: 13px; line-height: 1.5; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes sheet-up { from { transform: translateY(100%); } }

@media (max-width: 767px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal.is-wide {
    width: 100%; max-height: 88vh; border-radius: 16px 16px 0 0; animation: sheet-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal-grip { display: block; width: 36px; height: 4px; border-radius: 2px; background: #474d57; margin: 8px auto 0; flex: none; }
  .modal-head { padding: 12px 16px 10px; }
  .modal-title { font-size: 18px; }
  .modal-body { padding: 4px 16px 8px; }
  .modal-foot { padding: 12px 16px 16px; }
  .modal-foot .btn { height: 48px; font-size: 16px; }
}

/* ---------------------------------------------------------------- toasts */
/* top centre, like Binance — never on top of the action buttons in the right column */
#toast-root {
  position: fixed; z-index: 200; top: 64px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: min(480px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 8px; pointer-events: auto;
  background: #2b3139; color: var(--text); font-size: 14px; line-height: 1.45; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease-out; overflow-wrap: anywhere;
}
/* a toast can lie over the head of a tall dialog: there it must not take the click meant for the close button */
html.has-modal .toast { pointer-events: none; }
.toast .icon { width: 18px; height: 18px; margin-top: 1px; }
.toast-error .icon { color: var(--down); }
.toast-success .icon { color: var(--up); }
.toast-info .icon { color: var(--accent); }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@media (max-width: 767px) {
  #toast-root { top: calc(8px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px; transform: none; width: auto; align-items: stretch; max-width: none; }
}
