:root {
  --bg-main: #eaf5ff;
  --bg-panel: #ffffff;
  --bg-accent: #d8ecff;
  --primary: #48a9ff;
  --primary-dark: #1f86e0;
  --text-main: #12314d;
  --text-muted: #5a7690;
  --border-soft: #cbe5ff;
  --shadow-soft: 0 18px 40px rgba(49, 122, 189, 0.18);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --ease: 220ms ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 8% 0%, rgba(72, 169, 255, 0.3), transparent 30%),
    radial-gradient(circle at 90% 95%, rgba(31, 134, 224, 0.2), transparent 35%),
    linear-gradient(160deg, #f4fbff 0%, var(--bg-main) 50%, #e1f1ff 100%);
  min-height: 100vh;
}

/* ── Layout ──────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  gap: 0;
}

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
  background: linear-gradient(180deg, #def0ff 0%, #c9e6ff 100%);
  border-right: 1px solid rgba(31, 134, 224, 0.2);
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(72, 169, 255, 0.3);
}

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, #52b1ff, #1f86e0);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.6px;
  box-shadow: 0 8px 14px rgba(31, 134, 224, 0.35);
  overflow: hidden;
}

.brand-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-text h1 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.brand-text p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.menu-label {
  font-size: 0.75rem;
  color: #3778aa;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin: 18px 10px 10px;
}

.menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-button {
  width: 100%;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--ease), background var(--ease), border-color var(--ease), box-shadow var(--ease);
}

.menu-button:hover,
.menu-button:focus-visible {
  transform: translateX(3px);
  background: #f7fcff;
  border-color: #9ed2ff;
  outline: none;
  box-shadow: 0 8px 18px rgba(49, 122, 189, 0.18);
}

.menu-button.active {
  background: linear-gradient(160deg, #58b4ff, #2e96eb);
  border-color: #2c91e4;
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(46, 150, 235, 0.4);
}

/* ── Main content ────────────────────────────────────── */

.content {
  padding: 38px 40px;
}

.hero {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 30px;
  animation: rise 700ms ease-out;
}

.hero h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.4vw, 2.1rem);
}

.hero p {
  margin: 12px 0 0;
  max-width: 760px;
  color: var(--text-muted);
  line-height: 1.65;
  font-size: 1rem;
}

/* ── Cards ───────────────────────────────────────────── */

.panel-grid {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 16px;
}

.panel-card {
  background: linear-gradient(150deg, #ffffff, #edf7ff);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  padding: 18px;
  min-height: 140px;
  position: relative;
  overflow: hidden;
  animation: rise 800ms ease-out;
}

.panel-card::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -30px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(72, 169, 255, 0.18);
}

.panel-card h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-card p {
  margin: 10px 0 0;
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 0.95rem;
  max-width: 32ch;
}

/* ── Module area ─────────────────────────────────────── */

.module-title {
  margin-top: 28px;
  font-size: 0.86rem;
  color: #2f6d9c;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.module-placeholder {
  margin-top: 10px;
  background: #f8fcff;
  border: 1px dashed #98ccf5;
  border-radius: var(--radius-md);
  padding: 22px;
  color: var(--text-muted);
  line-height: 1.6;
  animation: rise 900ms ease-out;
}

/* ── Animations ──────────────────────────────────────── */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(31, 134, 224, 0.2);
  }

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

  .content {
    padding: 28px 18px 40px;
  }
}

@media (max-width: 620px) {
  .menu {
    grid-template-columns: 1fr;
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 22px 18px;
  }
}

/* ── Calculator module shared styles ─────────────────── */

.module-heading {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.module-desc {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form-section-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #3778aa;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 18px 0 10px;
}

.calc-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.field input,
.field select {
  padding: 9px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text-main);
  background: #fff;
  transition: border-color var(--ease), box-shadow var(--ease);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(72, 169, 255, 0.2);
}

.calc-btn {
  align-self: flex-start;
  padding: 11px 28px;
  background: linear-gradient(160deg, #58b4ff, #2e96eb);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(46, 150, 235, 0.35);
  transition: transform var(--ease), box-shadow var(--ease);
}

.calc-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(46, 150, 235, 0.45);
}

