*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

:root {
  --teal-header: #0a5c5c;
  --teal-dark: #084f4f;
  --teal-mid: #0d7373;
  --bg-page: #e8eef2;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --border: #9fc0c4;
  --paid: #dc2626;
  --recv: #16a34a;
  --nav-active: #ffd54f;
}

html,
body {
  min-height: 100%;
}

body.lenden-app {
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg-page);
  padding-bottom: 76px;
}

.lenden-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 12px;
  background: var(--teal-header);
  color: #fff;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.lenden-header h1 {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.lenden-main {
  width: 100%;
  padding: 10px 8px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lenden-card {
  background: var(--card);
  border: 1px solid #d5e0e6;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

.lenden-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.lenden-row--full {
  grid-template-columns: 1fr;
}

.lenden-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 46px;
  padding: 0 12px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  position: relative;
}

.lenden-field.is-open {
  z-index: 40;
}

.lenden-field--date {
  font: inherit;
  color: inherit;
  cursor: pointer;
  justify-content: space-between;
}

.lenden-field--date strong {
  font-size: 0.82rem;
  font-weight: 800;
}

.lenden-field--date svg {
  width: 18px;
  height: 18px;
  color: var(--teal-header);
  flex-shrink: 0;
}

.lenden-field__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--teal-header);
  font-size: 0.75rem;
  line-height: 1;
}

.lenden-field__icon svg {
  width: 16px;
  height: 16px;
}

.lenden-field__icon--pay {
  color: #ef4444;
  font-size: 0.9rem;
}

.lenden-field__icon--mode {
  font-size: 0.85rem;
}

.lenden-field .custom-select {
  flex: 1;
  min-width: 0;
  position: relative;
}

.custom-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.custom-select__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.custom-select__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select__chevron {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.custom-select__chevron svg {
  display: block;
  width: 100%;
  height: 100%;
}

.custom-select.is-open .custom-select__chevron {
  transform: rotate(180deg);
}

.custom-select__menu {
  position: absolute;
  top: calc(100% + 10px);
  left: -36px;
  right: -10px;
  z-index: 100;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1.5px solid #d1d5db;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  max-height: 220px;
  overflow-y: auto;
}

.custom-select__option {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.custom-select__option:hover {
  background: #e8f6f6;
  color: var(--teal-header);
}

.custom-select__option.is-selected {
  background: var(--teal-header);
  color: #fff;
}

.lenden-amount {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  outline: none;
}

.lenden-amount:focus {
  border-color: var(--teal-header);
  box-shadow: 0 0 0 2px rgba(10, 92, 92, 0.12);
}

.lenden-message {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

.lenden-message.hidden {
  display: none;
}

.lenden-message.error {
  background: #fee2e2;
  color: #991b1b;
}

.lenden-message.success {
  background: #dcfce7;
  color: #166534;
}

.btn-save-lenden {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--teal-header);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.btn-save-lenden svg {
  width: 18px;
  height: 18px;
}

.btn-save-lenden:active {
  transform: scale(0.99);
}

.lenden-section-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #334155;
  letter-spacing: 0.02em;
}

.lenden-history {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.lenden-empty {
  padding: 18px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.lenden-empty.hidden {
  display: none;
}

.lenden-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
}

.lenden-item__badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.lenden-item__badge.is-pay {
  background: #ffe4e6;
  color: #be123c;
}

.lenden-item__badge.is-recv {
  background: #dcfce7;
  color: #166534;
}

.lenden-item__info {
  flex: 1;
  min-width: 0;
}

.lenden-item__name {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lenden-item__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
}

.lenden-item__date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e0f2f1;
  color: #0f766e;
}

.lenden-item__amount {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.lenden-item__amount.is-pay {
  background: #ffe4e6;
  color: #be123c;
}

.lenden-item__amount.is-recv {
  background: #dcfce7;
  color: #166534;
}

.btn-del-lenden {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: #ffe4e6;
  color: #e11d48;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.lenden-summary {
  padding: 12px;
  border-radius: 14px;
  background: #eef4f8;
}

.lenden-summary__title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #64748b;
}

.lenden-summary__grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.lenden-summary__box {
  padding: 10px 8px;
  background: #fff;
  border-radius: 12px;
  text-align: center;
  border: 1px solid #e5e7eb;
}

.lenden-summary__box span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.25;
}

.lenden-summary__box strong {
  font-size: 0.9rem;
  font-weight: 800;
}

.is-paid {
  color: var(--paid);
}

.is-recv {
  color: var(--recv);
}

.is-net {
  color: var(--paid);
}

.is-net.is-positive {
  color: var(--recv);
}

.lenden-toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  z-index: 50;
  transform: translateX(-50%) translateY(8px);
  padding: 10px 16px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.lenden-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  padding: 8px 4px 10px;
  background: var(--teal-header);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav-item.active {
  color: var(--nav-active);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding-top: 2px;
  padding-bottom: 2px;
}

.nav-item__icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.nav-item__icon--jantri {
  -webkit-mask-image: url("../assets/icons/game.svg");
  mask-image: url("../assets/icons/game.svg");
}

.nav-item__icon--cutting {
  -webkit-mask-image: url("../assets/icons/cutting.svg");
  mask-image: url("../assets/icons/cutting.svg");
}

.nav-item__icon--result {
  -webkit-mask-image: url("../assets/icons/result.svg");
  mask-image: url("../assets/icons/result.svg");
}

.nav-item__icon--hisab {
  -webkit-mask-image: url("../assets/icons/hisab.svg");
  mask-image: url("../assets/icons/hisab.svg");
}

.nav-item__icon--lenden {
  -webkit-mask-image: url("../assets/icons/lenden.svg");
  mask-image: url("../assets/icons/lenden.svg");
}

.nav-item__icon--delete {
  -webkit-mask-image: url("../assets/icons/delete.svg");
  mask-image: url("../assets/icons/delete.svg");
}

.nav-item__icon--menu {
  -webkit-mask-image: url("../assets/icons/menu.svg");
  mask-image: url("../assets/icons/menu.svg");
}

.date-picker,
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 12px 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.date-picker.is-open,
.confirm-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.date-picker.is-closing,
.confirm-modal.is-closing {
  opacity: 0;
  visibility: visible;
  pointer-events: none;
}

.date-picker[hidden],
.confirm-modal[hidden] {
  display: none !important;
}

.date-picker__backdrop,
.confirm-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 32, 32, 0.55);
}

