/* Wealth Manager (design shared with Tresor): one stylesheet for light and dark. Tokens first, then base, components and views.
   Phones (up to 640px) get the navigation as a tab bar at the bottom, wider screens a bar at the top. */

:root {
  color-scheme: light dark;
  --bg: #f2f3f7;
  --surface: #ffffff;
  --surface-2: #f5f6f9;
  --text: #101217;
  --muted: #687082;
  --line: #e4e6ec;
  --accent: #3d5afe;
  --accent-hover: #2f4ae6;
  --accent-text: #ffffff;
  --accent-soft: #edf0ff;
  --danger: #d4342b;
  --danger-soft: #fdeeed;
  --warn-soft: #fff4d6;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 18, 23, .04), 0 2px 10px rgba(16, 18, 23, .05);
  --overlay: rgba(10, 12, 16, .42);
  --toast: #1c1f26;
  --tabbar: 0px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e12;
    --surface: #16191f;
    --surface-2: #1e222a;
    --text: #eef0f4;
    --muted: #98a1b1;
    --line: #272c35;
    --accent: #7d93ff;
    --accent-hover: #93a6ff;
    --accent-text: #0b0e1a;
    --accent-soft: rgba(125, 147, 255, .15);
    --danger: #ff6c63;
    --danger-soft: rgba(255, 108, 99, .14);
    --warn-soft: rgba(242, 193, 78, .14);
    --shadow: none;
    --overlay: rgba(0, 0, 0, .58);
    --toast: #2b303a;
  }
}

/* ------------------------------------------------ Base */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}

/*
 * iOS 26/27 lays a blurred strip (Liquid Glass scroll edge effect) over the top of an installed web app,
 * whatever the status bar: title and "Neu" turned blurry. It leaves the strip out when a fixed element with
 * its own background colour sits at the top (more than about 10 px high, nearly full width) and takes that
 * colour instead. WebKit reads the background-color of a real element, no pseudo-elements, no gradients.
 * As in Parkrevier (scout-app 369f554): the box sits on z-index 0 and the app is lifted above it
 * (#app on z-index 1), so it stays invisible. Not z-index -1: down there WebKit ignores it, the strip stayed.
 */
.edge-sampler {
  position: fixed; top: 0; left: 0; right: 0; z-index: 0;
  height: calc(env(safe-area-inset-top) + 40px);
  background-color: var(--bg);
  pointer-events: none;
}
#app { position: relative; z-index: 1; }

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin: 0; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; line-height: 1.3; margin: 0; }
h3 { font-size: .75rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 4px 0 0; }
p { margin: 0; }
a { color: var(--accent); }
strong { font-weight: 650; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace; }
.masked { -webkit-text-security: disc; text-security: disc; }
.sr, .offscreen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.fav { width: 15px; height: 15px; fill: #f5b301; stroke: #f5b301; }
.icon-btn .icon.fav { width: 22px; height: 22px; }
.icon.chev { width: 18px; height: 18px; color: var(--muted); opacity: .55; }

/* ------------------------------------------------ Buttons */

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none;
  cursor: pointer; touch-action: manipulation;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
button:hover { background: var(--surface-2); }
button:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: default; transform: none; }
button:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); }
button.primary:hover { background: var(--accent-hover); }
button.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
button.danger:hover { background: var(--danger-soft); filter: brightness(.97); }
button.small { min-height: 36px; padding: 0 14px; font-size: .9rem; border-radius: 10px; }
button.pill { min-height: 38px; padding: 0 16px; border-radius: 999px; font-size: .95rem; }
button.wide { width: 100%; }
button .icon { width: 18px; height: 18px; }

button.loading { position: relative; color: transparent !important; }
button.loading > * { visibility: hidden; }
button.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--muted); border-top-color: transparent; animation: spin .7s linear infinite;
}
button.primary.loading::after { border-color: var(--accent-text); border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; min-height: 40px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .icon { width: 20px; height: 20px; }

/* ------------------------------------------------ Form controls */

input, select, textarea { font: inherit; color: inherit; }

input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-size: 16px; /* 16px keeps iOS from zooming into the field */
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input[type=search] { -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
::placeholder { color: var(--muted); opacity: .8; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=file] { width: 100%; font-size: .9rem; color: var(--muted); }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; color: var(--text); margin-right: 12px;
  min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field .label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.input-group { display: flex; gap: 4px; align-items: center; }
.input-group input { flex: 1; min-width: 0; }
.pin { font-size: 1.8rem !important; letter-spacing: .6em; text-align: center; padding-left: .6em !important; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 2 1 180px; }
.inline-form select { flex: 1 1 140px; width: auto; }
.inline-form button { flex: 1 1 auto; white-space: nowrap; }
.inline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.inline-actions select { width: auto; min-height: 36px; padding: 4px 10px; border-radius: 10px; }

/* ------------------------------------------------ Navigation */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px max(20px, calc((100% - 960px) / 2));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.8) blur(16px);
  -webkit-backdrop-filter: saturate(1.8) blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, var(--accent), #8b5cf6);
}
.brand-mark .icon { width: 18px; height: 18px; }
.topbar nav { display: flex; gap: 4px; }
.tab {
  min-height: 40px; padding: 0 14px; gap: 7px;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600;
}
.tab .icon { width: 18px; height: 18px; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }

