html,
body,
button,
a,
input,
select,
textarea {
  max-width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  touch-action: manipulation;
}

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

h1,
h2,
.big,
.metric-card .big {
  letter-spacing: -0.02em;
}

h1,
h2,
.metric-card .big,
.bill-amount,
.expense-total {
  font-weight: 800;
}

b {
  font-weight: 700;
}

.page-kicker,
.section-kicker,
.field-label {
  font-weight: 700;
}

.btn,
.chip,
.pill,
summary,
.due-badge,
.plan-badge {
  font-weight: 700;
}

.drawer-logo,
.drawer-title,
.tool-badge,
.brand-mark span {
  font-weight: 800 !important;
}

.nav button[data-tab],
.drawer-subtitle {
  font-weight: 700 !important;
}

.wrap {
  padding-top: calc(18px + env(safe-area-inset-top));
}

.metric-card {
  align-items: stretch;
}

.metric-card .big,
.timing-box > b,
.donut-hole b {
  width: 100%;
  max-width: 100%;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  text-align: center;
}

.metric-label {
  text-align: left;
}

.status-line:empty {
  display: none !important;
}

.debt-type-fields {
  margin-top: 2px;
}

.bank-debt-fields,
.gold-purity-fields,
.due-date-wrap.bank-required {
  margin: 4px 0 10px;
  padding: 12px;
  border: 1px solid #ead9ad;
  border-radius: 15px;
  background: #fcf7e9;
}

.bank-debt-fields[hidden],
.gold-purity-fields[hidden] {
  display: none !important;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.required-badge {
  margin-top: 8px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #fff0cd;
  color: #9b650d;
  font-size: 10px;
  font-weight: 700;
}

.required-badge[hidden] {
  display: none;
}

.due-date-wrap input[type="date"] {
  min-height: 54px;
  color-scheme: light;
}

.debt-sort-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 10px 2px 16px;
  color: #81796c;
  font-size: 12px;
  font-weight: 600;
}

.debt-sort-row select {
  width: auto;
  min-width: 150px;
  margin: 0;
  padding: 10px 34px 10px 12px;
  border-radius: 14px;
  background: #fffdf8;
  font-size: 13px;
}

.bank-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #eee1c4;
  border-radius: 15px;
  background: #fbf7ed;
}

.bank-detail-grid div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #746d63;
  font-size: 11px;
}

.bank-detail-grid b {
  color: #111827;
  font-size: 13px;
}

.bank-plan {
  margin: 12px 0;
  padding: 11px 0;
  border-top: 1px solid #eee7db;
  border-bottom: 1px solid #eee7db;
}

.bank-plan-list {
  max-height: 340px;
  margin-top: 8px;
  overflow-y: auto;
}

.bank-plan-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 9px 4px;
  border-top: 1px solid #f0ece4;
  font-size: 12px;
}

.bank-plan-row.overdue {
  background: #fff7f5;
  color: #bd2e24;
}

.bank-plan-row.paid {
  opacity: 0.55;
  text-decoration: line-through;
}

.bank-no {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #f0eee9;
  font-weight: 700;
}

.donut-wrap {
  display: grid;
  place-items: center;
  padding: 10px 0 18px;
}

.debt-donut {
  display: grid;
  width: 172px;
  height: 172px;
  place-items: center;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(33, 28, 18, 0.07);
}

.donut-hole {
  display: flex;
  width: 118px;
  height: 118px;
  padding: 9px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px #f0eadf;
  text-align: center;
}

.donut-hole span {
  color: #81796c;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.donut-hole b {
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.15;
}

.distribution-list {
  border-top: 1px solid #f0ede6;
}

.distribution-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f0ede6;
}

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