.result-box {
  margin-top: 22px;
  background: #f0f9ff;
  border: 1px solid #b8dcf8;
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-box.hidden {
  display: none;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  padding-bottom: 8px;
  border-bottom: 1px solid #d6eefb;
}

.result-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.result-row strong {
  font-size: 1rem;
}

.result-positive strong {
  color: #1a8c4e;
}

.result-negative strong {
  color: #c0392b;
}

.result-error {
  color: #c0392b;
  font-size: 0.92rem;
}

@media (max-width: 620px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Brand button reset ──────────────────────────────── */

button.brand {
  cursor: pointer;
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
  transition: background var(--ease), border-color var(--ease), box-shadow var(--ease);
}

button.brand:hover {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(72, 169, 255, 0.55);
  box-shadow: 0 4px 14px rgba(72, 169, 255, 0.2);
}

button.brand:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* ── Module view (wraps loaded calculator) ───────────── */

.module-view {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 30px;
  animation: rise 450ms ease-out;
}

.module-loading {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* ── Dashboard hero ──────────────────────────────────── */

.dash-hero {
  margin-bottom: 32px;
}

.dash-eyebrow {
  margin: 0 0 8px;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--primary-dark);
}

.dash-title {
  margin: 0 0 12px;
  font-size: clamp(1.9rem, 3.5vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.dash-subtitle {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.65;
  max-width: 560px;
}

.dash-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dash-chip {
  background: rgba(72, 169, 255, 0.12);
  border: 1px solid rgba(72, 169, 255, 0.3);
  color: var(--primary-dark);
  border-radius: 100px;
  padding: 5px 16px;
  font-size: 0.81rem;
  font-weight: 600;
}

/* ── Dashboard module cards ──────────────────────────── */

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 18px;
}

.dash-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(49, 122, 189, 0.07);
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease);
  animation: rise 600ms ease-out both;
  font: inherit;
  color: var(--text-main);
  -webkit-appearance: none;
  appearance: none;
}

.dash-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(49, 122, 189, 0.18);
  border-color: var(--primary);
}

.dash-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.dash-card-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin-bottom: 2px;
}

.dash-card-tag {
  display: inline-block;
  align-self: flex-start;
  padding: 3px 12px;
  border-radius: 100px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dash-card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

.dash-card-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
  flex: 1;
}

.dash-card-cta {
  margin-top: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary-dark);
}

@media (max-width: 620px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }

  .module-view {
    padding: 20px 16px;
  }
}

/* ── Amortization table ──────────────────────────────── */

.amort-section {
  margin-top: 28px;
}

.amort-section.hidden {
  display: none;
}

.amort-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.amort-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.amort-toggle-all {
  padding: 7px 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: #f4fbff;
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}

.amort-toggle-all:hover {
  background: #e2f3ff;
  border-color: var(--primary);
}

.amort-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
}

.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.amort-table thead tr {
  background: #e8f4ff;
}

.amort-table th {
  padding: 10px 14px;
  text-align: right;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-soft);
}

.amort-table th:nth-child(1),
.amort-table th:nth-child(2) {
  text-align: left;
}

.amort-table td {
  padding: 9px 14px;
  text-align: right;
  color: var(--text-main);
  border-bottom: 1px solid #eaf4ff;
}

.amort-table td:nth-child(1),
.amort-table td:nth-child(2) {
  text-align: left;
}

/* Year rows */
.amort-year-row {
  background: #f7fbff;
  cursor: default;
}

.amort-year-row:hover {
  background: #eef7ff;
}

.amort-year-row td {
  border-bottom: 1px solid #d4ebff;
}

/* Expand button */
.amort-expand-btn {
  background: none;
  border: none;
  padding: 3px;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--primary-dark);
  border-radius: 6px;
  transition: background var(--ease);
}

.amort-expand-btn:hover {
  background: #d8ecff;
}

.amort-chevron {
  transition: transform 220ms ease;
  display: block;
}

