:root {
  --bg: #f5f5f5;
  --bg-white: #ffffff;
  --bg-otp: #f7f8fa;
  --primary: #113d6d;
  --primary-dark: #0c3058;
  --accent: #2c74a0;
  --text: #101428;
  --text-muted: #6a7380;
  --placeholder: #a8b3c4;
  --danger: #e54240;
  --ok: #2841b2;
  --otp-bg: #eef1f4;
  --keypad-bg: #e4e4e6;
  --radius: 12px;
  --radius-btn: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: "Noto Sans Thai", "Leelawadee UI", "Thonburi", "Sarabun", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.page {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

.page--white {
  background: var(--bg-otp);
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 16px;
  background: transparent;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.header__back {
  position: absolute;
  left: 6px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.header__back svg {
  display: block;
}

.header__title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

/* Login */
.login {
  flex: 1;
  padding: 56px 24px 24px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 44px;
}

.brand__logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
}

.brand__name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.field {
  margin-bottom: 12px;
}

.field__input {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: var(--radius);
  padding: 0 16px;
  background: var(--bg-white);
  font-size: 14px;
  color: var(--text);
  outline: none;
}

.field__input::placeholder {
  color: var(--placeholder);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn:active {
  background: var(--primary-dark);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--bottom {
  margin-top: 36px;
}

.hint-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  min-height: 0;
}

.hint-error:empty {
  display: none;
}

/* OTP */
.otp-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-otp);
}

.otp-main {
  padding: 28px 24px 16px;
}

.otp-tip {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 28px;
  overflow-wrap: anywhere;
}

.otp-tip__phone {
  color: var(--accent);
  font-weight: 700;
}

.otp-tip__tail {
  color: var(--text-muted);
  font-weight: 400;
}

.otp-boxes {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 22px;
}

.otp-box {
  width: 58px;
  height: 52px;
  border-radius: 8px;
  background: var(--otp-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.otp-box.is-active {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.otp-resend {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.otp-resend__sec {
  color: var(--accent);
  font-weight: 700;
}

.otp-resend__btn {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.keypad {
  margin-top: auto;
  padding: 6px 6px calc(10px + var(--safe-bottom));
  background: var(--keypad-bg);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.keypad__key {
  height: 50px;
  min-width: 0;
  border: none;
  border-radius: 5px;
  background: #fcfcfc;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
  font-size: 24px;
  font-weight: 500;
  color: #1c1c1e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.keypad__key--wide {
  grid-column: 1 / 3;
}

.keypad__key--icon {
  grid-column: 3;
}

.keypad__key--icon svg {
  display: block;
}

.keypad__key:active {
  background: #e8e8ea;
}

/* Account */
.account-body,
.cancel-body {
  padding: 8px 16px 16px;
  flex: 1;
}

.list-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 16px 14px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.list-row__title {
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 600;
}

.list-row__warn {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.35;
  white-space: nowrap;
}

.list-row__chev {
  color: #a3a3a3;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.list-row__chev svg {
  display: block;
}

.footer-fixed {
  margin-top: auto;
  padding: 12px 20px calc(20px + var(--safe-bottom));
}

/* Cancel conditions */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  margin-bottom: 12px;
}

.card__title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 14px;
  color: var(--text);
}

.cond-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.cond-item:last-child {
  margin-bottom: 0;
}

.cond-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.cond-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.cond-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.cond-text.is-bad {
  color: var(--danger);
}

.notice-list {
  list-style: disc;
  padding-left: 18px;
}

.notice-list li {
  color: var(--danger);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 6px;
  padding-left: 2px;
}

.notice-list li::marker {
  color: var(--danger);
}

.notice-list li:last-child {
  margin-bottom: 0;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.modal.is-open {
  display: flex;
}

.modal__mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 320px;
  background: var(--bg-white);
  border-radius: 16px;
  padding: 22px 20px 20px;
  text-align: center;
}

.modal__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal__msg {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 20px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  max-width: 80%;
  z-index: 200;
  display: none;
}

.toast.is-show {
  display: block;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.35);
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
}

.loading-overlay.is-show {
  display: flex;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #eee;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
