@font-face {
  font-family: "Montserrat";
  src: url("../fonts/Montserrat.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
}

:root {
  --bg: #1E2FB3;
  --sidebar: #0E1561;
  --card: rgba(255, 255, 255, 0.09);
  --field: rgba(0, 0, 0, 0.28);
  --border: rgba(255, 255, 255, 0.30);
  --line: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --text2: rgba(255, 255, 255, 0.78);
  --green: #7CE3A1;
  --yellow: #FFD23F;
  --red: #FF7A7A;
  --crisis: #9E1C28;
  --ink: #0E1561;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", "Segoe UI", system-ui, sans-serif;
  font-weight: 500;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

#app { height: 100%; }

/* ---------- layout ---------- */
.shell { display: flex; height: 100%; min-width: 1100px; }
.sidebar {
  width: 260px; flex: none; background: var(--sidebar);
  padding: 16px; overflow-y: auto;
}
.main { flex: 1; overflow-y: auto; padding: 32px; }
.stack { display: flex; flex-direction: column; gap: 22px; max-width: 1180px; }

.logo { font-size: 22px; padding: 0 12px 22px; }
.logo b { font-weight: 800; }

.nav {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 9px 12px; border: 0; border-radius: 8px;
  background: transparent; font-weight: 600; color: rgba(255,255,255,0.82);
  text-align: left; margin-bottom: 4px;
}
.nav:hover { background: rgba(255,255,255,0.08); }
.nav.active { background: rgba(255,255,255,0.16); font-weight: 700; color: #fff; }
.nav.sub { padding-left: 24px; width: calc(100% - 0px); }
.nav .chev { font-size: 11px; color: var(--text2); }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: 14px; padding: 20px;
}
.card.baller { background: var(--sidebar); }
.card.baller.crisis { background: var(--crisis); }
.card h3 { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.muted { color: var(--text2); }
.small { font-size: 12px; }

.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text2); }
.title { font-size: 38px; font-weight: 800; margin: 4px 0 0; line-height: 1.1; }
.subtitle { color: var(--text2); margin-top: 4px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.head-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- buttons & fields ---------- */
.pill {
  border: 1.5px solid rgba(255,255,255,0.55); background: transparent;
  border-radius: 999px; padding: 9px 18px; font-weight: 600; color: #fff;
}
.pill:hover { background: rgba(255,255,255,0.08); }
.pill:active { opacity: 0.65; }
.pill.filled { background: #fff; color: var(--bg); border-color: #fff; }
.pill.filled:hover { background: rgba(255,255,255,0.88); }
.pill.small { padding: 5px 12px; font-size: 12px; }
.pill:disabled { opacity: 0.4; cursor: default; }

.field, select, input[type=text], input[type=number], input[type=date] {
  background: var(--field); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font-weight: 500; outline: none; color: #fff;
}
input:focus, select:focus { border-color: rgba(255,255,255,0.7); }
input::placeholder { color: rgba(255,255,255,0.45); }
select option { background: #16217f; color: #fff; }
input[type=number]::-webkit-inner-spin-button { opacity: 0.4; }
.right { text-align: right; }

.label { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text2); display: block; margin-bottom: 6px; }

.form-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.form-row .grow { flex: 1; min-width: 200px; }
.form-row .grow input { width: 100%; }

.check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: #fff; }

/* ---------- tables ---------- */
.row {
  display: grid; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 8px;
}
.row + .row { border-top: 1px solid var(--line); }
.month-grid { grid-template-columns: minmax(150px, 1fr) 90px 90px 90px 130px 120px; }
.hist-grid { grid-template-columns: minmax(150px, 1fr) 100px 100px 140px 120px 16px; }
.log-grid { grid-template-columns: 200px minmax(120px, 1fr) 100px 80px; }
.row.head { padding-top: 8px; padding-bottom: 8px; }
.col-title { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text2); }
.num { text-align: right; }
.strong { font-weight: 600; }
.row.tint-yellow { background: rgba(255,210,63,0.18); }
.row.tint-red { background: rgba(255,122,122,0.18); }
.row.total { margin-top: 6px; font-weight: 700; font-size: 15px; background: rgba(255,255,255,0.06); border-top: 0; }
.row.total.tint-yellow { background: rgba(255,210,63,0.22); }
.row.total.tint-red { background: rgba(255,122,122,0.22); }
.row.clickable { cursor: pointer; border-radius: 8px; }
.row.clickable:hover { background: rgba(255,255,255,0.07); }

.chip {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; color: var(--ink); white-space: nowrap;
}
.chip.green { background: var(--green); }
.chip.yellow { background: var(--yellow); }
.chip.red { background: var(--red); }

.bar { position: relative; height: 14px; border-radius: 4px; background: rgba(255,255,255,0.2); }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.bar .tick { position: absolute; top: 0; width: 2px; height: 14px; background: #fff; margin-left: -1px; }
.fill.green { background: var(--green); }
.fill.yellow { background: var(--yellow); }
.fill.red { background: var(--red); }

/* ---------- baller card ---------- */
.baller-row { display: flex; align-items: center; gap: 18px; }
.baller-amount { font-size: 38px; font-weight: 800; }
.baller-row .spacer { flex: 1; }
.baller-note { text-align: right; font-size: 12px; color: var(--text2); line-height: 1.4; }

/* ---------- messages ---------- */
.msg-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 30px; }
.msg { font-weight: 600; font-size: 13px; }

/* ---------- ring ---------- */
.ring-wrap { display: flex; align-items: center; gap: 44px; margin-top: 14px; }
.ring { position: relative; width: 230px; height: 230px; flex: none; }
.ring svg { width: 230px; height: 230px; }
.ring .slice { transition: opacity 0.15s; }
.ring .center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 50px;
}
.ring .center .big { font-size: 26px; font-weight: 800; }
.ring .center .cap { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text2); margin-top: 2px; }
.legend { flex: 1; max-width: 640px; }
.legend-row {
  display: grid; grid-template-columns: 11px minmax(0, 1fr) auto 70px 48px; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
}
.legend-row.hover { background: rgba(255,255,255,0.10); }
.dot { width: 11px; height: 11px; border-radius: 50%; }
.legend-name { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.chip.small { padding: 3px 9px; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(5, 8, 40, 0.6);
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.modal {
  background: var(--bg); border-radius: 16px; padding: 24px; width: 740px; max-width: 94vw;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; gap: 16px;
}
.modal.narrow { width: 560px; }
.modal h2 { margin: 0; font-size: 28px; font-weight: 800; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.edit-row { display: flex; gap: 10px; align-items: center; }
.edit-row .grow { flex: 1; min-width: 0; }
.edit-row input[type=text].grow { width: 100%; }
.sum-line { display: flex; justify-content: space-between; }
.hr { height: 1px; background: var(--line); }

/* ---------- setup ---------- */
.setup { max-width: 760px; margin: 0 auto; padding: 40px; display: flex; flex-direction: column; gap: 20px; }
.setup .logo-lg { font-size: 40px; }
.total-banner {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,0.14); border-radius: 10px; padding: 12px 14px;
}
.total-banner .t { font-weight: 700; font-size: 15px; }
.total-banner .v { font-weight: 800; font-size: 20px; }
.error { color: var(--red); font-weight: 600; }
.seg { align-self: flex-start; display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 8px 16px; font-weight: 600; }
.seg button.on { background: rgba(255,255,255,0.22); }

.back { background: none; border: 0; padding: 0; color: var(--text2); font-weight: 600; font-size: 13px; text-align: left; }
.back:hover { color: #fff; }
.empty { padding: 18px 10px; color: var(--text2); }
.green-text { color: var(--green); }

.warn { background: rgba(255,210,63,0.18); border: 1px solid var(--yellow); border-radius: 10px; padding: 12px 14px; font-weight: 600; }

/* ---------- import review ---------- */
.modal.wide { width: 1040px; }
.imp-grid { grid-template-columns: 26px 64px minmax(160px, 1fr) 220px 84px 112px; }
.imp-list { background: var(--card); border-radius: 12px; max-height: 420px; overflow-y: auto; padding: 4px 0; }
.imp-list .row { padding: 6px 10px; }
.imp-list .row.off { opacity: 0.5; }
.imp-list input[type=text] { width: 100%; }
.imp-list select { width: 100%; }
.imp-note { font-size: 11px; color: var(--yellow); margin-top: 2px; }
.imp-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.imp-toolbar .grow { flex: 1; }
.sample { background: var(--field); border-radius: 8px; padding: 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; white-space: pre-wrap; max-height: 300px; overflow-y: auto; user-select: text; }

/* ---------- phone and small-screen layout ---------- */
.topbar, .scrim { display: none; }

@media (max-width: 820px) {
  html, body, #app { height: 100vh; height: 100dvh; }
  body { font-size: 15px; }
  input, select { font-size: 16px; }

  .shell { flex-direction: column; min-width: 0; }
  .topbar {
    display: flex; align-items: center; gap: 12px; flex: none;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--sidebar);
  }
  .menu-btn { border: 0; background: rgba(255,255,255,0.12); color: #fff; border-radius: 8px; width: 40px; height: 36px; font-size: 20px; }
  .logo-sm { font-size: 18px; }
  .logo-sm b { font-weight: 800; }

  .sidebar {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: 280px; max-width: 84vw;
    transform: translateX(-102%); transition: transform 0.2s ease;
    padding-top: calc(16px + env(safe-area-inset-top));
  }
  .shell.menu-open .sidebar { transform: none; }
  .shell.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(5, 8, 40, 0.55); }

  .main { padding: 16px 14px calc(24px + env(safe-area-inset-bottom)); }
  .stack { gap: 16px; }
  .title { font-size: 28px; }
  .page-head { flex-wrap: wrap; }
  .head-actions { flex-wrap: wrap; }
  .card { padding: 16px; }

  .form-row > div { flex: 1 1 140px; min-width: 0; }
  .form-row select, .form-row input { width: 100% !important; }
  .form-row .grow { flex: 1 1 100%; }
  .form-row > button { flex: 1 1 100%; padding: 12px; }
  .msg-row { flex-wrap: wrap; }

  .baller-row { flex-wrap: wrap; gap: 12px; }
  .baller-amount { font-size: 30px; }
  .baller-note { display: none; }
  .baller-row .spacer { display: none; }
  .baller-row > button { margin-left: auto; }

  /* tables become cards */
  .row { padding: 10px 8px; }
  .row.head { display: none; }
  .row [data-label]::before {
    content: attr(data-label); display: block; font-size: 10px; font-weight: 600;
    letter-spacing: 0.8px; text-transform: uppercase; color: var(--text2); margin-bottom: 2px;
  }

  .month-grid { grid-template-columns: repeat(3, 1fr); gap: 8px 10px; }
  .month-grid > :nth-child(1) { grid-column: 1 / 3; order: 1; }
  .month-grid > :nth-child(6) { grid-column: 3; order: 2; justify-self: end; }
  .month-grid > :nth-child(5) { grid-column: 1 / -1; order: 3; }
  .month-grid > :nth-child(2) { order: 4; text-align: left; }
  .month-grid > :nth-child(3) { order: 5; text-align: center; }
  .month-grid > :nth-child(4) { order: 6; text-align: right; }

  .hist-grid { grid-template-columns: repeat(3, 1fr); gap: 8px 10px; }
  .hist-grid > :nth-child(1) { grid-column: 1 / 3; order: 1; }
  .hist-grid > :nth-child(5) { grid-column: 3; order: 2; justify-self: end; }
  .hist-grid > :nth-child(6) { display: none; }
  .hist-grid > :nth-child(2) { order: 3; text-align: left; }
  .hist-grid > :nth-child(3) { order: 4; text-align: center; }
  .hist-grid > :nth-child(4) { order: 5; text-align: right; }

  .log-grid { grid-template-columns: 1fr auto auto; gap: 4px 10px; }
  .log-grid > :nth-child(1) { grid-column: 1 / -1; font-size: 12px; }

  /* ring chart */
  .ring-wrap { flex-direction: column; gap: 18px; align-items: stretch; }
  .ring { align-self: center; }
  .legend { max-width: none; }
  .legend-row { grid-template-columns: 11px minmax(0, 1fr) auto 44px; padding: 7px 4px; }
  .legend-row > :nth-child(4) { display: none; }
  .legend-name { flex-wrap: wrap; }

  /* pop-ups fill the screen width */
  .overlay { align-items: flex-end; }
  .modal, .modal.narrow, .modal.wide {
    width: 100%; max-width: 100vw; max-height: 94vh; max-height: 94dvh; border-radius: 16px 16px 0 0;
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
  }
  .modal h2 { font-size: 24px; }
  .edit-row { flex-wrap: wrap; }
  .edit-row .grow { min-width: 140px; }
  .edit-row input[type=text].grow { width: auto; flex: 1 1 140px; }

  /* import review */
  .imp-list { max-height: 48vh; }
  .imp-grid { grid-template-columns: 26px 1fr auto; gap: 6px 10px; }
  .imp-grid > :nth-child(1) { grid-column: 1; grid-row: 1; }
  .imp-grid > :nth-child(2) { grid-column: 2; grid-row: 1; }
  .imp-grid > :nth-child(5) { grid-column: 3; grid-row: 1; }
  .imp-grid > :nth-child(3) { grid-column: 2 / -1; grid-row: 2; }
  .imp-grid > :nth-child(4) { grid-column: 2 / -1; grid-row: 3; }
  .imp-grid > :nth-child(6) { grid-column: 2 / -1; grid-row: 4; }
  .imp-toolbar .grow { flex: 1 1 100%; text-align: left !important; order: -1; }

  /* setup */
  .setup { padding: calc(20px + env(safe-area-inset-top)) 16px 32px; }
  .setup .logo-lg { font-size: 32px; }
  .total-banner .v { font-size: 18px; }
}

/* ---------- entry currency toggle ---------- */
.amount-row { display: flex; gap: 8px; align-items: stretch; }
.seg.mini { align-self: auto; }
.seg.mini button { padding: 9px 14px; font-size: 15px; min-width: 42px; }
.rate-hint { font-size: 12.5px; color: var(--text2); min-height: 17px; margin-top: -2px; }
.orig { font-weight: 500; margin-top: 1px; }
@media (max-width: 820px) {
  .amount-row input { flex: 1; min-width: 0; width: auto !important; }
}
