/* ===== FIS H5 mobile client — v2 redesign (DBS-style chrome) ===== */
/* v2-only design tokens layered over /shared/theme.css (shared file untouched). */
/* Dark theme = warm "Heritree dark" (espresso-brown + cream/gold), matching the
   light version's brand family instead of the old navy. Overrides /shared/theme.css
   :root (loaded earlier). The light theme redefines all of these in its own blocks. */
:root {
  --bg: #22180d;                          /* deep espresso brown */
  --bg-header: #22180d;
  --panel: #2d2114;                       /* brown card */
  --panel-2: #3a2c1b;
  --card: #2d2114;
  --card-ink: #f2e8d5;                    /* cream text on cards */
  --card-muted: #b7996b;                  /* muted gold-tan */
  --rate-chip: #3a2c1b;                   /* dark brown chip */
  --text: #f4ecda;                        /* cream */
  --text-muted: #b39a72;                  /* muted tan */
  --accent: #e0b24a;                      /* bright Heritree gold */
  --accent-ink: #22180d;                  /* espresso text on gold */
  --border: #4a3a24;
  --divider: rgba(240, 222, 186, 0.14);
  --input-bg: #2d2114;
  --input-ink: #f4ecda;
  --shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  --danger: #e2926f;
  --pos: #79c793;

  --header-grad: linear-gradient(120deg, #a9761c 0%, #cf9a33 55%, #e0b24a 100%); /* gold gradient (same as light) */
  --header-ink: #fffdf9;                  /* cream ink on the gold header */

  --tabbar-bg: #1a1109;                   /* very dark brown bar */
  --tabbar-ink: #e6c168;                  /* gold — active label */
  --tabbar-inactive: #9c8154;             /* muted tan — inactive */
  --tabbar-active-bg: #c08a2a;            /* gold pill behind the selected tab */
  --tabbar-active-ink: #ffffff;           /* white on the gold pill */

  /* filter/segment pills — dark: gold active on a dark-brown track */
  --pill-track: #322516;
  --pill-border: #4a3a24;
  --pill-idle-ink: #b39a72;
  --pill-active-bg: #c08a2a;              /* gold pill */
  --pill-active-ink: #ffffff;             /* white text */
}
:root[data-theme="light"] {
  --header-grad: linear-gradient(120deg, #a9761c 0%, #cf9a33 55%, #e0b24a 100%);
  --header-ink: #fffdf9;                  /* cream-white ink on the Heritree gold header */
  /* light cream tab bar (matches the cards); dark theme keeps its navy bar */
  --tabbar-bg: #fffdf9;                   /* card cream-white */
  --tabbar-ink: #c08a2a;                  /* Heritree gold — active */
  --tabbar-inactive: #a98f6a;             /* muted tan — inactive */
  --tabbar-active-bg: #33240f;            /* espresso-brown pill behind the selected tab */
  --tabbar-active-ink: #e6c168;           /* bright gold on the espresso pill */
  /* filter/segment pills — light theme: solid Heritree-gold active on a soft cream-gold track */
  --pill-track: #f6ecd6;                  /* soft cream-gold segmented-control track */
  --pill-border: #e4d3ae;                 /* soft tan hairline */
  --pill-idle-ink: #8a7048;               /* muted tan-brown — inactive label */
  --pill-active-bg: #c08a2a;              /* solid Heritree gold pill */
  --pill-active-ink: #ffffff;             /* white text on gold */
}

#app { height: 100%; overflow: hidden; }

.phone {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;               /* fixed app shell: header + tabbar stay put */
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 26px;
  background: var(--bg);
}
.login .brand {
  text-align: center;
  margin-bottom: 6px;
}
.login .brand .wordmark {
  font-size: 51px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--accent);
  line-height: 1;
}
.login .brand .sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 3px;
}
.login h1 {
  text-align: center;
  color: var(--text);
  font-size: 23px;
  margin: 22px 0 24px;
  font-weight: 700;
}
.field {
  margin-bottom: 12px;
}
.field input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: var(--input-bg);
  color: var(--input-ink);
  font-size: 15px;
  outline: none;
}
.field input::placeholder { color: var(--text-muted); }
.login .forgot { text-align: right; color: var(--accent); font-size: 12px; margin: 2px 2px 16px; }
.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 28px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.btn-primary:active { transform: translateY(1px); }
.login .foot { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 13px; }
.login .foot a { font-weight: 700; }
.err { color: var(--danger); text-align: center; margin: 8px 0; font-size: 12px; min-height: 16px; }
.ok { color: var(--pos); text-align: center; margin: 8px 0; font-size: 12px; min-height: 16px; }

