/* Red Hat, self-hosted (OFL, see fonts/OFL.txt) so it works behind Cloudflare
   Access and on a weak connection; falls back to the system font. */
@font-face { font-family: "Red Hat Display"; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url(/fonts/RedHatDisplay-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Red Hat Display"; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url(/fonts/RedHatDisplay-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Red Hat Text"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(/fonts/RedHatText-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Red Hat Text"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(/fonts/RedHatText-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* Color carries meaning only: --usd / --try for currencies, --green / --red for
   gain / loss. Interactive chrome (--accent) is ink, i.e. the text color.
   Light is the base; dark follows the phone, or the choice in settings (html[data-theme]). */
:root {
  color-scheme: light dark;
  --font-display: "Red Hat Display", -apple-system, system-ui, "Segoe UI", sans-serif;
  --font-text: "Red Hat Text", -apple-system, system-ui, "Segoe UI", sans-serif;
  --bg: #F5F6F4;
  --fg: #17181A;
  --muted: #676A6E;
  --card: #FFFFFF;
  --border: #DCDDD8;
  --green: #1A7A4E;
  --red: #B23A31;
  --yellow: #946800;
  --accent: #17181A;
  --accent-dim: #ECEDEA;
  --on-accent: #F5F6F4;
  --usd: #2F6FB3;
  --usd-cash: #93B6DD;
  --try: #94600F;
  --metal: #A08A3E;
  --hover: rgba(23, 24, 26, 0.045);
  --shadow: rgba(23, 24, 26, 0.14);
}
/* Dark tokens apply when the phone is dark (unless the user picked "Açık" in
   settings) or when the user picked "Koyu". Keep both blocks identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141413;
    --fg: #ECEAE4;
    --muted: #9A968D;
    --card: #1C1C1A;
    --border: #2C2B28;
    --green: #57C18F;
    --red: #E4705F;
    --yellow: #E6B84A;
    --accent: #ECEAE4;
    --accent-dim: #262624;
    --on-accent: #141413;
    --usd: #7AA8DE;
    --usd-cash: #3E5F86;
    --try: #E8A94A;
    --metal: #CDB46A;
    --hover: rgba(255, 255, 255, 0.04);
    --shadow: rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141413;
  --fg: #ECEAE4;
  --muted: #9A968D;
  --card: #1C1C1A;
  --border: #2C2B28;
  --green: #57C18F;
  --red: #E4705F;
  --yellow: #E6B84A;
  --accent: #ECEAE4;
  --accent-dim: #262624;
  --on-accent: #141413;
  --usd: #7AA8DE;
  --usd-cash: #3E5F86;
  --try: #E8A94A;
  --metal: #CDB46A;
  --hover: rgba(255, 255, 255, 0.04);
  --shadow: rgba(0, 0, 0, 0.5);
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html { overscroll-behavior-y: contain; }
body {
  margin: 0; padding: 0;
  font: 15px/1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
  background: var(--bg); color: var(--fg);
  /* Full-height flex column; tabbar is pulled out of flow via fixed pos */
  height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
  padding-bottom: 95px; /* clearance for fixed tabbar ~85px */
}
/* iOS PWA cold-start: 100dvh can report height minus safe area.
   100vh includes the full screen height. */
@media (display-mode: standalone) {
  body { height: 100vh; }
}
/* Scrollable content region — owns the page padding and centers its column */
#app-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  background: var(--bg);
  width: 100%; max-width: 1100px; margin-inline: auto;
  padding: 24px;
  padding-top: max(24px, calc(env(safe-area-inset-top) + 12px));
  padding-bottom: 24px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}
header {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title buttons"
    "status status";
  align-items: center;
  gap: 6px 12px;
  margin-bottom: 16px;
}
header h1 { grid-area: title; }
.header-buttons { grid-area: buttons; display: flex; gap: 4px; }
.status { grid-area: status; display: flex; align-items: center; gap: 4px 12px; font-size: 13px; flex-wrap: wrap; }
.meta-chip { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meta-chip .dot { margin-right: 0; }   /* spacing handled by flex gap */
.meta-chip.bad { color: var(--red); }
.meta-sep { color: var(--border); }
#sources { display: inline-flex; gap: 24px; }   /* clear space between hisse / metal */
#as-of { display: inline-flex; align-items: center; gap: 8px; }   /* time · rate spacing */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
#market-status .mkt { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; }
#market-status .mkt .dot { margin: 0; }
#market-status .mkt.open .dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
#market-status .mkt.ext .dot { background: var(--yellow); }
#market-status .mkt.closed .dot { background: var(--muted); }
#market-status .mkt.soon { border-color: var(--yellow); color: var(--yellow); margin-left: 8px; }
h1 { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
h2 { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 24px 0 8px; color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }

.indices {
  display: flex; gap: 8px; margin: 4px 0 12px;
  /* Horizontal scroll so the strip stays readable as more indices are added */
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;            /* Firefox */
  /* Let the browser treat horizontal drags here as panning (not vertical
     scroll), so the strip scrolls smoothly inside the vertical page. */
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}
.indices::-webkit-scrollbar { display: none; }   /* Safari/Chrome */
.indices:empty { display: none; }
.indices .idx { flex: 0 0 auto; min-width: 96px; background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; }
.indices .idx .lbl { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.indices .idx .px { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.indices .idx .chg { font-size: 13px; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .indices .idx { padding: 7px 8px; min-width: 88px; } .indices .idx .px { font-size: 14px; } }

.perf-strip { display: flex; gap: 6px; margin: 4px 0 4px; }
.perf-strip:empty { display: none; }
.perf-strip .ps {
  flex: 1 1 0; min-width: 0; background: var(--card); border: 1px solid var(--border);
  border-radius: 9px; padding: 7px 6px; text-align: center;
}
.perf-strip .ps .lbl { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.perf-strip .ps .val { display: block; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.perf-strip .ps.total { border-color: var(--accent); }
.perf-strip-note { font-size: 12px; margin: 4px 0 16px; }
.perf-strip-note[hidden] { display: none; }
@media (max-width: 600px) {
  .perf-strip { gap: 4px; }
  .perf-strip .ps { padding: 6px 3px; }
  .perf-strip .ps .lbl { font-size: 12px; }
  .perf-strip .ps .val { font-size: 14px; }
}


/* Bottom tab bar — standard iOS approach: fixed overlay with safe-area
   padding so the content sits above the home indicator, same as every
   native app. */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: flex; gap: 2px;
  background: var(--bg); border-top: 1px solid var(--border);
  padding: 6px 8px;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar > button {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 11px;
  padding: 4px 0;
  border-radius: 8px;
}
.tabbar > button .ic { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
.tabbar > button .ic svg { display: block; }
.tabbar > button.active { color: var(--fg); font-weight: 600; }
.tabbar > button:active { background: var(--accent-dim); }
/* Center + opens the "Ekle" sheet. */
.tabbar .tab-add {
  flex: 0 0 auto; align-self: center; width: 48px; height: 48px; margin: 0 6px;
  border-radius: 16px; background: var(--accent); color: var(--on-accent);
}
.tabbar .tab-add:active { background: var(--accent); filter: brightness(0.9); }

/* Bottom sheet on phones, centered panel on wide screens. */
.modal.sheet-modal { width: 100%; min-width: 0; max-width: 480px; max-height: 90vh; margin: auto auto 0; border-radius: 22px 22px 0 0; border-bottom: 0; }
.sheet-modal[open] { animation: sheetIn 0.22s cubic-bezier(0.2, 0.9, 0.2, 1); }
@keyframes sheetIn { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .modal.sheet-modal { margin: auto; border-radius: 18px; border-bottom: 1px solid var(--border); } }
.sheet-body { display: flex; flex-direction: column; padding: 10px 16px max(20px, env(safe-area-inset-bottom)); }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--border); align-self: center; margin-bottom: 10px; }
.sheet-body h3 { margin: 0 0 6px; }
.sheet-act {
  display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: center; min-height: 56px;
  background: none; border: 0; border-bottom: 1px solid var(--border); padding: 6px 4px;
  color: var(--fg); font: inherit; text-align: left; cursor: pointer;
}
.sheet-act:hover { background: var(--hover); }
.sheet-act b { display: block; font-weight: 600; }
.sheet-act small { color: var(--muted); font-size: 13px; }
.sheet-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-dim); display: grid; place-items: center; }
.sheet-ic svg { width: 18px; height: 18px; }
.sheet-body .sheet-sync { margin-top: 14px; min-height: 48px; border-radius: 14px; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px; }
@media (min-width: 640px) {
  .tabbar { justify-content: center; }
  .tabbar > button { flex: 0 0 120px; }
}
.btn {
  background: transparent; color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px; cursor: pointer; font: inherit;
  font-size: 14px;
}
.btn:hover:not(:disabled) { border-color: var(--fg); background: var(--hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.12); }
.btn.danger { color: var(--red); border-color: transparent; padding: 2px 6px; font-size: 16px; }
.btn.danger:hover { background: rgba(248,113,113,0.1); border-color: var(--red); }
/* Header icon buttons (eye, settings): 40px targets, line icons. */
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; padding: 0;
  background: transparent; color: var(--fg); border: 1px solid transparent; border-radius: 10px; cursor: pointer;
}
.icon-btn:hover { background: var(--hover); border-color: var(--border); }
/* The update time doubles as the refresh control. */
.status-refresh {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 4px;
  background: none; border: 0; border-radius: 8px; color: var(--muted); font: inherit; cursor: pointer; font-variant-numeric: tabular-nums;
}
.status-refresh:hover { color: var(--fg); background: var(--hover); }
.settings-note { font-size: 13px; margin: -6px 0 10px; }
/* One visible keyboard focus ring everywhere (inputs keep their accent border). */
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
#refresh.spin svg { animation: spin 0.6s linear infinite; }
body.private .sensitive { color: var(--muted); letter-spacing: 0.1em; user-select: none; }

/* Pull-to-refresh */
#ptr {
  position: fixed; top: -8px; left: 50%; margin-left: -18px;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted); font-size: 18px;
  opacity: 0; z-index: 500; pointer-events: none;
}
#ptr.ready { border-color: var(--accent); color: var(--accent); }
#ptr.loading .ptr-icon { animation: spin 0.6s linear infinite; display: inline-block; }

/* Toast notifications */
#toast {
  position: fixed; top: max(16px, env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  background: var(--card); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 16px; font-size: 13px;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 2000; max-width: 90vw;
}
#toast[hidden] { display: none; }
#toast.success { border-color: var(--green); }
#toast.error { border-color: var(--red); }

/* New-version notice: a card above the phone tab bar (bottom-right on wide
   screens), one gentle entrance, "Sonra" to dismiss. */
#update-banner {
  position: fixed; z-index: 2000;
  left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
  bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: 440px; margin-inline: auto;
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px;
  background: var(--card); color: var(--fg);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 10px 30px var(--shadow);
  animation: bannerIn 0.25s cubic-bezier(0.2, 0.9, 0.2, 1);
}
#update-banner[hidden] { display: none; }
.ub-icon { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--accent-dim); }
.ub-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ub-text b { font-size: 15px; font-weight: 600; }
.ub-text small { color: var(--muted); font-size: 13px; }
#update-banner .btn { flex: none; min-height: 36px; }
@keyframes bannerIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@media (max-width: 380px) { .ub-icon { display: none; } }
@media (min-width: 1024px) { #update-banner { left: auto; right: 24px; bottom: 24px; margin: 0; } }

/* Live price dot — green/red/gray circle next to the price, pulses on update */
.price-cell { display: inline-flex; align-items: center; gap: 5px; }
.pdot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--border); transition: background 0.3s;
}
.pdot.up { background: var(--green); }
.pdot.dn { background: var(--red); }
@keyframes kPdotPulse {
  0%   { transform: scale(1);   opacity: 1; }
  40%  { transform: scale(2.2); opacity: 0.9; }
  100% { transform: scale(1);   opacity: 1; }
}
.pdot.pulse { animation: kPdotPulse 0.5s ease-out; }

