/* FinUp Web v2.3.3 — Responsive Revision 2
   Layout adaptif untuk ponsel, tablet, desktop, portrait, dan landscape. */

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-width: 0;
}

img,
svg,
canvas,
video {
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  max-width: 100%;
}

.main,
.topbar-inner,
.bottom-inner,
.card,
.chart,
.filter-box,
.list-item,
.list-main,
.list-text,
.menu-card,
.metric,
.hero-stat,
.setting-row,
.modal,
.auth-card,
.quick-add-card,
.lock-card {
  min-width: 0;
}

.main {
  width: 100%;
}

.hero-value,
.metric strong,
.amount,
.cash-flow-button b {
  overflow-wrap: anywhere;
}

.tabs,
.period-tabs {
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.table-wrap,
.report-table-wrap,
[data-table-scroll] {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

table {
  max-width: 100%;
}

.action-row,
.report-actions,
.goal-actions,
.row-between {
  flex-wrap: wrap;
}

/* Ponsel kecil */
@media (max-width: 479px) {
  .main {
    padding: 14px;
  }

  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar-inner {
    gap: 8px;
  }

  .top-brand {
    gap: 8px;
    min-width: 0;
  }

  .top-brand img {
    width: 36px;
    height: 36px;
  }

  .top-brand h1 {
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
  }

  .topbar .row {
    gap: 5px;
    flex: 0 0 auto;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    font-size: 17px;
  }

  .hero {
    border-radius: 20px;
    padding: 18px;
  }

  .hero-value {
    font-size: clamp(24px, 8vw, 30px);
  }

  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick {
    min-height: 78px;
    padding: 11px 8px;
    font-size: 11px;
  }

  .menu-grid,
  .grid-2,
  .planning-grid,
  .filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .menu-card {
    padding: 14px;
  }

  .donut-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .donut {
    align-self: center;
  }

  .chart-head {
    flex-direction: column;
    align-items: stretch;
  }

  .legend {
    flex-wrap: wrap;
  }

  .list-item {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .list-main {
    width: 100%;
  }

  .amount,
  .tx-side,
  .rec-actions {
    margin-left: auto;
    max-width: 100%;
  }

  .setting-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .setting-row > button,
  .setting-row > select,
  .setting-row > .btn {
    width: 100%;
  }

  .action-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .action-row .btn,
  .action-row .btn-primary,
  .report-actions .btn,
  .report-actions button {
    width: 100%;
  }

  .modal {
    padding-left: 14px;
    padding-right: 14px;
  }

  .full-page-header {
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .full-page-back,
  .full-page-spacer {
    width: 38px;
    height: 38px;
  }

  .full-page-title {
    font-size: 16px;
  }

  .bottom-inner {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-btn {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fab {
    right: 14px;
  }

  .auth-card {
    padding: 20px;
    border-radius: 22px;
  }

  .brand h1 {
    font-size: 27px;
  }

  .quick-add-wrap,
  .lock {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* Ponsel lebar dan tablet kecil: hindari dua kolom yang terlalu sempit. */
@media (min-width: 480px) and (max-width: 699px) {
  .main {
    padding: 16px;
  }

  .filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Tablet portrait: dashboard satu kolom agar kartu tidak berhimpitan. */
@media (min-width: 700px) and (max-width: 899px) {
  .dashboard-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .main,
  .topbar-inner {
    max-width: 820px;
  }

  .menu-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Tablet landscape dan desktop sedang. */
@media (min-width: 900px) and (max-width: 1199px) {
  .main,
  .topbar-inner {
    max-width: 1120px;
  }

  .dashboard-layout {
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr);
  }

  .menu-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Desktop dan layar lebar. */
@media (min-width: 1200px) {
  .main,
  .topbar-inner {
    max-width: 1280px;
  }

  .main {
    padding: 28px 32px;
  }

  .dashboard-layout {
    grid-template-columns: minmax(0, 1.12fr) minmax(380px, .88fr);
    gap: 22px;
  }

  .planning-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .quick-grid {
    gap: 14px;
  }

  .bottom-inner {
    max-width: 760px;
  }

  .modal > :not(.full-page-header) {
    width: min(100%, 1180px);
    margin-left: auto;
    margin-right: auto;
  }

  .auth-card {
    width: min(100%, 480px);
  }
}

/* Landscape dengan tinggi terbatas: semua halaman tetap dapat digulir. */
@media (orientation: landscape) and (max-height: 620px) {
  .center-screen,
  .lock,
  .quick-add-wrap {
    align-items: flex-start;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .center-screen {
    padding-top: max(12px, var(--safe-top));
    padding-bottom: max(12px, var(--safe-bottom));
  }

  .auth-card {
    width: min(94vw, 760px);
    margin: auto;
    padding: 16px 20px;
  }

  .auth-card .brand {
    margin-bottom: 8px;
  }

  .auth-card .brand-logo {
    width: 46px;
    height: 46px;
  }

  .auth-card .brand h1 {
    font-size: 24px;
  }

  .auth-card h2 {
    margin-top: 6px;
    font-size: 19px;
  }

  .auth-card .desc {
    margin-bottom: 9px;
  }

  .auth-card .field {
    margin: 8px 0;
  }

  .topbar {
    padding-top: calc(5px + var(--safe-top));
    padding-bottom: 7px;
  }

  .top-brand img {
    width: 34px;
    height: 34px;
  }

  .top-brand h1 {
    font-size: 17px;
  }

  .sync-chip {
    margin-top: 0;
  }

  #appScreen {
    padding-bottom: 68px;
  }

  .bottom-nav {
    padding-top: 3px;
    padding-bottom: calc(3px + var(--safe-bottom));
  }

  .nav-btn {
    padding-top: 2px;
    padding-bottom: 2px;
  }

  .nav-btn i {
    font-size: 18px;
    margin-bottom: 0;
  }

  .fab {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    bottom: calc(58px + var(--safe-bottom));
  }

  .full-page-header {
    padding-top: calc(5px + var(--safe-top));
    padding-bottom: 7px;
    margin-bottom: 12px;
  }

  .full-page-back,
  .full-page-spacer {
    width: 36px;
    height: 36px;
  }

  .modal {
    padding-bottom: calc(14px + var(--safe-bottom));
  }

  .lock-card,
  .quick-add-card {
    margin: auto;
  }
}

/* Perangkat sentuh: target interaksi minimal dan tidak bergantung hover. */
@media (pointer: coarse) {
  button,
  .tab,
  .nav-btn,
  .menu-card,
  .list-item {
    touch-action: manipulation;
  }

  .btn,
  .input,
  select.input {
    min-height: 44px;
  }
}

/* Foldable/narrow split-screen dan zoom browser. */
@media (max-width: 319px) {
  .hero-grid,
  .quick-grid,
  .quick-add-grid,
  .pin-pad {
    grid-template-columns: minmax(0, 1fr);
  }

  .bottom-nav {
    overflow-x: auto;
    justify-content: flex-start;
  }

  .bottom-inner {
    min-width: 310px;
  }
}