/* ---------- Header ---------- */
.hdr {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  color: var(--header-ink);
  background: var(--header-grad);
  border-bottom: none;
  border-radius: 0 0 20px 20px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
}
.hdr .burger {
  font-size: 18px;
  color: var(--header-ink);
  background: none; border: none; padding: 0; line-height: 1;
}
.hdr .title { font-size: 17px; font-weight: 800; color: var(--header-ink); flex: 1; }
.hdr .lang {
  border: 1.5px solid var(--header-ink);
  color: var(--header-ink);
  background: rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 9px;
}

/* ---------- View / scroll area ---------- */
.view {
  flex: 1;
  min-height: 0;                   /* allow the flex child to scroll within the fixed shell */
  overflow-y: auto;
  overflow-x: hidden;              /* no left/right scroll on any page */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;    /* keep scrolling inside the cards, not the page */
  padding: 12px 14px 14px;
}

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--panel);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
/* content lists sit inside a white card (reference-style carded rows) */
.list-card { padding: 4px 14px; }
.list-card .list-title { margin-top: 8px; }
.list-card .list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 8px; }
.list-card .list-head .list-title { margin: 0; }
.list-updated { font-size: 13px; white-space: nowrap; }
.list-card .quote:last-child,
.list-card .rec:last-child,
.list-card .row-line:last-child { border-bottom: none; }
.wcard {
  background: var(--card);
  color: var(--card-ink);
  border-radius: 12px;
  padding: 12px 14px;
}
.muted { color: var(--text-muted); }
.center { text-align: center; }