@media (max-width: 640px) {
  :root { --tabbar: calc(62px + env(safe-area-inset-bottom)); }
  .topbar {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-bottom: 0; border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
  }
  .brand { display: none; }
  .topbar nav { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
  .tab {
    flex-direction: column; gap: 3px; min-height: 50px; padding: 4px 0; border-radius: 12px;
    font-size: .68rem; font-weight: 600; letter-spacing: .01em;
  }
  .tab .icon { width: 24px; height: 24px; }
  .tab:hover, .tab.active { background: transparent; }
  /* While typing, the keyboard needs the room (and a fixed bar would float above it). */
  body:has(:is(input:not([type=checkbox]):not([type=range]):not([type=file]), textarea, select):focus) .topbar { display: none; }
}

/* ------------------------------------------------ Layout */

.container {
  max-width: 720px; margin: 0 auto;
  padding: 24px 16px calc(48px + var(--tabbar));
  display: flex; flex-direction: column; gap: 16px;
}
@media (max-width: 640px) { .container { padding-top: 16px; } }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; min-height: 44px; }
.toolbar h1.grow + * { flex: none; }
.toolbar > .icon-btn:first-child { margin-left: -8px; }
.page-head { display: flex; flex-direction: column; gap: 2px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.form { display: flex; flex-direction: column; gap: 16px; }
.card.form { gap: 14px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.actions.wrap { justify-content: flex-start; }
.actions.stack { flex-direction: column; align-items: stretch; }
@media (min-width: 641px) { .actions.stack { flex-direction: row; justify-content: flex-end; } }
/* Phones: buttons at the end of a card or form share the full width. */
@media (max-width: 640px) {
  .card .actions:not(.wrap) > button, .form > .actions > button { flex: 1 1 auto; }
}
.section-title { font-size: .78rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 10px 4px -6px; }

.notice { background: var(--warn-soft); padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9rem; line-height: 1.45; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--warn-soft); padding: 10px 14px; border-radius: var(--radius-sm); font-size: .9rem;
}
.group-note {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); font-size: .9rem; line-height: 1.4;
}
.group-note > .icon { color: var(--accent); }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); margin: 0; }

/* ------------------------------------------------ Login and other screens before unlocking */

