/* ============================================================================
   SynapGo — "Clean Light" design system (light, fixed theme)
   Plain CSS (no build). Layered ON TOP of Tailwind Play CDN: use Tailwind
   utilities for layout/spacing, these classes for the themed surfaces.
   Component classes beat element preflight (class > element specificity),
   so prefer .card / .input / .btn / .data-table over raw utilities.
   ============================================================================ */

:root {
  --bg:        #f6f8fb;   /* page canvas */
  --panel:     #ffffff;   /* card surface */
  --panel-2:   #f1f5f9;   /* nested surface: table header, inputs, hover */
  --sidebar:   #ffffff;
  --border:    #e6eaf0;
  --border-2:  #d6dde7;
  --text:      #0f172a;
  --text-2:    #334155;   /* secondary */
  --muted:     #64748b;   /* labels, hints */
  --accent:    #4f46e5;   /* primary indigo */
  --accent-2:  #6366f1;   /* brighter indigo (active) */
  --accent-bg: #eef2ff;
  --danger:    #dc2626;
  --danger-bg: #fef2f2;
  --warn:      #b45309;
  --warn-bg:   #fffbeb;
  --info:      #2563eb;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── base ─────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text); }
::selection { background: var(--accent-bg); }

/* slim scrollbars */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ── price-board colors (VN convention) ───────────────────────────────────── */
.px-up    { color: #16a34a; font-weight: 600; }  /* tăng  — xanh lá  */
.px-down  { color: #dc2626; font-weight: 600; }  /* giảm  — đỏ       */
.px-ceil  { color: #a21caf; font-weight: 600; }  /* trần  — tím      */
.px-floor { color: #0891b2; font-weight: 600; }  /* sàn   — cyan     */
.px-ref   { color: #ca8a08; font-weight: 600; }  /* tham chiếu — vàng */

/* ── app shell ────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 38px; height: 38px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--accent);
  border-radius: 9px; font-size: 19px; overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-name { display: block; font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.1; }
.brand-sub  { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--text-2); font-size: 14px; text-decoration: none;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }
.nav-item .ti { font-size: 18px; width: 20px; text-align: center; }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot .user { display: flex; align-items: center; gap: 7px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 26px; min-height: 60px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  background: rgba(246,248,251,.85); backdrop-filter: blur(10px);
}
.page-title { font-size: 19px; font-weight: 600; margin: 0; }
.page { padding: 24px 26px; display: flex; flex-direction: column; gap: 20px; }

.acct-select { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.acct-select .ti { font-size: 17px; }

/* ── cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  margin: 0 0 14px; display: flex; align-items: center; gap: 8px;
}
.card-title .ti { color: var(--muted); font-size: 17px; }
.card-sub { font-size: 12px; color: var(--muted); }

/* ── stat / KPI cards ─────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 25px; font-weight: 600; font-family: var(--mono); letter-spacing: -.5px; margin-top: 7px; }
.stat-foot { font-size: 11px; color: var(--muted); margin-top: 5px; }

/* ── tables ───────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.data-table thead th {
  text-align: left; font-weight: 500; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table thead th.right, .data-table td.right { text-align: right; }
.data-table tbody td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--panel-2); }
.data-table .sym { color: var(--text); font-weight: 600; }
.data-table .num { font-family: var(--mono); }
.data-table .muted { color: var(--muted); }
.data-table .empty { color: var(--muted); text-align: center; padding: 18px 10px; }
.scroll-x { overflow-x: auto; }

/* ── buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; font-family: inherit;
  border: 1px solid var(--border-2); background: var(--panel); color: var(--text);
  cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--panel-2); border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .ti { font-size: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #ffffff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #ffffff; font-weight: 600; }
.btn-danger:hover { opacity: .9; background: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 9px; font-size: 11px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── forms ────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label, label.field-label { font-size: 11px; color: var(--muted); }
.input, .select, textarea.input {
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 8px;
  padding: 8px 11px; color: var(--text); font-size: 13px; font-family: inherit; outline: none;
  width: 100%;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.input::placeholder { color: var(--muted); }
.input.uppercase { text-transform: uppercase; }
.select { appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; padding-right: 30px; }
/* soft fallback for any raw control not yet class-migrated */
input:not([type=checkbox]):not([type=radio]):not(.btn), select, textarea {
  color: var(--text); font-family: inherit;
}

/* ── badges / status pills ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 500;
  border: 1px solid var(--border-2); color: var(--text-2); background: var(--panel-2); white-space: nowrap;
}
.badge-success { color: #15803d; background: #dcfce7; border-color: transparent; }
.badge-danger  { color: #b91c1c; background: #fee2e2; border-color: transparent; }
.badge-warn    { color: #b45309; background: #fef3c7; border-color: transparent; }
.badge-info    { color: #1d4ed8; background: #dbeafe; border-color: transparent; }

/* ── order side (buy/sell) — distinct pill so it doesn't read as a price ───── */
.side-tag { display: inline-flex; padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.side-buy  { color: #15803d; background: #dcfce7; }
.side-sell { color: #b91c1c; background: #fee2e2; }

/* ── alerts / callouts ────────────────────────────────────────────────────── */
.alert { border-radius: 10px; padding: 12px 15px; font-size: 13px; border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text-2); }
.alert a { color: inherit; text-decoration: underline; font-weight: 500; }
.alert-warn    { border-color: #fcd34d; background: var(--warn-bg); color: var(--warn); }
.alert-success { border-color: #86efac; background: #f0fdf4; color: #15803d; }
.alert-danger  { border-color: #fca5a5; background: var(--danger-bg); color: #b91c1c; }

/* ── misc helpers ─────────────────────────────────────────────────────────── */
.divider { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.text-muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.text-up { color: #16a34a; }
.text-down { color: var(--danger); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.code-box { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 8px; padding: 10px 12px; font-family: var(--mono); font-size: 12px; color: var(--text); white-space: pre-wrap; word-break: break-all; }

/* ── list rows (JS-rendered account / source chips in settings) ───────────── */
.list-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px;
  background: var(--panel); font-size: 13px; color: var(--text-2);
}
.list-row b { color: var(--text); font-weight: 600; }

/* ── auth / login ─────────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 410px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 30px; box-shadow: var(--shadow); }

/* ── hamburger + drawer backdrop (mobile only; hidden on desktop) ──────────── */
.nav-toggle { display: none; background: transparent; border: 0; color: var(--text); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.nav-toggle:hover { background: var(--panel-2); }
.nav-backdrop { display: none; }

/* manual-order form: auto-fit grid (responsive, no fixed widths) */
.order-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.order-form .btn { height: 38px; }

/* ── responsive / mobile ──────────────────────────────────────────────────── */
@media (max-width: 860px) {
  html, body { overflow-x: hidden; }
  .main { overflow-x: hidden; min-width: 0; }
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100dvh; width: 250px; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 44px rgba(15, 23, 42, .22);
  }
  body.nav-open .sidebar { transform: none; }
  .nav-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 55;
    opacity: 0; pointer-events: none; transition: opacity .22s; }
  body.nav-open .nav-backdrop { display: block; opacity: 1; pointer-events: auto; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .page-title { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page { padding: 16px 14px; gap: 14px; }
  .card { padding: 14px 15px; }
  .card-title { font-size: 13px; }
  .stat-value { font-size: 22px; }
  .stat-grid { grid-template-columns: 1fr; gap: 12px; }
  .data-table { font-size: 12px; }
  .data-table thead th, .data-table tbody td { padding: 8px 8px; white-space: nowrap; }
  .scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .list-row { flex-wrap: wrap; gap: 8px; }
  .acct-select { font-size: 12px; }
  .acct-select select { max-width: 46vw; }
  .auth-card { padding: 22px; }
}