/* ---------- Global rates ---------- */
.panel .panel-title { color: var(--text); font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.rates-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.rate-chip {
  background: var(--rate-chip);
  color: var(--card-ink);
  border-radius: 8px;
  padding: 6px 4px;
  text-align: center;
}
.rate-chip .ccy { font-size: 11px; font-weight: 700; }
.rate-chip .val { font-size: 11px; margin-top: 2px; }

/* ---------- Sector chips ---------- */
.section-head {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; color: var(--text); font-weight: 700; font-size: 14px; margin: 4px 2px 8px;
  width: 100%; background: none; border: none; padding: 2px 2px; font-family: inherit;
}
.section-head .chev { color: var(--accent); font-size: 13px; line-height: 1; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--pill-border);
  color: var(--pill-idle-ink);
  background: var(--pill-track);
  border-radius: 18px;
  padding: 6px 5px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip.active { background: var(--pill-active-bg); color: var(--pill-active-ink); border-color: transparent; font-weight: 700; }

/* ---------- Bond quote list ---------- */
.list-title { color: var(--accent); font-size: 15px; font-weight: 800; margin: 4px 0 8px; }
.quote {
  border-bottom: 1px solid var(--divider);
  padding: 11px 0;
}
.quote .qrow { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; align-items: center; }
.quote .qcol-name { min-width: 0; }
.quote .qcol-m { text-align: right; min-width: 0; }
.quote .qval, .quote .qlabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* sort control (票息 / 孳息率) */
.sortbar { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin: 6px 0 8px; }
.sort-lbl { font-size: 12px; color: var(--text-muted); margin-right: 2px; }
.sort-pill {
  border: 1px solid var(--pill-border); background: var(--pill-track); color: var(--pill-idle-ink);
  border-radius: 16px; padding: 5px 12px; font-size: 12px; font-weight: 700;
}
.sort-pill.active { background: var(--pill-active-bg); color: var(--pill-active-ink); border-color: transparent; }
.quote .qname { color: var(--text); font-weight: 800; font-size: 14px; line-height: 1.2; }
.quote .qsub { color: var(--text-muted); font-size: 12px; font-weight: 800; margin-top: 2px; }
.quote .qlabel { color: var(--text-muted); font-size: 11px; }
.quote .qval { color: var(--text); font-weight: 700; font-size: 13px; margin-top: 1px; }

/* ---------- Summary (assets/interest/income) ---------- */
.hero { text-align: center; }
.hero .hero-label { color: var(--text); font-size: 15px; }
.hero .hero-value { color: var(--text); font-size: 25px; font-weight: 800; margin: 4px 0 12px; }
.hero .hero-value.net { font-size: 23px; }
.hero-2 { display: flex; gap: 10px; }
.hero-2 .wcard { flex: 1; }
.hero-2 .ccy { font-size: 13px; font-weight: 700; color: var(--card-muted); }
.hero-2 .big { font-size: 17px; font-weight: 800; }
.hero-2 .big.loan { color: var(--card-muted); }
.wcard.rate-bg { background: var(--rate-chip); }
.hero-2 .lbl { font-size: 12px; color: var(--card-muted); margin-top: 3px; }

.asset-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.asset-nav { flex: 1; padding-left: 14px; }
.asset-nav .nav-l { color: var(--text); font-size: 14px; }
.asset-nav .nav-v { color: var(--text); font-size: 19px; font-weight: 800; }
.asset-ratio { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; }
.asset-ratio .nav-l { color: var(--text); font-size: 13px; }
.donut { position: relative; width: 60px; height: 60px; flex-shrink: 0; }
.donut svg { display: block; transform: rotate(-90deg); }
.donut .pct {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-weight: 800; font-size: 12px;
}

/* segmented toggle — soft track with an inset espresso active pill */
.seg {
  display: flex; gap: 3px; border: 1px solid var(--pill-border); border-radius: 22px;
  margin: 12px 0; background: var(--pill-track); padding: 3px;
}
.seg button {
  flex: 1; padding: 7px 5px; border: none; background: transparent; border-radius: 18px;
  color: var(--pill-idle-ink); font-size: 12.5px; font-weight: 700;
}
.seg button.active { background: var(--pill-active-bg); color: var(--pill-active-ink); }

/* period selector */
.period {
  display: flex; gap: 2px; border: 1px solid var(--pill-border); border-radius: 22px;
  background: var(--pill-track); padding: 3px;
}
.period button {
  flex: 1; padding: 6px 2px; border: none; background: transparent; border-radius: 16px;
  color: var(--pill-idle-ink); font-size: 11.5px; font-weight: 600;
}
.period button.active { background: var(--pill-active-bg); color: var(--pill-active-ink); font-weight: 800; }

/* holdings / ledger rows */
.row-line {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--divider);
}
.row-line .rl-name { color: var(--text); font-weight: 800; font-size: 14px; }
.row-line .rl-sub { color: var(--text-muted); font-size: 12px; font-weight: 800; margin-top: 2px; }
.row-line .rl-mid { color: var(--text); text-align: center; font-size: 13px; }
.row-line .rl-ccy { color: var(--text); font-size: 13px; }
.row-line .rl-amt { color: var(--text); font-weight: 800; font-size: 13px; text-align: right; }
.rl-amt.neg { color: var(--danger); }
.rl-amt.pos { color: var(--pos); }
.rl-amt.loan { color: var(--card-muted); }

