/* Gold Copy mini-app — light theme in Elena's palette (cream + gold), mobile-first, safe-area aware.
   Shell for two products: copy-trading cabinet and (later) Account Management (DU).
   Same static stack as pwa/app (HTML + CSS + vanilla ES modules), but this is NOT the MT5 emulator. */
:root {
  --bg: #fbfaf7;
  --bg2: #f3efe6;
  --card: #ffffff;
  --ink: #1c1a16;
  --ink2: #6b6558;
  --ink3: #9a9384;
  --line: #e8e3d8;
  --line2: #f0ece3;
  --gold: #a87b26;
  --gold-2: #c79a3f;
  --gold-soft: #f7eeda;
  --green: #12855a;
  --green-soft: #e6f5ee;
  --red: #c23b32;
  --red-soft: #fbeceb;
  --shadow: 0 1px 2px rgba(28, 26, 22, .05), 0 10px 24px -14px rgba(28, 26, 22, .28);
  --radius: 16px;
  --radius-sm: 11px;
  --tabbar-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg2);
  color: var(--ink);
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

/* ---------------------------------------------------------------- top bar */
#topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(var(--safe-top) + 12px) 18px 10px;
  background: var(--bg);
}

#topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.01em;
}

#topbar .brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--gold-2), var(--gold));
  box-shadow: 0 0 0 3px var(--gold-soft);
}

#topbar-refresh {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink2);
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .35s ease, color .15s ease;
}

#topbar-refresh:active { color: var(--gold); transform: rotate(140deg); }

#topbar-refresh svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- screen */
.screen {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: 18px;
}

.pad { padding: 4px 16px 0; }

.h1 {
  margin: 6px 2px 6px;
  font-size: 23px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.02em;
}

.sub {
  margin: 0 2px 16px;
  color: var(--ink2);
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- form */
.form { padding: 6px 14px 14px; }

.field { display: block; padding: 10px 0; border-bottom: 1px solid var(--line2); }
.field:last-of-type { border-bottom: 0; }

.lab {
  display: block;
  margin-bottom: 6px;
  color: var(--ink3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  height: 44px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;                 /* 16px stops iOS from zooming the field on focus */
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 8px;
}

.field input::placeholder { color: #b8b1a3; }

.field:focus-within { border-bottom-color: var(--gold-2); }

.sel-wrap { position: relative; }

.sel-wrap::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink3);
  border-bottom: 2px solid var(--ink3);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.pw { position: relative; display: flex; align-items: center; }

.pw input { padding-right: 62px; }

.pw-eye {
  position: absolute;
  right: 0;
  height: 32px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--gold);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  margin-top: 16px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--ink);
  cursor: pointer;
  transition: transform .08s ease, opacity .15s ease;
}

.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .55; pointer-events: none; }

.btn-primary {
  background: linear-gradient(140deg, var(--gold-2), var(--gold));
  box-shadow: 0 8px 18px -10px rgba(168, 123, 38, .75);
}