/* Month sub-header */
.amort-month-header td {
  background: #f0f9ff;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-soft);
}

/* Month rows */
.amort-month-row {
  background: #fff;
}

.amort-month-row:hover {
  background: #f7fbff;
}

.amort-month-group.hidden {
  display: none;
}

/* ── Form actions row ────────────────────────────────── */

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 20px;
}

.calc-btn--secondary {
  background: #ffffff;
  color: var(--primary-dark);
  border: 1.5px solid var(--primary);
  box-shadow: none;
}

.calc-btn--secondary:hover {
  background: #edf6ff;
  box-shadow: 0 6px 14px rgba(46, 150, 235, 0.18);
}

.calc-btn--active {
  background: linear-gradient(160deg, #58b4ff, #2e96eb);
  color: #fff;
  border-color: #2c91e4;
}

/* ── Acquittance section ─────────────────────────────── */

.acquittance-section {
  margin-top: 24px;
  background: #f4faff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  animation: rise 350ms ease-out;
}

.acquittance-section.hidden {
  display: none;
}

.acquittance-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 700;
}

.acquittance-desc {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.acquittance-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.acquittance-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.acquittance-row .field {
  flex: 0 0 200px;
}

@media (max-width: 620px) {
  .acquittance-row {
    flex-direction: column;
    align-items: stretch;
  }

  .acquittance-row .field {
    flex: unset;
  }
}

/* ── Hybrid ARM toggle row ───────────────────────────── */

.hybrid-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 0;
  cursor: pointer;
  user-select: none;
}

.hybrid-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-dark);
  cursor: pointer;
  flex-shrink: 0;
}

.hybrid-toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.hybrid-toggle-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #dbeafe;
  color: #1e40af;
  flex-shrink: 0;
}

.hybrid-toggle-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.hybrid-fields {
  margin-top: 14px;
  padding: 16px;
  background: #f0f8ff;
  border: 1px solid #bee3f8;
  border-radius: var(--radius-md);
  animation: rise 300ms ease-out;
}

.hybrid-fields.hidden {
  display: none;
}

.extra-pay-fields.hidden {
  display: none;
}

/* ── Phase badges ────────────────────────────────────── */

.phase-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
  line-height: 1.6;
}

.phase-badge--fix {
  background: #dbeafe;
  color: #1e40af;
}

.phase-badge--var {
  background: #fef9c3;
  color: #854d0e;
}

.result-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 4px 0;
}

/* Variable-phase month rows get a subtle tint */
.amort-phase2 {
  background: #fffdf0;
}

/* ── Language toggle ──────────────────────────────────── */

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 0;
  width: calc(100% - 32px);
  margin: 0 16px 4px;
  background: rgba(0,0,0,0.18);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 3px;
  overflow: hidden;
}

.lang-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1;
  padding: 6px 10px;
  border: none;
  border-radius: 16px;
  background: transparent;
  color: rgba(255,255,255,0.55);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), box-shadow var(--ease);
}

.lang-opt:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.1);
}

/* Active option pill */
.lang-toggle[data-lang="en"] .lang-opt--en,
.lang-toggle[data-lang="id"] .lang-opt--id {
  background: rgba(255,255,255,0.92);
  color: var(--primary-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.lang-flag { font-size: 1.05rem; line-height: 1; }
.lang-code  { font-size: 0.78rem; font-weight: 800; }

.lang-divider {
  color: rgba(255,255,255,0.2);
  font-size: 0.7rem;
  user-select: none;
  flex-shrink: 0;
}

/* ── Extra payment rows & badge ───────────────────────── */

.amort-extra {
  background: #f0fdf4;
}

.phase-badge--extra {
  background: #16a34a;
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

/* ── Amort header buttons row & PDF button ────────────── */

.amort-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.amort-header-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.calc-btn--pdf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.82rem;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--ease), transform var(--ease);
}

.calc-btn--pdf:hover {
  background: #15803d;
  transform: translateY(-1px);
}

.calc-btn--pdf svg {
  flex-shrink: 0;
}