/* ledger record (income/interest) — fixed columns: name (flex) | currency | amount */
.rec { display: grid; grid-template-columns: 1fr 46px 104px; align-items: center; column-gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--divider); }
.rec > div:first-child { min-width: 0; }
.rec .rec-type { color: var(--text); font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec .rec-date { color: var(--text-muted); font-size: 11px; margin-top: 1px; }
.rec .rec-ccy { color: var(--text); font-size: 14px; text-align: center; }
.rec .rec-amt { color: var(--text); font-weight: 800; font-size: 15px; text-align: right; }
.rec .rec-amt.neg { color: var(--card-muted); }   /* lighter tone for negative (expense) values */

/* date range cards */
.range { display: flex; gap: 10px; margin-top: 10px; }
.range .wcard { flex: 1; }
.range .r-lbl { font-size: 15px; color: var(--card-ink); }
.range .r-val { font-size: 16px; font-weight: 800; color: var(--card-ink); margin-top: 6px; }
.range input[type="date"] {
  border: none; background: transparent; color: var(--card-ink);
  font-size: 15px; font-weight: 700; width: 100%; padding: 0; outline: none;
}

/* settings */
.settings-label { color: var(--text); font-size: 15px; margin: 6px 2px 8px; }
.card-form { background: var(--card); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); }
.card-form .settings-label { color: var(--card-ink); }
.card-form input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 15px; margin-bottom: 14px; color: var(--input-ink); background: var(--input-bg);
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
  flex-shrink: 0;
  display: flex; gap: 2px; background: var(--tabbar-bg);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(51, 36, 15, 0.08);
  border-top: 1px solid var(--divider);
  border-radius: 18px 18px 0 0;
}
.tabbar button {
  flex: 1; border: none; background: none; color: var(--tabbar-inactive);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px;
  font-size: 10px; font-weight: 700; border-radius: 14px;
}
/* selected tab: espresso-brown pill (falls back to no fill in the dark theme) */
.tabbar button.active {
  color: var(--tabbar-active-ink, var(--tabbar-ink));
  background: var(--tabbar-active-bg, transparent);
}
.tabbar svg { width: 24px; height: 24px; }

.empty { text-align: center; color: var(--text-muted); padding: 32px 0; }
.spin { text-align: center; color: var(--text-muted); padding: 24px 0; }

/* ---------- Slide-out drawer menu ---------- */
.drawer-scrim {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: absolute; top: 0; left: 0; bottom: 0; z-index: 60;
  width: 74%; max-width: 290px;
  background: var(--panel);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex; flex-direction: column;
  padding: 18px 12px calc(14px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-brand { color: var(--accent); font-size: 24px; font-weight: 800; letter-spacing: 2px; padding: 6px 12px 14px; }
.drawer-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.drawer-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border: none; background: none; border-radius: 10px;
  color: var(--text); font-size: 15px; font-weight: 700; text-align: left; width: 100%;
}
.drawer-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.drawer-item.active { background: var(--rate-chip); color: var(--accent); }
.drawer-logout {
  margin-top: 8px; padding: 12px; border: 1.5px solid var(--accent); background: transparent;
  color: var(--accent); border-radius: 10px; font-weight: 700; font-size: 14px;
}

/* ---------- Portrait lock ---------- */
/* Phone in landscape: hide the app and prompt to rotate back to portrait. */
.rotate-lock { display: none; }
.rotate-lock .rotate-ico { font-size: 40px; }
.rotate-lock .rotate-title { font-size: 17px; font-weight: 800; color: var(--accent); }
.rotate-lock .rotate-sub { font-size: 12px; color: var(--text-muted); }
@media screen and (orientation: landscape) and (max-height: 500px) {
  #app { display: none; }
  .rotate-lock {
    display: flex; position: fixed; inset: 0; z-index: 9999;
    flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    background: var(--bg); color: var(--text); text-align: center; padding: 24px;
  }
}