.dist-name {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

.dist-name i {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.dist-values {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
}

.dist-values small,
.gold-purity-label {
  margin-top: 3px;
  color: #81796c;
  font-size: 11px;
  font-weight: 600;
}

.debt-balance {
  margin-bottom: 10px !important;
}

.app-signature {
  margin: 26px 0 6px;
  color: #a07a2d;
  font-size: 12px;
  font-style: italic;
  text-align: center;
  opacity: 0.8;
}

html.modal-scroll-lock,
body.modal-scroll-lock {
  overscroll-behavior: none;
}

body.modal-scroll-lock {
  position: fixed !important;
  right: 0;
  left: 0;
  width: 100%;
  overflow: hidden !important;
}

.modal {
  align-items: flex-end !important;
  justify-content: center !important;
  padding: max(8px, env(safe-area-inset-top)) 12px 12px !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

.modal .sheet {
  display: flex !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 736px !important;
  max-height: calc(100dvh - max(20px, env(safe-area-inset-top)) - 12px) !important;
  margin: 0 !important;
  padding: 12px 18px calc(18px + env(safe-area-inset-bottom)) !important;
  flex-direction: column !important;
  overflow: hidden !important;
  border: 1px solid rgba(233, 223, 202, 0.9);
  border-radius: 28px 28px 20px 20px !important;
  background: #fffdf9 !important;
  box-shadow: 0 -14px 44px rgba(16, 24, 39, 0.18) !important;
}

.modal .sheet h2 {
  flex: 0 0 auto;
  margin: 2px 2px 14px;
  font-size: 24px;
  font-weight: 800;
}

.modal .sheet form {
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0 1px 6px;
  flex: 1 1 auto;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.modal .sheet input,
.modal .sheet select,
.modal .sheet textarea,
.modal .sheet .actions {
  min-width: 0;
  max-width: 100%;
}

.modal .sheet input,
.modal .sheet select,
.modal .sheet textarea {
  min-height: 51px;
  margin: 5px 0 9px;
  border-color: #e5ddce;
  border-radius: 15px;
  background: #fff;
}

.modal .sheet textarea {
  min-height: 84px;
}

.modal .sheet .actions {
  position: static !important;
  margin: 14px 0 2px !important;
  padding: 0 !important;
  background: none !important;
}

.actions,
.actions > .btn {
  min-width: 0;
}

.debt-timing-card {
  overflow: hidden;
}

.debt-timing-head {
  align-items: flex-start;
}

.timing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.timing-box {
  display: flex;
  min-width: 0;
  min-height: 116px;
  padding: 13px;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  border: 1.5px solid #ddd;
  border-radius: 17px;
  transition: transform 0.12s, box-shadow 0.12s;
}

.timing-box:active {
  transform: scale(0.985);
}

.timing-box:focus-visible,
.timing-box[aria-expanded="true"] {
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 24, 39, 0.07);
}

.timing-box > b {
  font-size: 23px;
  line-height: 1.08;
}

.timing-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #555d6a;
  font-size: 12px;
  font-weight: 700;
}

.timing-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.timing-meta {
  min-height: 15px;
  color: #737b88;
  font-size: 11px;
  line-height: 1.35;
}

.timing-now {
  border-color: #df8079;
  background: #fff8f7;
}

.timing-now .timing-dot {
  background: #c43a2f;
}

.timing-now > b {
  color: #b92d24;
}

.timing-soon {
  border-color: #d7b34c;
  background: #fffdf4;
}

.timing-soon .timing-dot {
  background: #c28b16;
}

.timing-future {
  border-color: #8391a8;
  background: #f8faff;
}

.timing-future .timing-dot {
  background: #53627a;
}

.timing-unscheduled {
  border-color: #b7ad9c;
  background: #fbfaf6;
}

.timing-unscheduled .timing-dot {
  background: #8f8678;
}

.timing-detail {
  margin-top: 12px;
  padding: 2px 13px 8px;
  border: 1px solid #e6dfd2;
  border-radius: 16px;
  background: #fff;
}

.timing-detail[hidden] {
  display: none;
}

.timing-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0 8px;
}

.timing-detail-head b {
  font-size: 14px;
}

.timing-detail-close {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f3f1ed;
  color: #5f6470;
  font-size: 20px;
  line-height: 1;
}

.timing-detail-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid #f0ece4;
}

.timing-detail-row > div:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.timing-detail-row > div:first-child b,
.timing-detail-amount b {
  font-size: 13px;
}

.timing-detail-row > div:first-child span {
  color: #737b88;
  font-size: 11px;
  line-height: 1.35;
}

.timing-detail-amount {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 2px;
  text-align: right;
}

.timing-detail-amount small {
  color: #81796c;
  font-size: 10px;
}

.timing-detail-empty {
  padding: 12px 0 15px;
  color: #737b88;
  font-size: 12px;
}

.cash-history-card .row > div:first-child {
  min-width: 0;
}

.cash-history-card .row > div:last-child {
  white-space: nowrap;
}

@media (max-width: 390px) {
  .metric-card {
    padding: 15px;
  }

  .modal {
    padding-right: 8px !important;
    padding-left: 8px !important;
  }

  .modal .sheet {
    padding-right: 14px !important;
    padding-left: 14px !important;
    border-radius: 24px 24px 18px 18px !important;
  }

  .modal .sheet h2 {
    font-size: 22px;
  }
}

@media (max-width: 340px) {
  .wrap {
    padding-right: 9px;
    padding-left: 9px;
  }

  .metric-grid,
  .timing-grid {
    gap: 7px;
  }

  .metric-card,
  .timing-box {
    padding-right: 10px;
    padding-left: 10px;
  }

  .timing-label {
    font-size: 11px;
  }
}
