:root {
  --brand: #1a5cf0;
  --brand-dark: #1249c4;
  --ink: #0b1b36;
  --muted: #5d6b82;
  --line: #e6ebf3;
  --bg: #eef3fb;
  --soft: #e8f0fe;
}

* { -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); }
body { color: var(--ink); font-family: 'Inter', system-ui, sans-serif; font-size: 14px; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 60; background: #fff;
  display: flex; flex-direction: column; padding: 22px 12px 14px;
  transform: translateX(-100%); transition: transform .25s ease; box-shadow: 0 0 40px rgba(11, 27, 54, .2);
}
.sidebar.is-open { transform: none; }
.overlay { position: fixed; inset: 0; background: rgba(11, 27, 54, .45); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }
.overlay.is-open { opacity: 1; pointer-events: auto; }
@media (min-width: 1024px) {
  .sidebar { transform: none; box-shadow: none; }
  .overlay { display: none; }
  .main { margin-left: 272px; }
}
.main { padding: 14px 14px 32px; min-height: 100vh; }
@media (min-width: 640px) { .main { padding: 16px 24px 40px; } }

.nav-link { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 10px; font-size: 15px; font-weight: 500; color: var(--ink); transition: background .15s, color .15s; }
.nav-link svg { width: 22px; height: 22px; flex-shrink: 0; }
.nav-link:hover { background: #f3f6fc; }
.nav-link.is-active { background: var(--soft); color: var(--brand); }

.topbar { background: #fff; border-radius: 14px; height: 54px; padding: 0 12px 0 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 1px 2px rgba(16, 40, 90, .05); }
.crumb { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb b { color: var(--brand); font-weight: 500; }
.avatar { width: 36px; height: 36px; border-radius: 9999px; background: #eaeff8; color: var(--ink); font-weight: 700; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; }
.avatar-lg { width: 96px; height: 96px; font-size: 32px; background: #eaeff8; }

/* ---------- Generic ---------- */
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
@media (min-width: 640px) { .page-title { font-size: 32px; } }
.page-sub { color: var(--muted); font-size: 15px; margin-top: 4px; }
.card { background: #fff; border-radius: 16px; padding: 22px; box-shadow: 0 1px 2px rgba(16, 40, 90, .05); }
.card-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.card-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: 10px; font-weight: 600; font-size: 14px; transition: background .15s, box-shadow .15s, color .15s; white-space: nowrap; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-soft { background: var(--soft); color: var(--brand); }
.btn-soft:hover { background: #dbe7fd; }
.btn-outline { background: #fff; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-outline:hover { background: var(--soft); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; border-radius: 9999px; display: grid; place-items: center; color: var(--ink); transition: background .15s; }
.icon-btn:hover { background: #f1f4fa; }
.icon-btn svg { width: 20px; height: 20px; }
.round-add { width: 34px; height: 34px; border-radius: 9999px; background: var(--brand); color: #fff; display: grid; place-items: center; }
.round-add svg { width: 18px; height: 18px; }

.pill-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { height: 38px; padding: 0 20px; border-radius: 9999px; background: #e9eef8; color: var(--ink); font-size: 13.5px; font-weight: 500; transition: background .15s, color .15s; }
.pill:hover { background: #dfe7f6; }
.pill.is-active { background: var(--brand); color: #fff; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 8px; font-size: 12.5px; font-weight: 500; }
.badge svg { width: 14px; height: 14px; }
.badge-ok { background: #e3f6ea; color: #14803c; }
.badge-warn { background: #fdf0d9; color: #b45f06; }
.badge-off { background: #e8ecf3; color: #475569; }
.dot { width: 9px; height: 9px; border-radius: 9999px; background: #22c55e; display: inline-block; }

.field-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--ink); }
.field { width: 100%; height: 46px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 14px; font-size: 14px; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.field::placeholder { color: #94a3b8; }
.field:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(26, 92, 240, .14); }
.field.invalid { border-color: #dc2626; }
select.field { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b1b36' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 38px; }
textarea.field { height: auto; padding: 12px 14px; }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #64748b; pointer-events: none; }
.search .field { padding-left: 42px; }

.switch { position: relative; width: 46px; height: 26px; border-radius: 9999px; background: #cbd5e1; transition: background .2s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 9999px; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch[aria-checked="true"] { background: var(--brand); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.tbl { width: 100%; min-width: 560px; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.row { cursor: pointer; transition: background .12s; }
.tbl tbody tr.row:hover, .tbl tbody tr.row.is-selected { background: #eef4ff; }
.tbl .sub { color: var(--muted); font-size: 12px; }
.amt-out { font-weight: 500; }
.amt-in { color: #16a34a; font-weight: 500; }

/* merchant avatars */
.av { width: 38px; height: 38px; border-radius: 9999px; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; background: #e9eef7; color: var(--ink); overflow: hidden; }
.av svg { width: 20px; height: 20px; }
.av-black { background: #0b0b0b; color: #fff; }
.av-green { background: #1ed760; color: #0b0b0b; }
.av-blue { background: var(--brand); color: #fff; }

/* ---------- Bank cards ---------- */
.bcard { position: relative; display: block; width: 100%; aspect-ratio: 760 / 427; border-radius: 6.2% / 11%; overflow: hidden; background: #0b1428; color: #fff; font-size: 16px; }
.bcard > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bcard .t { position: absolute; font-weight: 600; line-height: 1; white-space: nowrap; }
.bcard .t-type { top: 11%; right: 6%; font-size: .75em; letter-spacing: .06em; }
.bcard .t-num { left: 6%; bottom: 36%; font-size: 1.25em; letter-spacing: .08em; }
.bcard .t-name { left: 6%; bottom: 13%; font-size: .78em; letter-spacing: .08em; }
.bcard .chip { position: absolute; left: 6%; top: 33%; width: 11%; height: 14%; border-radius: 12%; background: linear-gradient(135deg, #f7d98b, #c9962b); }
.bcard.is-frozen > img { filter: grayscale(.9) brightness(.7); }
.bcard.is-frozen::after { content: "GELÉE"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; letter-spacing: .3em; font-size: 1.1em; background: rgba(11, 27, 54, .35); }
.bcard.sz-lg { font-size: 18px; }
.bcard.sz-md { font-size: 14px; }
.bcard.sz-sm { font-size: 9px; }
.bcard.sz-sm .t-type { font-size: .78em; }
.bcard.sz-sm .t-num { font-size: 1.3em; }
.bcard.sz-sm .t-name { font-size: .8em; }
.bcard.sz-xs { font-size: 0; }
.bcard.sz-xs .t, .bcard.sz-xs .chip { display: none; }

.card-item { display: flex; align-items: center; gap: 14px; padding: 8px; border-radius: 12px; border: 1.5px solid transparent; cursor: pointer; text-align: left; width: 100%; transition: border-color .15s, background .15s; }
.card-item:hover { background: #f5f8fe; }
.card-item.is-selected { border-color: #8fb1f7; background: #f3f7ff; }

/* ---------- Modal & toast ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(11, 27, 54, .5); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 440px; padding: 24px; box-shadow: 0 24px 60px rgba(11, 27, 54, .35); max-height: 90vh; overflow: auto; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px; z-index: 120; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Misc ---------- */
.faq-item { border-bottom: 1px solid var(--line); }
.faq-item:last-child { border-bottom: 0; }
.faq-q { width: 100%; display: flex; align-items: center; gap: 14px; padding: 13px 4px; text-align: left; font-size: 14px; font-weight: 500; }
.faq-q svg { width: 16px; height: 16px; transition: transform .2s; flex-shrink: 0; }
.faq-item.is-open .faq-q svg { transform: rotate(90deg); }
.faq-a { padding: 0 4px 14px 34px; color: var(--muted); font-size: 13.5px; line-height: 1.55; }

.info-box { display: flex; gap: 10px; align-items: flex-start; background: var(--soft); color: #1e3a8a; border-radius: 10px; padding: 12px 14px; font-size: 12.5px; line-height: 1.45; }
.info-box svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--brand); margin-top: 1px; }
.kv-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: 0; }
.kv-row .ico { width: 22px; height: 22px; color: var(--ink); flex-shrink: 0; }
.chev { width: 18px; height: 18px; color: #475569; flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.seg { gap: 0; background: #e9eef8; border-radius: 9999px; padding: 2px; }
.seg .pill { background: transparent; }
.seg .pill.is-active { background: var(--brand); }
.set-tab { display: flex; align-items: center; justify-content: center; gap: 10px; height: 48px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--ink); transition: background .15s, color .15s; }
.set-tab svg { width: 20px; height: 20px; }
.set-tab:hover { background: #f3f6fc; }
.set-tab.is-active { background: var(--soft); color: var(--brand); }

/* Let grid columns shrink so wide tables scroll inside their card instead of the page */
:where(.main .grid) { grid-template-columns: minmax(0, 1fr); }
:where(.main .grid > *) { min-width: 0; }
.main { overflow-x: clip; }

/* Standard desktop scale: the layouts are drawn large, shrink them on desktop screens */
:root { --z: 1; }
@media (min-width: 1024px) {
  :root { --z: .85; }
  body { zoom: var(--z); }
  .main { min-height: calc(100vh / var(--z)); }
}

/* =====================  MOBILE (app-like)  ===================== */
.tabbar, .sheet { display: none; }
#navBtn { display: none !important; }

@media (max-width: 1023px) {
  html, body { background: var(--bg); }
  body { font-size: 13.5px; }
  .sidebar { display: none; }

  /* header */
  .main { padding: 0 12px calc(84px + env(safe-area-inset-bottom)); }
  .topbar { position: sticky; top: 0; z-index: 40; margin: 0 -12px; border-radius: 0; height: 54px; padding: 0 12px; gap: 10px; box-shadow: 0 1px 0 var(--line); }
  .crumb-root { display: none; }
  .crumb { font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
  .crumb b { color: var(--ink); font-weight: 700; }
  .icon-btn { width: 38px; height: 38px; }
  .avatar { width: 34px; height: 34px; font-size: 12px; }
  main { margin-top: 16px !important; }

  /* typography & cards */
  .page-title { font-size: 24px; }
  .page-sub { font-size: 13px; margin-top: 2px; }
  .card { padding: 16px; border-radius: 16px; }
  .card.\!p-4, .card.\!p-5 { padding: 14px !important; }
  h2.card-title { font-size: 16px !important; }
  #createCard, #focusForm, #exportBtn { width: 100%; height: 44px !important; }
  .card-sub { font-size: 12.5px; }
  .btn { height: 42px; padding: 0 16px; font-size: 14px; border-radius: 12px; }
  .btn-sm { height: 34px; font-size: 12.5px; }
  .pill { height: 34px; padding: 0 16px; font-size: 13px; }
  .field { height: 44px; font-size: 16px; border-radius: 12px; } /* 16px avoids iOS zoom */
  .field-label { font-size: 12.5px; }
  .badge { height: 24px; font-size: 12px; }
  .kv-row { padding: 10px 0; }

  /* home balance */
  #balance { font-size: 34px !important; }

  /* tables -> app lists */
  .tbl.m-list { min-width: 0 !important; }
  .m-list thead { display: none; }
  .m-list tbody { display: block; }
  .m-list tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; row-gap: 2px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
  .m-list tr:last-child { border-bottom: 0; }
  .m-list td { display: block; padding: 0; border: 0; }
  .m-list .av { width: 40px; height: 40px; }
  .m-list tr.row.is-selected { background: #eef4ff; border-radius: 10px; padding-inline: 8px; }
  .m-list td:first-child { grid-column: 1; grid-row: 1 / span 2; }
  .m-list td:first-child .font-medium { font-size: 14.5px; }
  /* tx5: transaction | date | amount | status | chevron */
  .tx5 td:nth-child(2) { grid-column: 2; grid-row: 2; text-align: right; font-size: 12px; }
  .tx5 td:nth-child(3) { grid-column: 2; grid-row: 1; text-align: right; font-weight: 600; font-size: 14.5px; }
  .tx5 td:nth-child(4), .tx5 td:nth-child(5) { display: none; }
  /* tx6: transaction | via | date | amount | status | chevron */
  .tx6 td:nth-child(2), .tx6 td:nth-child(5), .tx6 td:nth-child(6) { display: none; }
  .tx6 td:nth-child(3) { grid-column: 2; grid-row: 2; text-align: right; font-size: 12px; }
  .tx6 td:nth-child(4) { grid-column: 2; grid-row: 1; text-align: right; font-weight: 600; font-size: 14.5px; }
  /* ben: name | ident | last | actions */
  .ben td:nth-child(2), .ben td:nth-child(3) { display: none; }
  .ben td:nth-child(4) { grid-column: 2; grid-row: 1 / span 2; }
  .ben td:nth-child(4) .btn { height: 32px; padding: 0 10px; font-size: 12px; }
  .ben td:nth-child(4) > div { gap: 4px; }

  /* bottom tab bar */
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: grid; grid-template-columns: repeat(5, 1fr); background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px rgba(16, 40, 90, .06); }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 0; font-size: 10.5px; font-weight: 500; color: #64748b; min-width: 0; }
  .tab span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-ico { width: 52px; height: 30px; border-radius: 9999px; display: grid; place-items: center; transition: background .2s, color .2s; }
  .tab.is-active { color: var(--brand); font-weight: 600; }
  .tab.is-active .tab-ico { background: var(--soft); }

  /* "Plus" sheet */
  .sheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; background: #fff; border-radius: 20px 20px 0 0; padding: 18px 14px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(11, 27, 54, .25); animation: sheet-up .22s ease; }
  .sheet[hidden] { display: none; }
  .sheet-link { display: flex; align-items: center; gap: 14px; padding: 14px 10px; border-radius: 12px; font-size: 15px; font-weight: 500; }
  .sheet-link:active { background: #f1f4fa; }
  .sheet-link svg { width: 22px; height: 22px; }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

  /* modals become bottom sheets, toast sits above the tab bar */
  .modal-wrap { place-items: center; padding: 16px; }
  .modal { max-width: 420px; border-radius: 18px; padding: 20px 16px; }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); font-size: 13px; padding: 10px 16px; }

  /* cards */
  .card-item { padding: 6px; gap: 10px; }
  .set-tab { height: 42px; font-size: 13px; gap: 6px; }
  .set-tab svg { width: 18px; height: 18px; }
  .info-box { font-size: 12px; }
}

@media (max-width: 1023px) {
  .m-stats { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px !important; }
  .m-stats .card { flex-direction: column; align-items: flex-start !important; gap: 8px !important; padding: 12px !important; }
  .m-stats .card > span { width: 32px !important; height: 32px !important; border-radius: 10px !important; }
  .m-stats .card > span svg { width: 18px !important; height: 18px !important; }
  .m-stats .card p:first-child { font-size: 11px; line-height: 1.2; }
  .m-stats .card p:last-child { font-size: 15px !important; }
  .m-filters { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px !important; }
  .m-filters > :first-child { grid-column: 1 / -1; }
  .m-filters .field { padding-left: 10px; padding-right: 26px; font-size: 14px; background-position: right 8px center; }
  .m-filters .relative .field { padding-left: 30px; }
  .m-filters .relative > span { left: 8px; }
}

@media (max-width: 1023px) {
  .m-filters { grid-template-columns: 1.55fr 1fr 1fr !important; }
  .m-filters .search .field { padding-left: 42px; padding-right: 12px; font-size: 16px; }
  .m-filters .relative .field { padding-left: 32px; font-size: 13.5px; }
  .m-filters .relative > span svg { width: 16px !important; height: 16px !important; }
}
@media (max-width: 1023px) { .m-filters { grid-template-columns: 1.9fr 1fr 1fr !important; } .m-filters .relative .field { font-size: 13px; padding-right: 22px; } }
@media (max-width: 1023px) { .ben td:nth-child(4) .btn { font-size: 0; width: 36px; height: 36px; padding: 0; gap: 0; border-radius: 9999px; } .ben td:nth-child(4) .btn svg { width: 17px; height: 17px; } }

/* Home on mobile: no greeting; order = balance, cards, transactions, quick payments */
@media (max-width: 1023px) {
  .home-head { display: none !important; }
  .home-grid { margin-top: 0 !important; }
  .home-col { display: contents !important; }
  .h-balance { order: 1; }
  .h-cards { order: 2; }
  .h-tx { order: 3; }
  .h-quick { display: none; }
}

/* Dialogs: centered on every screen size */
.modal { display: flex; flex-direction: column; }
.modal form { display: flex; flex-direction: column; flex: 1; }
.modal form > div:last-child { margin-top: auto; }
.badge-bad{background:#fdeaea;color:#dc2626}
.kv-grid dd{text-align:right}

/* intl-tel-input */
.iti { width: 100%; display: block; }
.iti__country-list { font-size: 14px; z-index: 130; }
.iti--container { z-index: 140; }
.iti input.field { padding-left: 96px; }
