/* ============================================================
   깨알도구
   대출 상환 계산기
   tool.css
   ============================================================ */

.tool-page {
  --tool-page-max-width: 980px;
}

/* ============================================================
   CALCULATOR
   ============================================================ */

.loan-calculator {
  align-items: start;
}

/* ============================================================
   SECTION SPACING
   ============================================================ */

.period-title,
.grace-title,
.method-title {
  margin-top: 5px;
}

/* ============================================================
   PERIOD
   ============================================================ */

.period-grid {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 8px;
}

/* ============================================================
   DISABLED GRACE INPUT
   ============================================================ */

#graceInput:disabled {
  cursor: not-allowed;

  background: var(--surface-soft);

  color: var(--text-soft);

  opacity: 0.65;
}

/* ============================================================
   REPAYMENT METHOD
   ============================================================ */

.repayment-options {
  display: grid;

  grid-template-columns: repeat(3, minmax(0, 1fr));

  gap: 6px;
}

.repayment-option {
  min-width: 0;

  cursor: pointer;
}

.repayment-option input {
  position: absolute;

  width: 1px;
  height: 1px;

  opacity: 0;

  pointer-events: none;
}

.repayment-option span {
  display: flex;

  min-height: 68px;

  flex-direction: column;
  align-items: center;
  justify-content: center;

  gap: 4px;

  padding: 8px 5px;

  border: 1px solid var(--line);

  border-radius: 10px;

  background: #fff;

  text-align: center;

  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.repayment-option strong {
  color: var(--text);

  font-size: 12px;

  font-weight: 900;
}

.repayment-option small {
  color: var(--text-soft);

  font-size: 12px;

  line-height: 1.35;
}

.repayment-option:hover span {
  background: var(--surface-soft);
}

.repayment-option input:checked + span {
  border-color: var(--brand);

  background: var(--surface-soft);
}

.repayment-option input:focus-visible + span {
  outline: 2px solid var(--brand);

  outline-offset: 2px;
}

/* ============================================================
   METHOD HELP
   ============================================================ */

.method-help {
  margin-top: 7px;

  padding: 8px 10px;

  border-radius: 9px;

  background: var(--surface-soft);

  color: var(--text-soft);

  font-size: 12px;

  line-height: 1.55;
}

/* ============================================================
   METHOD BADGE
   ============================================================ */

.loan-method-badge {
  display: inline-flex;

  align-items: center;

  min-height: 25px;

  margin-bottom: 12px;

  padding: 0 9px;

  border-radius: 999px;

  background: var(--surface-soft);

  color: var(--text);

  font-size: 12px;

  font-weight: 900;
}

/* ============================================================
   CORE RESULT
   ============================================================ */

.loan-core-grid {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 7px;

  margin-top: 15px;
}

.loan-core-card {
  min-width: 0;

  padding: 13px 9px;

  border: 1px solid var(--line);

  border-radius: 11px;

  background: #fff;

  text-align: center;
}

.loan-core-card span {
  display: block;

  color: var(--text-soft);

  font-size: 12px;

  line-height: 1.4;
}

.loan-core-card strong {
  display: block;

  margin-top: 4px;

  color: var(--brand);

  font-size: 15px;

  font-weight: 900;

  line-height: 1.35;

  overflow-wrap: anywhere;
}

/* ============================================================
   DETAIL RESULT
   ============================================================ */

.loan-result-grid {
  margin-top: 10px;

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

/* ============================================================
   SUMMARY
   ============================================================ */

.loan-summary-note {
  display: grid;

  grid-template-columns:
    auto 1fr
    auto 1fr;

  align-items: center;

  gap: 5px 8px;

  margin-top: 13px;

  padding: 10px;

  border-radius: 10px;

  background: var(--surface-soft);
}

.loan-summary-note span {
  color: var(--text-soft);

  font-size: 12px;

  line-height: 1.4;
}

.loan-summary-note strong {
  color: var(--text);

  font-size: 12px;

  font-weight: 900;

  line-height: 1.4;

  text-align: right;
}

/* ============================================================
   SCHEDULE SECTION
   ============================================================ */

.loan-schedule-section {
  margin-top: 18px;

  padding: 20px;

  border: 1px solid var(--line);

  border-radius: var(--tool-panel-radius);

  background: #fff;
}

/* ============================================================
   SCHEDULE HEAD
   ============================================================ */

.schedule-head {
  display: flex;

  align-items: flex-start;
  justify-content: space-between;

  gap: 12px;

  margin-bottom: 13px;
}

.schedule-head > div:first-child {
  min-width: 0;
}

.schedule-head h2 {
  margin: 0;

  color: var(--text);

  font-size: 16px;

  font-weight: 900;

  line-height: 1.3;
}

.schedule-head p {
  margin: 4px 0 0;

  color: var(--text-soft);

  font-size: 12px;

  line-height: 1.5;
}

.schedule-total {
  flex: 0 0 auto;

  padding: 5px 8px;

  border-radius: 999px;

  background: var(--surface-soft);

  color: var(--text-soft);

  font-size: 12px;

  font-weight: 800;

  white-space: nowrap;
}

/* ============================================================
   MOBILE HINT
   ============================================================ */

.schedule-mobile-hint {
  display: none;

  margin: -4px 0 8px;

  color: var(--text-soft);

  font-size: 12px;

  text-align: center;
}

/* ============================================================
   SCHEDULE TABLE
   ============================================================ */

.schedule-table {
  width: 100%;

  max-height: 560px;

  overflow: auto;

  border: 1px solid var(--line);

  border-radius: 11px;

  background: #fff;

  overscroll-behavior: contain;

  -webkit-overflow-scrolling: touch;

  scrollbar-width: thin;
}

.schedule-scroll {
  min-width: 760px;
}

/* ============================================================
   SCHEDULE ROW
   ============================================================ */

.schedule-row {
  display: grid;

  grid-template-columns:
    52px
    74px
    minmax(115px, 1fr)
    minmax(115px, 1fr)
    minmax(105px, 0.9fr)
    minmax(135px, 1.15fr);

  align-items: center;

  min-height: 43px;

  border-bottom: 1px solid #efeee9;
}

.schedule-row:last-child {
  border-bottom: 0;
}

/* ============================================================
   SCHEDULE CELL
   ============================================================ */

.schedule-row > div {
  min-width: 0;

  padding: 7px 9px;

  color: var(--text);

  font-size: 12px;

  font-weight: 600;

  line-height: 1.35;

  text-align: right;

  white-space: nowrap;
}

.schedule-row > div:first-child,
.schedule-row > div:nth-child(2) {
  text-align: center;
}

.schedule-row > div:first-child {
  color: var(--text-soft);

  font-weight: 700;
}

/* ============================================================
   HEADER
   ============================================================ */

.schedule-header {
  position: sticky;

  top: 0;

  z-index: 2;

  min-height: 41px;

  background: var(--surface-soft);

  border-bottom: 1px solid var(--line);

  box-shadow: 0 1px 0 var(--line);
}

.schedule-header > div {
  color: var(--text-soft);

  font-size: 12px;

  font-weight: 900;
}

/* ============================================================
   PHASE
   ============================================================ */

.schedule-phase {
  display: inline-flex;

  align-items: center;
  justify-content: center;

  min-width: 43px;

  min-height: 22px;

  padding: 0 6px;

  border-radius: 999px;

  font-size: 12px;

  font-weight: 900;

  line-height: 1;
}

.phase-grace {
  background: #f7f2e7;

  color: #75623d;
}

.phase-repayment {
  background: #eef5ea;

  color: #52694a;
}

.phase-interest {
  background: #eef2f5;

  color: #52616b;
}

.phase-maturity {
  background: #fff0ed;

  color: #8a5148;
}

/* ============================================================
   YEAR START
   ============================================================ */

.schedule-year-start {
  border-top: 2px solid var(--line);
}

/* ============================================================
   FINAL PAYMENT
   ============================================================ */

.schedule-body .schedule-row:last-child {
  background: #faf9f5;
}

.schedule-body .schedule-row:last-child > div {
  color: var(--text);

  font-weight: 900;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */

.schedule-table::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.schedule-table::-webkit-scrollbar-track {
  background: var(--surface-soft);
}

.schedule-table::-webkit-scrollbar-thumb {
  border: 2px solid var(--surface-soft);

  border-radius: 999px;

  background: var(--line);
}

/* ============================================================
   GUIDE
   ============================================================ */

.loan-guide-grid {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 8px;

  margin-top: 12px;
}

.loan-guide-card {
  min-width: 0;

  padding: 12px;

  border: 1px solid var(--line);

  border-radius: 11px;

  background: #fff;
}

.loan-guide-card strong {
  color: var(--text);

  font-size: 12px;

  font-weight: 900;
}

.loan-guide-card p {
  margin: 6px 0 0;

  color: var(--text-soft);

  font-size: 12px;

  line-height: 1.6;
}

/* ============================================================
   TABLET
   ============================================================ */

@media (max-width: 820px) {
  .loan-calculator {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 560px) {
  /* ==========================================================
     METHODS
     ========================================================== */

  .repayment-options {
    grid-template-columns: 1fr;
  }

  .repayment-option span {
    min-height: 48px;

    flex-direction: row;
    align-items: center;
    justify-content: space-between;

    padding: 8px 10px;

    text-align: left;
  }

  .repayment-option strong {
    font-size: 12px;
  }

  .repayment-option small {
    font-size: 12px;

    text-align: right;
  }

  /* ==========================================================
     RESULT
     ========================================================== */

  .loan-core-card {
    padding: 11px 7px;
  }

  .loan-core-card strong {
    font-size: 13px;
  }

  .loan-summary-note {
    grid-template-columns: auto 1fr;

    gap: 5px 8px;
  }

  .loan-summary-note span {
    font-size: 12px;
  }

  .loan-summary-note strong {
    font-size: 12px;
  }

  /* ==========================================================
     SCHEDULE
     ========================================================== */

  .loan-schedule-section {
    padding: 14px 8px;

    border-radius: 14px;
  }

  .schedule-head {
    padding: 0 4px;

    gap: 8px;
  }

  .schedule-head h2 {
    font-size: 14px;
  }

  .schedule-head p {
    font-size: 12px;
  }

  .schedule-total {
    font-size: 12px;
  }

  .schedule-mobile-hint {
    display: block;
  }

  .schedule-scroll {
    min-width: 720px;
  }

  .schedule-row {
    grid-template-columns:
      44px
      66px
      minmax(105px, 1fr)
      minmax(105px, 1fr)
      minmax(95px, 0.9fr)
      minmax(125px, 1.15fr);

    min-height: 42px;
  }

  .schedule-row > div {
    padding: 7px 6px;

    font-size: 12px;

    line-height: 1.35;
  }

  .schedule-header > div {
    font-size: 12px;
  }

  .schedule-phase {
    min-width: 40px;

    min-height: 21px;

    font-size: 12px;
  }

  .loan-guide-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   VERY SMALL MOBILE
   ============================================================ */

@media (max-width: 380px) {
  .period-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .loan-core-card strong {
    font-size: 12px;
  }

  .schedule-scroll {
    min-width: 700px;
  }

  .schedule-row > div {
    font-size: 12px;
  }
}