.date-picker__panel,
.confirm-modal__panel {
  position: relative;
  width: min(360px, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
  overflow: hidden;
  transform: translateY(14px) scale(0.94);
  opacity: 0;
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease;
}

.date-picker.is-open .date-picker__panel,
.confirm-modal.is-open .confirm-modal__panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.date-picker.is-closing .date-picker__panel,
.confirm-modal.is-closing .confirm-modal__panel {
  transform: translateY(10px) scale(0.96);
  opacity: 0;
}

.confirm-modal {
  align-items: center;
  padding: 20px 12px;
}

.confirm-modal__panel {
  padding: 20px 18px;
  text-align: center;
}

.confirm-modal__panel h3 {
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 800;
}

.confirm-modal__panel p {
  margin-bottom: 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.4;
}

.confirm-modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-confirm-cancel,
.btn-confirm-ok {
  min-height: 42px;
  border: none;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.btn-confirm-cancel {
  background: #e2e8f0;
  color: #334155;
}

.btn-confirm-ok {
  background: #dc2626;
  color: #fff;
}

.date-picker__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--teal-header);
  color: #fff;
}

.date-picker__head h2 {
  font-size: 0.95rem;
  font-weight: 800;
}

.date-picker__close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.date-picker__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 4px;
}

.date-picker__nav {
  width: 36px;
  height: 36px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.date-picker__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 8px 12px 0;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
}

.date-picker__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 8px 12px 12px;
}

.date-picker__day {
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}

.date-picker__day.is-muted {
  color: #cbd5e1;
}

.date-picker__day.is-today {
  box-shadow: inset 0 0 0 1.5px var(--teal-header);
}

.date-picker__day.is-selected {
  background: var(--teal-header);
  color: #fff;
}

.date-picker__footer {
  padding: 0 12px 14px;
  text-align: center;
}

.date-picker__today {
  padding: 8px 18px;
  border: none;
  border-radius: 999px;
  background: var(--teal-mid);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

@media (min-width: 900px) {
  .lenden-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 14px 16px 24px;
  }

  .lenden-card {
    padding: 16px;
  }

  .lenden-summary__box span {
    font-size: 0.7rem;
  }

  .lenden-summary__box strong {
    font-size: 1rem;
  }
}

@media (max-width: 380px) {
  .lenden-row {
    gap: 6px;
  }

  .lenden-field {
    padding: 0 8px;
    min-height: 42px;
  }

  .custom-select__trigger,
  .lenden-field--date strong {
    font-size: 0.7rem;
  }

  .lenden-summary__box span {
    font-size: 0.55rem;
  }

  .lenden-summary__box strong {
    font-size: 0.78rem;
  }
}