.auth { max-width: 400px; margin: 0 auto; padding: max(48px, 9vh) 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.auth h1 { text-align: center; }
.auth > .muted { margin-top: -6px; }
.auth-logo {
  width: 72px; height: 72px; margin: 0 auto 4px; border-radius: 22px; color: #fff;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #8b5cf6);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--accent) 32%, transparent);
}
.auth-logo .icon { width: 34px; height: 34px; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
  font-size: .72rem; font-weight: 650; line-height: 1.5; white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; }
.badge.group { background: var(--accent-soft); color: var(--accent); border-color: transparent; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.badge.warn { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.here { background: var(--accent); color: var(--accent-text); border-color: transparent; }
/* ------------------------------------------------ Dialogs, generator, toast */

.overlay {
  position: fixed; inset: 0; z-index: 50; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade .15s ease-out;
}
.dialog {
  width: 100%; max-width: 440px; max-height: 88vh; overflow: auto;
  background: var(--surface); border-radius: 20px; padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .3);
  animation: pop .18s ease-out;
}
.dialog .actions { margin-top: 4px; }
.dialog > div:not(.actions) { display: flex; flex-direction: column; gap: 12px; }
/* Phones: confirmations slide up from the bottom like a sheet. Dialogs with a text field stay centred,
   so the keyboard doesn't cover them. */
@media (max-width: 640px) {
  .overlay:not(:has(:is(input:not([type=checkbox]):not([type=range]), textarea, select))) { align-items: flex-end; padding: 0; }
  .overlay:not(:has(:is(input:not([type=checkbox]):not([type=range]), textarea, select))) .dialog {
    max-width: none; border-radius: 22px 22px 0 0;
    padding: 24px 18px calc(18px + env(safe-area-inset-bottom));
    animation: sheet .24s cubic-bezier(.2, .8, .3, 1);
  }
  .dialog .actions > button { flex: 1 1 auto; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
@keyframes sheet { from { transform: translateY(48px); opacity: .5; } }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--toast); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: .9rem; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
@media (max-width: 640px) {
  body:has(.topbar) .toast { bottom: calc(12px + var(--tabbar)); }
}

/* ------------------------------------------------ Account, admin, logs */

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: flex; justify-content: space-between; align-items: center; gap: 4px 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.log li:last-child { border-bottom: 0; }
.log li.warn { color: var(--danger); }
.log-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.log-title { overflow-wrap: anywhere; }
.log-sub { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.log li.warn .log-sub { color: inherit; opacity: .8; }

/* ------------------------------------------------ Overview: the euro band with the dollar band directly to its right */

:root {
  --eur-band: #e4eaff;
  --eur-ink: #233a9e;
  --usd-band: #dff3e7;
  --usd-ink: #125a38;
  --up: #0f7a4a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --eur-band: #1a2448;
    --eur-ink: #b6c4ff;
    --usd-band: #13332a;
    --usd-ink: #9be3bb;
    --up: #5fd39a;
  }
}

.container.wide { max-width: 1120px; }
.status { flex: 1 1 200px; font-size: .9rem; }
.status.warn { color: var(--danger); }
.date-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-pick input { width: auto !important; min-height: 40px !important; padding: 6px 10px !important; }
.date-pick button { min-height: 40px; }

.ledger-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ledger { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ledger th, .ledger td { padding: 10px 12px; text-align: left; font-weight: 400; white-space: nowrap; vertical-align: middle; }
.ledger th:first-child, .ledger td:first-child { padding-left: 18px; }
.ledger tbody tr > * { border-top: 1px solid var(--line); }
.ledger .num { text-align: right; }
.ledger .eur { background: var(--eur-band); color: var(--eur-ink); text-align: right; }
.ledger .usd { background: var(--usd-band); color: var(--usd-ink); text-align: right; }
.ledger .value { font-weight: 650; }
.ledger .up { color: var(--up); }
.ledger .down { color: var(--danger); }

.grand th { font-size: 1.05rem; font-weight: 650; }
.grand td { padding-block: 18px; font-size: clamp(1.45rem, 2.6vw, 2.1rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.heads th { color: var(--muted); font-size: .8rem; font-weight: 600; border-top: 1px solid var(--line); }
.heads th.eur { color: var(--eur-ink); }
.heads th.usd { color: var(--usd-ink); }
.section th, .section td { font-weight: 650; }

.position { display: block; font-weight: 600; }
.position-sub { display: block; color: var(--muted); font-size: .84rem; }
.ledger td.note { color: var(--muted); white-space: normal; }

button.edit {
  min-height: 34px; padding: 0 8px; margin-right: -8px; font-weight: 400; border-color: transparent; background: transparent;
  text-decoration: underline dotted var(--muted); text-underline-offset: 3px; font-variant-numeric: tabular-nums;
}
button.edit:hover { background: var(--surface-2); }
.ledger .icon-btn { width: 36px; height: 36px; min-height: 36px; }
.ledger .icon-btn:hover { color: var(--danger); }

.add-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 16px; align-items: start; }

.combo { position: relative; }
.combo ul {
  position: absolute; inset: 100% 0 auto; z-index: 5; margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18); max-height: 290px; overflow-y: auto;
}
.combo li { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.combo li span { color: var(--muted); margin-left: 6px; font-size: .9rem; }
.combo li:hover, .combo li.active { background: var(--accent-soft); }

.credit { font-size: .8rem; }

/* Phones: every position is a small block, with euro left and dollar right, so nothing has to scroll sideways. */
@media (max-width: 640px) {
  .ledger, .ledger thead, .ledger tbody { display: block; }
  .ledger .heads { display: none; }
  .ledger tr { display: grid; grid-template-columns: 1fr 1fr; }
  .ledger th, .ledger td { display: block; padding: 8px 14px; white-space: normal; min-width: 0; }
  .ledger th:first-child, .ledger td:first-child { padding-left: 14px; }
  .ledger tbody tr > * { border-top: 0; }
  .ledger tbody tr { border-top: 1px solid var(--line); }
  .ledger .spacer { display: none; }

  .grand th, .section th { grid-column: 1 / -1; padding-bottom: 6px; }
  .grand td { padding-block: 12px; font-size: 1.3rem; }
  .section th { padding-top: 12px; }
  .ledger td.note { grid-column: 1 / -1; }

  .pos .cell-name { order: 1; padding-bottom: 0; }
  .pos .cell-change { order: 2; padding-bottom: 0; }
  .pos .cell-amount { order: 3; text-align: left; padding-block: 0 4px; }
  .pos .cell-amount button.edit { margin: 0 0 0 -8px; }
  .pos .cell-remove { order: 4; text-align: right; padding-block: 0 4px; }
  .pos .eur-price { order: 5; }
  .pos .usd-price { order: 6; }
  .pos .eur-value { order: 7; }
  .pos .usd-value { order: 8; }
  .pos td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 500; opacity: .75; }
  .pos td.empty-cell { display: none; }
  .pos.asset .cell-name { grid-column: 1; }
}