.btn-ghost {
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn-danger { color: var(--red); background: var(--red-soft); box-shadow: none; }

.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row .btn { margin-top: 0; }

.spin {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- notice */
.banner {
  margin: 0 0 12px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.4;
}

.banner-err { color: var(--red); background: var(--red-soft); }
.banner-ok { color: var(--green); background: var(--green-soft); }

.note {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.note-i {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  line-height: 18px;
  text-align: center;
}

.note p { margin: 0; color: var(--ink2); font-size: 13px; }
.note b { color: var(--ink); font-weight: 600; }

/* Preview banner: the cabinet is rendering sample data, not a hub account. */
.demo-flag {
  margin: 12px 16px 0;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  color: var(--ink2);
  font-size: 12.5px;
  line-height: 1.4;
}

.demo-flag b { color: var(--gold); font-weight: 700; }

/* ---------------------------------------------------------------- cabinet hero */
.hero {
  margin: 4px 16px 0;
  padding: 18px 18px 16px;
  border-radius: 20px;
  background: radial-gradient(120% 120% at 100% 0%, #fffdf7 0%, #fff 55%, #fdf9f0 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.hero-lab { color: var(--ink3); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

.hero-bal { margin: 6px 0 0; font-size: 34px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hero-bal small { font-size: 15px; font-weight: 600; color: var(--ink3); letter-spacing: 0; }

.hero-sub { margin-top: 2px; font-size: 13px; color: var(--ink2); }
.hero-sub .up { color: var(--green); font-weight: 600; }
.hero-sub .down { color: var(--red); font-weight: 600; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-live { color: var(--green); background: var(--green-soft); }

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(18, 133, 90, .38); }
  55% { box-shadow: 0 0 0 5px rgba(18, 133, 90, 0); }
}

.kpis { display: flex; gap: 8px; margin: 14px 16px 0; }

.kpi {
  flex: 1;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}

.kpi-v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-l { margin-top: 2px; color: var(--ink3); font-size: 11px; font-weight: 500; }

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 13px;
  color: var(--ink2);
}

.meta b { color: var(--ink); font-weight: 600; }
.meta .mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ---------------------------------------------------------------- sections */
.sec { margin: 22px 16px 0; }

.sec-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 2px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink3);
}

.sec-h .cnt { font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink3); }

/* ---------------------------------------------------------------- signal card (a copied signal) */
.signal-card {
  margin-bottom: 10px;
  padding: 13px 14px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.gc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.gc-id { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gc-sym { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.gc-st { color: var(--ink3); font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.side {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.side-sell { color: var(--red); background: var(--red-soft); }
.side-buy { color: var(--green); background: var(--green-soft); }

.gc-rows { margin-top: 8px; }

.gc-r {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line2);
}

.gc-r:last-child { border-bottom: 0; }

.gc-k { color: var(--ink3); font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.gc-v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.gc-v.sl { color: var(--red); }
.gc-v.tp { color: var(--green); }

.gc-foot {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
  padding-top: 9px;
  border-top: 1px solid var(--line2);
}

.gc-foot .gc-time { margin-left: auto; color: var(--ink3); font-size: 12px; font-variant-numeric: tabular-nums; }

.legs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }

.leg-pill {
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg2);
  color: var(--ink2);
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
}

.leg-pill.done { background: var(--green-soft); color: var(--green); }

/* ---------------------------------------------------------------- fills */
.fill {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line2);
}

.fill:last-child { border-bottom: 0; }

.fill-ic {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.fill-ic.win { color: var(--green); background: var(--green-soft); }
.fill-ic.loss { color: var(--red); background: var(--red-soft); }

.fill-main { flex: 1; min-width: 0; }
.fill-t { font-size: 14px; font-weight: 600; }
.fill-s { color: var(--ink3); font-size: 12px; }

.fill-amt { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fill-amt.win { color: var(--green); }
.fill-amt.loss { color: var(--red); }

/* ---------------------------------------------------------------- empty / loading */
.empty {
  margin: 26px 16px;
  padding: 34px 22px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
}

.empty-ic {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--gold);
  background: var(--gold-soft);
}

.empty-ic svg { width: 26px; height: 26px; }
.empty-h { margin: 0 0 6px; font-size: 17px; font-weight: 700; }
.empty-p { margin: 0 auto; max-width: 30em; color: var(--ink2); font-size: 13.5px; }

.loading { display: grid; place-items: center; gap: 10px; padding: 46px 0; color: var(--ink3); font-size: 13px; }
.loading .spin { border-color: var(--line); border-top-color: var(--gold); }

/* ---------------------------------------------------------------- tab bar */
#tabbar {
  flex: none;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 5px 6px calc(5px + var(--safe-bottom));
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

#tabbar button {
  flex: 1;
  height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink3);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}

#tabbar button svg { width: 22px; height: 22px; }
#tabbar button.on { color: var(--gold); background: var(--gold-soft); }

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  transform: translate(-50%, 14px);
  max-width: min(88vw, 420px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}

#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .pill-dot { animation: none; }
  #topbar-refresh { transition: none; }
}