/* Lock screen overlay */
#lock-screen {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
#lock-screen[hidden] { display: none; }
/* Not a card: the lock screen is the whole page, so the content sits on the ground. */
.lock-card { width: 100%; max-width: 320px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.lock-icon {
  width: 56px; height: 56px; border-radius: 16px; margin-bottom: 20px;
  display: grid; place-items: center; background: var(--accent-dim); color: var(--fg);
}
.lock-card h2 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--fg); }
.lock-desc { margin: 8px 0 0; color: var(--muted); font-size: 15px; max-width: 30ch; text-wrap: balance; }
.lock-card .btn { width: 100%; min-height: 48px; margin-top: 28px; border-radius: 12px; font-size: 16px; }
#unlock-error { margin-top: 12px; min-height: 1.4em; color: var(--red); font-size: 14px; }
#unlock-error:empty { visibility: hidden; }
.lock-foot { margin: 20px 0 0; color: var(--muted); font-size: 13px; }

/* Setup banner */
#setup-banner {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px; font-size: 13px;
}
#setup-banner[hidden] { display: none; }
#setup-banner > span { flex: 1; min-width: 200px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Özet: net worth + money map. Two columns on wide screens. */
.summary { display: grid; grid-template-columns: 1fr; gap: 20px; margin: 4px 0 16px; }
@media (min-width: 900px) { .summary { grid-template-columns: 5fr 7fr; gap: 48px; align-items: start; } }
.hero { display: flex; flex-direction: column; gap: 4px; }
.hero-lbl { font-size: 14px; color: var(--muted); }
.hero-big { font-family: var(--font-display); font-size: 44px; font-weight: 600; line-height: 1.05; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.hero-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* The day pills sit beside the ₺ total; on phones they get a row of their own. */
.hero-pills { display: contents; }
.lbl-short { display: none; }
@media (max-width: 699px) {
  .hero-pills { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  /* Pre-market / after-hours on a line of its own: no room beside the day figures. */
  .pc-ext { display: block; }
  .ph-ext { flex-basis: 100%; }
}
.hero-try { font-family: var(--font-display); font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
@media (min-width: 900px) { .hero-big { font-size: 56px; } .hero-try { font-size: 24px; } }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 12px; background: var(--accent-dim); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-map { display: flex; flex-direction: column; gap: 8px; }
.map-bar { display: flex; gap: 3px; height: 14px; }
.map-bar span { min-width: 4px; }
.map-bar span:first-child { border-radius: 7px 0 0 7px; }
.map-bar span:last-child { border-radius: 0 7px 7px 0; }
.map-bar span:only-child { border-radius: 7px; }
.map-row { display: grid; grid-template-columns: 10px 1fr auto 56px; gap: 10px; align-items: center; min-height: 46px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.map-row:last-child { border-bottom: 0; }
.map-sw { width: 10px; height: 10px; border-radius: 3px; }
.map-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.map-name small { color: var(--muted); font-size: 13px; }
.map-amt { font-weight: 600; text-align: right; }
.map-pct { color: var(--muted); font-size: 14px; text-align: right; }

.alloc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: center; }
@media (max-width: 600px) { .alloc-row { grid-template-columns: 1fr; } }

.collapse { margin: 8px 0; }
.collapse > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; font-weight: 600; color: var(--fg);
}
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; }
.collapse[open] > summary::before { transform: rotate(90deg); }
.collapse > summary:hover { border-color: var(--fg); }
.collapse[open] > summary { border-color: var(--fg); margin-bottom: 10px; }
/* Wide tables scroll inside the collapse instead of stretching the whole page
   (which made mobile zoom out when opening Pozisyonlar/Metaller). */
.collapse-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.count { color: var(--muted); font-size: 13px; font-weight: 400; }

.movers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .movers-grid { grid-template-columns: 1fr; gap: 14px; } }
.movers-grid h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.mover { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.mover:last-child { border-bottom: none; }
.mover .mv-tk { flex: 1; font-weight: 600; color: var(--fg); cursor: pointer; }
.mover .mv-px { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.mover .mv-pct { font-variant-numeric: tabular-nums; min-width: 56px; text-align: right; }
.mover .mv-watch { font-size: 12px; color: var(--muted); }
.chart-wrap { position: relative; height: 200px; margin-bottom: 12px; }
.chart-wrap.tall { height: 380px; }
.period-tabs { display: inline-flex; gap: 2px; margin-left: 8px; vertical-align: middle; }
.period-tabs button {
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: 6px 10px; min-height: 32px; cursor: pointer; font-size: 13px;
}
.period-tabs button.active { background: var(--accent-dim); color: var(--fg); border-color: var(--accent); }
.period-tabs button:hover:not(.active) { color: var(--fg); }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar { display: grid; grid-template-columns: 110px 1fr 60px; align-items: center; gap: 8px; }
.bar .track { background: var(--border); height: 8px; border-radius: 4px; overflow: hidden; }
.bar .fill { background: var(--fg); height: 100%; }
.bar .pct { text-align: right; color: var(--muted); }

/* Tables scroll horizontally on narrow screens — wrap in section automatically. */
section:has(table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; min-width: 560px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; }
td.r, th.r { text-align: right; }
td.r, th { white-space: nowrap; }
tr:hover td { background: var(--hover); }

.pos { color: var(--green); }
.neg { color: var(--red); }

.ticker-link { color: var(--fg); cursor: pointer; text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; white-space: nowrap; }
.ticker-link:hover { text-decoration: underline; }

.avatar-wrap { display: inline-flex; vertical-align: middle; margin-right: 7px; }
.avatar { width: var(--sz, 22px); height: var(--sz, 22px); border-radius: 5px; object-fit: contain; background: #fff; flex: none; }
.avatar-fallback { display: inline-flex; align-items: center; justify-content: center; background: var(--accent-dim); color: var(--fg); font-size: calc(var(--sz, 22px) * 0.5); font-weight: 700; }
.avatar-metal { display: inline-flex; align-items: center; justify-content: center; width: var(--sz, 22px); height: var(--sz, 22px); border-radius: 5px; font-size: calc(var(--sz, 22px) * 0.42); font-weight: 700; vertical-align: middle; margin-right: 7px; flex: none; }
.avatar-metal.gold { background: linear-gradient(135deg, #facc15, #d4a017); color: #3a2e00; }
.avatar-metal.silver { background: linear-gradient(135deg, #e5e7eb, #9ca3af); color: #1f2937; }

table.sortable th[data-sort] { cursor: pointer; user-select: none; }
table.sortable th[data-sort]:hover { color: var(--fg); }
table.sortable th[data-sort].sorted { color: var(--accent); }
table.sortable th[data-sort].sorted::after { content: " ↓"; font-size: 12px; }
table.sortable th[data-sort].sorted.asc::after { content: " ↑"; }

.filters { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input[type="search"] {
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font: inherit; font-size: 15px;
}
.filters select:focus, .filters input[type="search"]:focus { outline: none; border-color: var(--fg); }
.filters input[type="search"] { min-width: 140px; flex: 1; }

.wl-add { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.wl-add input { background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; font: inherit; }
.wl-add input:focus { outline: none; border-color: var(--fg); }
.wl-add #wl-target { width: 130px; }
.wl-add .combo input { text-transform: uppercase; }
#watchlist { min-width: 0; }   /* fewer/short columns — don't force the 560px table width */
#watchlist .wl-hit { color: var(--green); }   /* price at/under target */
.seed-toggle { margin-left: auto; font-size: 13px; display: flex; align-items: center; gap: 4px; }

.combo { position: relative; }
.combo input { width: 100%; padding-right: 28px; box-sizing: border-box; }
.combo-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: 2px 4px; font-size: 12px;
}
.combo-toggle:hover { color: var(--fg); }
.combo-list {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: 6px;
  margin: 0; padding: 4px; list-style: none;
  max-height: 260px; overflow-y: auto; z-index: 20;
  box-shadow: 0 4px 16px var(--shadow);
}
.combo-list li {
  padding: 6px 10px; border-radius: 4px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 8px;
}
.combo-list li:hover, .combo-list li.active { background: var(--accent-dim); }
.combo-list li .secondary { color: var(--muted); font-size: 13px; }
.combo-list li.empty { color: var(--muted); cursor: default; }
.combo-list li.empty:hover { background: transparent; }

.emir-wrap { margin-top: 16px; }
.emir-wrap > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--fg);
}
.emir-wrap > summary::-webkit-details-marker { display: none; }
.emir-wrap > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; }
.emir-wrap[open] > summary::before { transform: rotate(90deg); }
.emir-wrap > summary:hover { border-color: var(--fg); }
.emir-wrap[open] > summary { border-color: var(--fg); margin-bottom: 8px; }
.emir { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.emir-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.emir-grid input { background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font: inherit; font-variant-numeric: tabular-nums; }
.emir-grid input:focus { outline: none; border-color: var(--fg); }
.emir-out { margin-top: 14px; }
.emir-out .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; font-size: 14px; }
.emir-out .stats div { display: flex; justify-content: space-between; padding: 2px 0; }
.emir-out .stats .k { color: var(--muted); }
.emir-out .action { margin-top: 14px; padding: 12px 14px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.emir-out .action.buy { background: rgba(74,222,128,0.10); border: 1px solid rgba(74,222,128,0.30); }
.emir-out .action.sell { background: rgba(248,113,113,0.10); border: 1px solid rgba(248,113,113,0.30); }
.emir-out .action.eq { background: var(--hover); border: 1px solid var(--border); }
.emir-out .action .verdict { font-size: 18px; font-weight: 700; }
.emir-out .action .verdict.buy { color: var(--green); }
.emir-out .action .verdict.sell { color: var(--red); }
.emir-out .warn { margin-top: 8px; padding: 6px 10px; background: rgba(250,204,21,0.10); border: 1px solid rgba(250,204,21,0.30); border-radius: 6px; font-size: 14px; color: var(--yellow); }

.btn.icon { padding: 2px 6px; font-size: 14px; border-color: transparent; }
.btn.icon:hover { background: var(--hover); border-color: var(--border); }
.cols-btn { margin-left: 4px; vertical-align: middle; color: var(--muted); }
.cols-btn:hover { color: var(--fg); }

.ticker-modal { min-width: 420px; max-width: 94vw; }
.ticker-body { padding: 18px 22px; }
.ticker-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.ticker-head h3 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.ticker-head .btn { font-size: 13px; padding: 5px 12px; text-decoration: none; white-space: nowrap; }
.ticker-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px 12px; font-size: 15px; margin-bottom: 12px; }
.ticker-summary .k { color: var(--muted); font-size: 12px; display: block; }
.ticker-returns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ticker-returns .chip { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 9px; font-size: 13px; font-variant-numeric: tabular-nums; }
.ticker-returns .chip .lbl { color: var(--muted); margin-right: 4px; }
#td-trades { max-height: 220px; overflow-y: auto; font-size: 14px; }
#td-trades table { width: 100%; border-collapse: collapse; }
#td-trades td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
@media (max-width: 480px) { .ticker-modal { min-width: auto; width: 94vw; } }

.cols-modal { min-width: 320px; max-width: 92vw; }
.cols-body { padding: 18px 22px; }
.cols-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.cols-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 6px; background: var(--bg);
}
.cols-list li.hidden { opacity: 0.45; }
.cols-list .label { flex: 1; font-size: 15px; }
.cols-list .order-btns { display: flex; gap: 2px; }
.cols-list .order-btns button { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 6px; padding: 6px 10px; min-width: 36px; min-height: 36px; cursor: pointer; font-size: 13px; }
.cols-list .order-btns button:hover:not(:disabled) { color: var(--fg); border-color: var(--fg); }
.cols-list .order-btns button:disabled { opacity: 0.3; cursor: default; }
.cols-list input[type="checkbox"] { cursor: pointer; }

/* Mobile tuning — iPhone width is ~430px. */
@media (max-width: 600px) {
  #app-scroll {
    padding: 12px;
    padding-top: max(10px, calc(env(safe-area-inset-top) + 6px));
    padding-bottom: 16px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  h1 { font-size: 17px; }
  .status { font-size: 13px; }
  th, td { padding: 9px 8px; font-size: 14px; }
  .bar { grid-template-columns: 80px 1fr 48px; }
  .emir-grid { grid-template-columns: 1fr; }
  .modal { min-width: auto; width: 92vw; }
  .row { flex-direction: column; gap: 0; }
  .combo-list { max-height: 180px; }
  .filters input[type="search"] { min-width: 0; }
  .seed-toggle { margin-left: 0; flex-basis: 100%; }
}

.tag { display: inline-block; padding: 2px 7px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.tag.buy   { background: var(--accent-dim); color: var(--green); }
.tag.sell  { background: var(--accent-dim); color: var(--red); }
.tag.cash  { background: var(--accent-dim); color: var(--fg); }
.tag.metal { background: var(--accent-dim); color: var(--metal); }
.tag.seed  { background: var(--hover); color: var(--muted); font-weight: 400; }

/* Modals */
.modal {
  background: var(--card); color: var(--fg);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0; min-width: 380px; max-width: 90vw;
}
.modal::backdrop { background: rgba(0,0,0,0.6); }
.modal form { padding: 20px 22px; }
.modal h3 { font-family: var(--font-display); margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; flex: 1; }
.field label { font-size: 13px; color: var(--muted); }
.field input {
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font: inherit; font-variant-numeric: tabular-nums;
  /* 16px keeps iOS Safari from auto-zooming when an input gains focus */
  font-size: 16px;
}
.field input:focus { outline: none; border-color: var(--fg); }
.row { display: flex; gap: 10px; }
.seg { display: flex; gap: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.seg button {
  flex: 1; background: transparent; color: var(--muted);
  border: none; padding: 6px 10px; cursor: pointer;
  border-radius: 6px; font: inherit; font-size: 15px;
}
.seg button.active { background: var(--accent-dim); color: var(--fg); }
.seg button:hover:not(.active) { color: var(--fg); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

[data-show-when] { display: none; }
[data-show-when].on { display: flex; }

/* History table: keep cells on one line; the section scrolls horizontally on
   mobile rather than wrapping the type tags (AL + IBKR) onto two lines. */
#history th, #history td { white-space: nowrap; }
#history .tag { white-space: nowrap; }
/* Edit/delete are tiny glyphs — give them a finger-sized hit area on touch. */
@media (pointer: coarse) {
  #history .btn.icon, #history .btn.danger { min-width: 40px; min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* System audit log */
.audit-log { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.audit-row { display: grid; grid-template-columns: 88px 110px 1fr; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline; }
.audit-row:last-child { border-bottom: none; }
.audit-when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-event { font-weight: 600; }
.audit-detail { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* Data export / statement */
.data-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.statement-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.statement-controls select { margin-left: 6px; }
#statement-content h3 { margin: 0 0 2px; font-size: 18px; }
#statement-content .stmt-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
#statement-content h4 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 16px 0 6px; }
.stmt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.stmt-grid .row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 4px 0; font-variant-numeric: tabular-nums; }
.stmt-grid .row .k { color: var(--muted); }
#statement-content table { width: 100%; border-collapse: collapse; font-size: 13px; }
#statement-content table th, #statement-content table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
#statement-content table td.num { text-align: right; font-variant-numeric: tabular-nums; }

@media print {
  body * { visibility: hidden; }
  #modal-statement, #modal-statement * { visibility: visible; }
  #modal-statement { position: static; inset: 0; max-width: none; max-height: none; width: auto; overflow: visible; box-shadow: none; border: none; background: #fff; }
  #modal-statement .cols-body { max-height: none; overflow: visible; }
  #modal-statement::backdrop { display: none; }
  #statement-content table { white-space: normal; }
  .no-print { display: none !important; }
  #statement-content { color: #000; }
  #statement-content table th, #statement-content table td,
  .stmt-grid .row { border-color: #ccc; }
  #statement-content h4, #statement-content .stmt-sub, .stmt-grid .row .k { color: #444; }
}

/* ---------- Phone lists (positions, history) ---------- */
/* Under 700px the wide tables become two-line lists; column settings only apply to tables. */
.m-list { display: none; }
@media (max-width: 699px) {
  #positions, #history { display: none; }
  .m-list { display: block; }
  #history-details .cols-btn, #positions-details .cols-btn { display: none; }   /* column settings only apply to tables */
}
.m-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  min-height: 58px; border-bottom: 1px solid var(--border); cursor: pointer; font-variant-numeric: tabular-nums;
}
.m-row:last-child { border-bottom: 0; }
.m-row .avatar-wrap { margin-right: 0; }
.m-main b, .m-side b { display: block; font-weight: 600; }
.m-main small { display: block; color: var(--muted); font-size: 13px; }
.m-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.m-day { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 20px 0 8px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; color: var(--fg); }
.m-day span + span { font-size: 13px; font-weight: 400; color: var(--muted); }
.m-day:first-child { padding-top: 6px; }
.m-tx {
  display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.m-what { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.m-amt { text-align: right; font-weight: 600; font-size: 15px; white-space: nowrap; }
.m-meta { color: var(--muted); font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.m-acts { justify-self: end; display: flex; gap: 2px; }
.m-acts:empty { display: none; }
.m-acts .btn { min-width: 40px; min-height: 40px; }
.m-empty { text-align: center; padding: 20px 0; }

/* ---------- Wide screens: tabs move to the top ---------- */
@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  /* flex-shrink: 0 — otherwise a tall tab (Analiz) squeezes the bar in the body column. */
  .tabbar {
    position: static; order: -1; flex-shrink: 0; justify-content: center; align-items: stretch; gap: 4px;
    height: 56px; padding: 0 24px; border-top: 0; border-bottom: 1px solid var(--border);
  }
  .tabbar > button { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 0 16px; font-size: 14px; border-radius: 0; border-bottom: 2px solid transparent; }
  .tabbar > button.active { border-bottom-color: var(--fg); }
  .tabbar > button:active { background: var(--hover); }
  .tabbar .tab-add { order: 1; align-self: center; width: auto; height: 36px; margin-left: 16px; padding: 0 14px; border-radius: 10px; border-bottom: 0; }
  .tabbar .tab-add::after { content: "Ekle"; font-weight: 600; }
}

/* ---------- Phones: nothing should need a sideways swipe ---------- */
/* Kept at the end so it wins over the base .modal / table widths above. */
@media (max-width: 699px) {
  table { min-width: 0; }
  #metals { display: none; }
  #metals-details .cols-btn { display: none; }
  .modal, .cols-modal { min-width: 0; width: 92vw; }
  /* Index strip becomes a grid instead of a horizontal scroller. */
  .indices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; touch-action: auto; }
  .indices .idx { min-width: 0; }
  .period-tabs { flex-wrap: wrap; }
  .m-amt { white-space: normal; overflow-wrap: anywhere; }
  #statement-content table th, #statement-content table td { white-space: normal; }
  .ticker-head { flex-wrap: wrap; }
}

/* ---------- Settings: passkeys + audit log ---------- */
.pk-list { display: flex; flex-direction: column; }
.pk-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pk-row:last-child { border-bottom: 0; }
.pk-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pk-main b { font-weight: 600; overflow-wrap: anywhere; }
.pk-main small { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pk-acts { display: flex; gap: 4px; }
.pk-role { font-size: 12px; font-weight: 500; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; margin-left: 4px; white-space: nowrap; }
.pk-role.admin { color: var(--accent); border-color: var(--accent); }
.pk-role-btn { align-self: flex-start; margin-top: 4px; padding: 0; background: none; border: 0; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }

/* Read-only passkey (viewer): everything to look at, nothing to change. The
   server refuses changes anyway; this just doesn't offer them. */
body[data-role="viewer"] :is(#open-add, .wl-add, [data-wl-del], [data-del], [data-edit-id], .admin-only) { display: none !important; }
.pk-acts .btn { min-width: 40px; min-height: 40px; }
.pk-empty { padding: 12px 0; }
.pk-add { margin-top: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.pk-add p { margin: 0; font-size: 13px; max-width: 60ch; }
@media (max-width: 699px) {
  /* Time + event on the first line, detail below. */
  .audit-row { grid-template-columns: auto 1fr; gap: 2px 8px; }
  .audit-detail { grid-column: 1 / -1; overflow-wrap: anywhere; }
  .cols-body { padding: 16px; }
}

/* ---------- Tab bar slots: brand + status/buttons appear only in the desktop top strip ---------- */
.tab-brand, .tabbar-right { display: none; }
@media (min-width: 1024px) {
  #app-scroll > header { display: none; }   /* its contents moved into the top strip */
  .tabbar { justify-content: flex-start; }
  .tab-brand { display: flex; align-items: center; order: 0; margin-right: 16px; font-family: var(--font-display); font-weight: 700; font-size: 18px; }
  .tabbar > button[data-tab] { order: 1; }
  .tabbar-right { display: flex; order: 2; margin-left: auto; align-items: center; gap: 12px; }
  .tabbar-right .status { flex-wrap: nowrap; font-size: 13px; }
  .tabbar-right .header-buttons { display: flex; gap: 2px; }
  .tabbar .tab-add { order: 3; }
}

/* ---------- Readability on phones ---------- */
@media (max-width: 699px) {
  /* 16px form text: readable, and iOS doesn't zoom the page on focus. */
  input, select, textarea { font-size: 16px; }
  .collapse > summary { min-height: 44px; }
}
/* Source marker ("IBKR") as quiet text, not another badge next to the type tag. */
.src { color: var(--muted); font-size: 12px; font-weight: 500; }
.ccy-usd { color: var(--usd); }
.ccy-try { color: var(--try); }
/* Phone sort picker above the positions list. */
.m-sortbar { display: none; }
@media (max-width: 699px) {
  .m-sortbar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .m-sortbar label { color: var(--muted); font-size: 14px; }
  .m-sortbar select { flex: 1; min-width: 0; min-height: 40px; background: var(--card); color: var(--fg); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; font: inherit; font-size: 16px; }
  .m-sortbar .m-sort-dir { min-height: 40px; white-space: nowrap; }
}

/* ---------- Sections, strips and movers in the new style ---------- */
/* Collapsible sections: full-width headings with a chevron on the right,
   separated by a hairline — no pill buttons. Kept last so it overrides the
   earlier .collapse / .emir-wrap rules. */
.collapse, .emir-wrap { margin: 0; border-top: 1px solid var(--border); }
.collapse > summary, .emir-wrap > summary {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 56px; padding: 14px 0;
  background: none; border: 0; border-radius: 0; margin: 0;
  font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--fg);
}
.collapse > summary::before, .emir-wrap > summary::before { content: none; }
.collapse > summary::after, .emir-wrap > summary::after {
  content: ""; margin-left: auto; width: 9px; height: 9px; flex: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-3px) rotate(45deg); transition: transform 0.15s;
}
.collapse[open] > summary::after, .emir-wrap[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.collapse > summary:hover, .emir-wrap > summary:hover,
.collapse[open] > summary, .emir-wrap[open] > summary { border: 0; color: var(--fg); margin: 0; }
.collapse > summary .count, .collapse > summary .muted { font-family: var(--font-text); font-size: 13px; font-weight: 400; color: var(--muted); }
.collapse-body { padding-bottom: 20px; }
.emir { background: none; border: 0; border-radius: 0; padding: 0 0 20px; }

/* Return strip: one quiet row, columns split by hairlines, no boxes. */
.perf-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin: 12px 0 0; border-top: 1px solid var(--border); }
.perf-strip .ps { background: none; border: 0; border-radius: 0; padding: 12px 0 10px 12px; text-align: left; min-width: 0; }
.perf-strip .ps:first-child { padding-left: 0; }
.perf-strip .ps + .ps { border-left: 1px solid var(--border); }
.perf-strip .ps.total { border-color: var(--border); }
.perf-strip .ps.total .lbl { color: var(--fg); font-weight: 600; }
.perf-strip .ps .val { font-family: var(--font-display); font-size: 17px; }
.perf-strip-note { margin: 0 0 20px; }

/* Market indices: plain grid, no boxes. */
.indices { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 4px 16px; overflow: visible; touch-action: auto; margin: 0 0 20px; }
.indices .idx { background: none; border: 0; border-radius: 0; padding: 6px 0; min-width: 0; }
.indices .idx .px { font-size: 15px; }

/* Period choices: rounded chips; the curve's Getiri/Net varlık switch is a segmented control. */
.period-tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 0 12px 10px 0; vertical-align: middle; }
.period-tabs button {
  min-height: 32px; padding: 0 12px; border: 0; border-radius: 16px;
  background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.period-tabs button:hover:not(.active) { background: var(--hover); color: var(--fg); }
.period-tabs button.active { background: var(--fg); color: var(--bg); font-weight: 600; border: 0; }
#curve-mode { gap: 0; padding: 3px; border-radius: 10px; background: var(--accent-dim); }
#curve-mode button { border-radius: 8px; }
#curve-mode button.active { background: var(--card); color: var(--fg); }

/* Movers: same rows as the phone lists — avatar, ticker, price, change pill. */
.movers-grid { gap: 8px 32px; }
.movers-grid h4 { margin: 4px 0 2px; font-family: var(--font-text); font-size: 14px; font-weight: 600; color: var(--muted); }
.mover { display: grid; grid-template-columns: 28px 1fr auto auto; gap: 10px; align-items: center; min-height: 52px; padding: 6px 0; font-size: 15px; }
.mover .avatar-wrap { margin-right: 0; }
.mover .mv-tk { display: flex; flex-direction: column; align-items: flex-start; font-weight: 600; color: var(--fg); }
.mover .mv-px { font-size: 14px; }
.mv-empty { margin: 8px 0; font-size: 14px; }

@media (max-width: 699px) {
  .perf-strip .ps { padding-left: 8px; }
  .perf-strip .ps .val { font-size: 15px; }
  .indices { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 12px; }
}

/* Özet strips mirror each other: equal columns, centered text, hairline dividers. */
.perf-strip { margin: 16px 0 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.perf-strip .ps, .perf-strip .ps:first-child { padding: 12px 4px; text-align: center; }
.perf-strip-note { text-align: center; margin: 10px auto 20px; max-width: 60ch; }
.indices { grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 0; margin: 0; border-top: 1px solid var(--border); }
.indices .idx { padding: 12px 4px; text-align: center; }
.indices .idx + .idx { border-left: 1px solid var(--border); }
@media (max-width: 699px) {
  .perf-strip .ps, .perf-strip .ps:first-child { padding: 10px 2px; }
  /* 3 × 2 grid with lines between cells. */
  .indices { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
  .indices .idx:nth-child(3n+1) { border-left: 0; }
  .indices .idx:nth-child(n+4) { border-top: 1px solid var(--border); }
}

/* Phone positions: chips choosing the one metric under each row's value. */
.m-metric { display: none; }
.m-metric-text { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 699px) {
  .m-metric { display: flex; margin: 0 0 4px; }
}

/* ---------- Position cards (SavvyTrader-style) ---------- */
/* Big logo, ticker + weight, value + one chosen metric as colored text (no badges).
   One column on phones, two from 700px, three from 1024px with hairline dividers.
   Wide screens can switch to the configurable table ("Tablo"). */
#positions { display: none; }
.pc-list { display: grid; grid-template-columns: minmax(0, 1fr); }
.pos-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.pos-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.ph-count { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.ph-day { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.ph-day > span { font-weight: 600; }
.pos-view { margin: 0; }
.pos-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-bottom: 4px; }
.pos-controls .m-sortbar, .pos-controls .m-metric { display: flex; align-items: center; gap: 8px; margin: 0; }
.pos-controls .m-sortbar label { color: var(--muted); font-size: 14px; }
.pos-controls .m-sortbar select { min-height: 36px; background: var(--card); color: var(--fg); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; font: inherit; font-size: 15px; }
.pos-controls .m-sortbar .m-sort-dir { min-height: 36px; white-space: nowrap; }

.pc { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; font-variant-numeric: tabular-nums; }
.pos-cash { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pos-cash b { font-weight: 600; color: var(--fg); }
.pos-cash:empty { display: none; }
.pc-rank { width: 30px; flex: none; text-align: right; color: var(--muted); font-size: 13px; }
.pc .avatar-wrap { margin-right: 0; flex: none; }
.pc .avatar { border-radius: 10px; }
.pc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pc-main b { font-size: 16px; font-weight: 600; }
.pc-main b small { font-size: 13px; font-weight: 400; color: var(--muted); }
.pc-main > small { display: flex; flex-wrap: wrap; gap: 0 10px; color: var(--muted); font-size: 13px; }
.pc-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.pc-side b { font-size: 16px; font-weight: 600; }
.pc-side small { font-size: 13px; font-weight: 500; }
.pc-ext { font-size: 12px; }
.pc-price { color: var(--muted); }

@media (max-width: 699px) {
  .pos-view { display: none; }
  .pos-controls .m-metric { width: 100%; }
  .pos-controls .m-sortbar { width: 100%; }
  .pos-controls .m-sortbar select { flex: 1; min-width: 0; min-height: 40px; font-size: 16px; }
  .pc-rank { width: 24px; font-size: 12px; }
}
@media (min-width: 700px) {
  #positions-details[data-view="table"] #positions-list,
  #positions-details[data-view="table"] .pos-controls { display: none; }
  #positions-details[data-view="table"] #positions { display: table; }
  #positions-details:not([data-view="table"]) .cols-btn { display: none; }
}
@media (min-width: 700px) and (max-width: 1023px) {
  .pc-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pc:nth-child(2n+1) { padding-right: 16px; border-right: 1px solid var(--border); }
  .pc:nth-child(2n) { padding-left: 16px; }
}
@media (min-width: 1024px) {
  .pc-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pc:not(:nth-child(3n)) { padding-right: 16px; border-right: 1px solid var(--border); }
  .pc:not(:nth-child(3n+1)) { padding-left: 16px; }
}

/* ---------- No layout shift when switching choices ---------- */
/* Selected chips/tabs don't change weight (bolder text is wider and pushed
   its neighbours); the selected state is shown by background/border only. */
.period-tabs button, .period-tabs button.active,
.tabbar > button, .tabbar > button.active { font-weight: 500; }
@media (min-width: 1024px) { .tabbar > button.active { font-weight: 500; color: var(--fg); } }
/* Cards keep their size whatever metric is shown: the right side reserves a
   fixed width and no line wraps, so rows never change height. */
.pc-side { flex: none; min-width: 8.75rem; }
.pc-main b, .pc-main > small, .pc-side b, .pc-side small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pc-main > small { flex-wrap: nowrap; }
.pc { height: 72px; min-height: 0; }
/* Enough room per card so ticker, weight and quantity don't get cut:
   2 columns up to 1199px, 3 only on wide screens; slimmer value column. */
.pc-side { min-width: 7.5rem; }
@media (min-width: 1024px) and (max-width: 1199px) {
  .pc-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pc:not(:nth-child(3n)), .pc:not(:nth-child(3n+1)) { padding: 12px 0; border-right: 0; }
  .pc:nth-child(2n+1) { padding-right: 16px; border-right: 1px solid var(--border); }
  .pc:nth-child(2n) { padding-left: 16px; }
}

/* ---------- iOS double-tap ---------- */
/* A quick double tap on a control made iOS zoom/select text and nudge the
   fixed tab bar up. manipulation keeps taps and scrolling but drops
   double-tap zoom; the bar's labels can't be selected or long-press called. */
html { touch-action: manipulation; }
button, a, summary, [role="button"], .tabbar { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.tabbar, .tabbar * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* List rows: a soft background for keyboard focus instead of a bright ring. */
.pc:focus, .m-row:focus { outline: none; }
.pc:focus-visible, .m-row:focus-visible { outline: none; background: var(--hover); box-shadow: inset 3px 0 0 var(--fg); }

/* Pills are flex boxes, which drop the space between a word and a following
   element ("Bugün-$3.240"); give their parts an explicit gap. */
.pill { gap: 0.3em; }

/* ---------- Demo mode ---------- */
.lock-card .lock-demo { margin-top: 10px; background: transparent; }
.demo-bar { display: inline-flex; align-items: center; gap: 6px; margin-right: 4px; }
.demo-bar[hidden] { display: none; }
.demo-badge { height: 24px; padding: 0 9px; border-radius: 12px; display: inline-flex; align-items: center; background: var(--usd); color: var(--on-accent); font-size: 12px; font-weight: 600; }
.demo-bar .btn { min-height: 32px; padding: 0 10px; }
/* Desktop top strip: status items stay on one line each ("Güncellendi 23:04", "USD/TRY 48,5500"). */
@media (min-width: 1024px) {
  .tabbar-right .status > *, .tabbar-right .status-refresh, .tabbar-right #fx-chip { white-space: nowrap; }
}
/* Desktop top strip must fit 1280px: drop the source dots (a diagnostic) and tighten spacing. */
@media (min-width: 1024px) {
  .tabbar-right #sources { display: none; }
  .tabbar-right { gap: 10px; }
  .tabbar > button[data-tab] { padding: 0 12px; }
  .tab-brand { margin-right: 8px; }
}
/* Three card columns only when each card has room for ticker, weight and quantity. */
@media (min-width: 1024px) and (max-width: 1439px) {
  .pc-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pc:not(:nth-child(3n)), .pc:not(:nth-child(3n+1)) { padding: 12px 0; border-right: 0; }
  .pc:nth-child(2n+1) { padding-right: 16px; border-right: 1px solid var(--border); }
  .pc:nth-child(2n) { padding-left: 16px; }
}

/* ---------- Loading skeletons (replaced by the first render) ---------- */
.skel { display: block; border-radius: 6px; background: var(--accent-dim); animation: skelPulse 1.6s ease-in-out infinite; }
@keyframes skelPulse { 50% { opacity: 0.5; } }
.skel-big { width: 62%; max-width: 280px; height: 46px; margin: 4px 0; }
.skel-try { width: 42%; max-width: 170px; height: 22px; }
.skel-bar { height: 14px; border-radius: 7px; }
.skel-sw { width: 10px; height: 10px; border-radius: 3px; }
.skel-text { width: 88px; height: 14px; }
.skel-amt { width: 76px; height: 14px; justify-self: end; }
.skel-lbl { width: 30px; height: 10px; margin: 3px auto 7px; }
.skel-val { width: 54px; height: 16px; margin: 0 auto; }
.skel-logo { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.skel-sub { width: 64px; height: 11px; margin-top: 7px; }
.pc-side .skel-sub { margin-left: auto; }
.pc-skel { cursor: default; }

/* Refresh control never moves while its text changes: at the start of the
   phone status line (icon first), last before the fixed buttons on desktop. */
.status-refresh { order: -1; flex-direction: row-reverse; }
@media (min-width: 1024px) {
  .tabbar-right .status-refresh { order: 99; flex-direction: row; }
}
/* Skeleton sizes tuned against the loaded layout (measured), so the page doesn't shift. */
.skel-val { height: 20px; }
@media (min-width: 900px) { .skel-big { height: 59px; } }
/* Phone status line usually wraps to two lines once filled; reserve them up front. */
@media (max-width: 699px) { #app-scroll > header .status { min-height: 58px; align-content: flex-start; } }

/* ---------- IBKR account picker (top left, like IBKR's own) ---------- */
.title-group { grid-area: title; display: flex; align-items: center; gap: 10px; min-width: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.acct-picker { position: relative; display: inline-flex; align-items: center; min-width: 0; }
.acct-picker[hidden] { display: none; }
.acct-picker select {
  appearance: none; -webkit-appearance: none; min-height: 34px; max-width: 100%;
  padding: 0 30px 0 12px; border: 1px solid var(--border); border-radius: 17px;
  background: var(--card); color: var(--fg); font: inherit; font-size: 14px; font-weight: 600;
  text-overflow: ellipsis; cursor: pointer;
}
.acct-chev { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
/* The picker must shrink with the header instead of running under the buttons. */
header { grid-template-columns: minmax(0, 1fr) auto; }
.acct-picker, .acct-picker select { max-width: 100%; }
.acct-picker select { overflow: hidden; white-space: nowrap; }
@media (max-width: 1023px) { body.has-accounts header h1 { display: none; } }
.pc-main b .pc-multi { margin-left: 8px; font-size: 12px; }
.ticker-summary .td-acct { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px; }
.ticker-summary .td-acct .k { display: inline; font-size: 14px; }
@media (min-width: 1024px) {
  .tabbar .acct-picker { align-self: center; margin-right: 12px; flex: none; }
  .tabbar .acct-picker select { max-width: 220px; }
}
/* Merged row held in several accounts. */
.pc-multi { color: var(--usd); font-weight: 600; }
/* ---------- Stable table columns ---------- */
/* Auto layout sized columns from their content, so switching accounts (or
   filters) made columns jump. Fixed layout with percentage widths keeps them
   in place and still fits tablet widths; unset columns share the rest. */
#history, #positions, #metals { table-layout: fixed; }
#history td, #positions td, #metals td { overflow: hidden; text-overflow: ellipsis; }
#history th[data-col="executed_at"] { width: 10%; }
#history th[data-col="tag"] { width: 14%; }
#history th[data-col="subject"] { width: 10%; }
#history th[data-col="qty"] { width: 8%; }
#history th[data-col="price"] { width: 11%; }
#history th[data-col="amount"] { width: 21%; }
#history thead th:last-child { width: 8%; }
#positions th[data-col="ticker"], #metals th[data-col="name"] { width: 16%; }
/* Desktop top strip between 1024 and 1439px: with the account picker it no
   longer fits (Ekle ran off the edge). Tabs lose their icons, Ekle becomes
   the + alone and the status shows just the time. */
@media (min-width: 1024px) and (max-width: 1439px) {
  .tabbar > button[data-tab] .ic { display: none; }
  .tabbar > button[data-tab] { padding: 0 8px; }
  .tabbar .tab-add { width: 36px; padding: 0; justify-content: center; margin-left: 8px; }
  .tabbar .tab-add::after { content: none; }
  .tabbar-right .asof-word { display: none; }
  .tabbar-right { gap: 8px; }
}

/* Notifications: bell + history dialog + per-channel mute rows (public/notices.js). */
.notice-bell { position: relative; }
#notice-count { position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
.mute-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; font-size: 13px; }
.mute-row .btn { font-size: 13px; padding: 5px 10px; }
.notice-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.notice-toolbar .btn { font-size: 13px; padding: 5px 10px; }
.notice-list { max-height: 60vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; min-width: min(460px, 80vw); }
.notice-row { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notice-row:last-child { border-bottom: none; }
.notice-row.unread { background: var(--accent-dim); }
.notice-row div { display: flex; justify-content: space-between; gap: 10px; }
.notice-row time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.notice-row p { margin: 3px 0 0; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.notice-list .muted { display: block; padding: 14px; text-align: center; }
