:root {
  --brand: #0f3d3e;
  --brand-2: #14595b;
  --accent: #2ecc8f;
  --bg: #f2f4f3;
  --card: #ffffff;
  --text: #15201f;
  --muted: #5c6b69;
  --border: #dde3e1;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 14px) calc(env(safe-area-inset-right) + 20px) 14px calc(env(safe-area-inset-left) + 20px);
  background: var(--brand);
  color: #fff;
}
.bar img { border-radius: 7px; }
.bar h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: 0.2px; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + 16px);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 4%);
}
.card.center { text-align: center; padding: 36px 20px; }
.card h2 { margin: 0 0 6px; font-size: 22px; }

[hidden] { display: none !important; }

.muted { color: var(--muted); margin: 0 0 18px; }
.step { margin: 14px 0 0; font-size: 14px; min-height: 1em; }

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }

input[type="password"] {
  width: 100%;
  font: 16px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; /* ≥16px avoids iOS zoom */
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfcfc;
  color: var(--text);
}
input:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; }

.button {
  display: block;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.button:active { background: var(--brand-2); }
.button:disabled { opacity: 0.55; cursor: default; }
.button.secondary { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }


.glyph {
  width: 52px;
  height: 52px;
  margin-bottom: 10px;
  fill: none;
  stroke: var(--brand);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.error {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 15px;
}

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 12px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- header refresh */

.bar h1 { flex: 1; }
.bar-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1.5px solid rgb(255 255 255 / 55%);
  border-radius: 18px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
}
.bar-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.bar-button:disabled { opacity: 0.5; cursor: default; }
.bar-button:not(:disabled):active { background: rgb(255 255 255 / 12%); }

/* ---------------------------------------------------------------- cards */

/* minmax(0, 1fr): a grid track otherwise grows to its widest unbreakable content (a long merchant name),
   pushing the card past the screen edge. */
#cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }

.bank-card { padding: 18px 16px 10px; min-width: 0; }

.card-head { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-size: 14px; min-width: 0; }
.card-title { color: var(--text); font-weight: 600; }
.card-currency { margin-left: auto; font-weight: 600; letter-spacing: 0.4px; }

.card-balance { margin: 8px 0 12px; }
.amount-main { font-size: 30px; font-weight: 700; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; }
.amount-label { color: var(--muted); font-size: 13px; margin-top: -2px; }
.amount-sub { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.history { border-top: 1px solid var(--border); margin: 0 -16px; padding: 4px 0 0; }
.history-status { margin: 8px 16px; color: var(--muted); font-size: 14px; }
.history-status.danger, .notice.danger { color: var(--danger); }

.tx-list { list-style: none; margin: 0; padding: 0; }
.tx {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  min-width: 0;
}
.tx:active { background: #f1f5f4; }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-desc { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.tx-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-card-amount { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.positive { color: #138a5b; }
.badge { font-size: 11px; font-weight: 600; color: #8a5a00; background: #fff3d6; border-radius: 6px; padding: 1px 6px; }

.link-button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-top: 1px solid var(--border);
  background: none;
  color: var(--brand-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.notice { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); color: var(--muted); }

.bank-footer { margin-top: 18px; text-align: center; }
.bank-footer .muted { font-size: 13px; margin-bottom: 10px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- details sheet */

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 85dvh;
  margin: auto auto 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 18px);
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--card);
  color: var(--text);
  overflow-y: auto;
}
.sheet::backdrop { background: rgb(0 0 0 / 40%); }
.sheet-handle { width: 40px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: var(--border); }
.details-amount { font-size: 30px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.details-desc { text-align: center; color: var(--muted); margin: 2px 0 16px; }
.details { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0 0 20px; font-size: 15px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
