:root {
  --pink: #f97393;
  --pink2: #ffb3c6;
  --pink3: #fff0f6;
  --yellow: #fff6b9;
  --yellow2: #fff8cf;
  --ink: #6b2146;
  --ink2: #b0125b;
  --muted: #8e6d80;
  --line: #ffd1e2;
  --line2: #ffc0d7;
  --panel: rgba(255,255,255,.9);
  --panel2: rgba(255,255,255,.72);
  --danger: #af3150;
  --good: #23745c;
  --shadow: 0 14px 30px rgba(120,80,120,.12);
  --r: 18px;
  --max: 1180px;
  font-family: "Mali", cursive;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; -webkit-text-size-adjust: 100%; }
body {
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 12% 0%, #fff0f6 0%, transparent 60%),
    radial-gradient(900px 520px at 88% 8%, #fff8cf 0%, transparent 58%),
    linear-gradient(135deg, var(--yellow), var(--pink3));
}

button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; height: auto; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  line-height: 1.55;
  font-size: 14px;
}
.toast.good { border-color: #bde6d5; color: var(--good); }
.toast.bad { border-color: #ffc5d0; color: var(--danger); }

.page-loader {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  overflow: hidden;
  background: rgba(255,209,226,.55);
}
.page-loader span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink), var(--yellow));
  animation: loadingSlide 1s ease-in-out infinite;
}
@keyframes loadingSlide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(260%); }
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px 12px;
}

.auth-card {
  width: min(560px, 100%);
  padding: 16px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  text-align: center;
}

.auth-logo {
  height: 96px;
  display: block;
  margin: 0 auto 8px;
  filter: drop-shadow(0 10px 18px rgba(249,115,147,.18));
}

.auth-title h1,
.brand h1,
.view-head h2,
.view-head h3,
.section-title {
  color: var(--ink2);
  text-shadow: 0 2px 0 #fff;
}

.auth-title h1 { font-size: clamp(22px, 5vw, 30px); line-height: 1.35; }
.auth-title p, .sub { color: var(--muted); line-height: 1.55; font-size: 14px; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,209,226,.55);
}

.segmented button {
  margin: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.segmented button.active {
  background: #fff;
  color: var(--ink2);
  box-shadow: 0 6px 16px rgba(249,115,147,.14);
}

.auth-form,
.form-panel {
  text-align: left;
}

label {
  display: block;
  margin: 11px 0 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

input, textarea, select {
  width: 100%;
  min-height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 11px 13px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: .16s ease;
}

textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus {
  border-color: #ff9ec0;
  box-shadow: 0 0 0 4px rgba(249,115,147,.14);
}
input::placeholder, textarea::placeholder { color: #a78998; opacity: 1; }

button,
.file-button {
  min-height: 44px;
  border: 1.5px solid var(--line2);
  border-radius: 16px;
  padding: 10px 16px;
  color: var(--ink);
  background: linear-gradient(135deg, var(--pink2), var(--yellow2));
  box-shadow: 0 6px 18px rgba(249,115,147,.14);
  cursor: pointer;
  font-weight: 900;
  transition: .15s ease;
}
button:hover, .file-button:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(249,115,147,.20); }
button:active,
.app-nav a:active,
.file-button:active { transform: scale(.98); }
button:disabled { opacity: .6; cursor: wait; transform: none; }
button.is-busy {
  position: relative;
  color: transparent !important;
}
button.is-busy::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(176,18,91,.22);
  border-top-color: var(--ink2);
  border-radius: 999px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.primary { width: 100%; margin-top: 14px; }
.ghost { background: #fff; box-shadow: none; }
.small { min-height: 38px; padding: 7px 12px; border-radius: 14px; font-size: 13px; }
.signout-btn { justify-self: end; white-space: nowrap; }
.refresh-btn { white-space: nowrap; }
.danger { color: var(--danger); background: #fff5f7; border-color: #ffc5d0; box-shadow: none; }
.text-button {
  width: 100%;
  min-height: 38px;
  margin-top: 8px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--ink2);
}

.grid { display: grid; gap: 10px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.wide { grid-column: 1 / -1; }

.app-screen {
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: 12px 12px 32px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.header-avatar {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border: 2px solid var(--line);
  border-radius: 999px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--ink2);
  background: linear-gradient(135deg, var(--pink3), var(--yellow2));
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 8px 14px rgba(249,115,147,.12);
}
.header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.brand h1 { font-size: clamp(18px, 3vw, 26px); line-height: 1.25; }
.brand p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(420px, 50vw); }
.shop-mark {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.shop-mark img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 999px;
}

.app-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.app-nav a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  color: var(--ink2);
  background: rgba(255,255,255,.74);
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
}
.app-nav a.active { background: linear-gradient(135deg, var(--pink2), var(--yellow2)); border-color: var(--pink); }

.view { animation: fadeUp .2s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
}
.view-head.compact { margin: 0 0 10px; }
.view-head h2 { font-size: clamp(22px, 4vw, 32px); line-height: 1.25; }
.view-head h3 { font-size: 20px; }
.view-head > div { min-width: 0; }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.metrics.due-only { grid-template-columns: minmax(0, 1fr); }
.metric {
  min-height: 82px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--panel2);
  text-align: center;
}
.metric strong { display: block; color: var(--ink2); font-size: 22px; line-height: 1.35; }
.metric span { color: var(--muted); font-size: 13px; }

.credit-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,.9), rgba(255,248,207,.72));
}
.credit-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
.credit-card strong {
  display: block;
  color: var(--ink2);
  font-size: 24px;
  line-height: 1.35;
}
.credit-card .sub { margin-top: 2px; }

.panel {
  border: 1px solid rgba(255,255,255,.9);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  padding: 14px;
}

.table-panel { overflow-x: auto; }
table { width: 100%; min-width: 720px; border-collapse: collapse; background: #fff; border-radius: 16px; overflow: hidden; }
.status-table table { min-width: 0; }
.status-table th,
.status-table td { text-align: center; vertical-align: middle; }
.status-table td:nth-child(2) { text-align: left; }
th, td {
  padding: 11px 10px;
  border-bottom: 1px solid #ffe3ed;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.5;
}
th { color: var(--ink2); background: #fff6fa; font-weight: 900; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.money { text-align: right; white-space: nowrap; }
.status-table .money { text-align: center; }

.mode-tabs { margin-top: 0; }
.credit-notice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 10px 0 12px;
  border: 1.5px solid #c7ebdc;
  border-radius: 16px;
  background: #ecfff7;
  color: var(--good);
  padding: 10px;
}
.credit-notice strong { color: var(--good); }
.credit-notice p { margin-top: 2px; font-size: 12px; line-height: 1.45; }
.select-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 12px;
}
.select-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(96px, 150px);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.select-row.payment-row {
  grid-template-columns: auto minmax(0, 1fr) minmax(92px, 132px);
  padding: 8px 10px;
}
.payment-row .amount-input {
  min-height: 40px;
  padding: 8px 10px;
}
.payment-row .item-title { font-size: 13px; }
.payment-row .item-sub { font-size: 11px; }
.payment-row .amount-input:disabled {
  border-color: #dedce0;
  background: #ecebed;
  color: #929096;
  cursor: not-allowed;
  opacity: 1;
  -webkit-text-fill-color: #929096;
}
.select-row.is-checked { border-color: var(--pink); background: linear-gradient(135deg, #fff0f6, #fffdf0); }
.select-row input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--pink); }
.select-row .item-title { font-weight: 900; color: var(--ink2); word-break: break-word; }
.select-row .item-sub { font-size: 12px; color: var(--muted); word-break: break-word; }

.section-title {
  margin: 14px 0 8px;
  font-size: 18px;
  font-weight: 900;
}

.section-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}
.section-headline .section-title { margin: 10px 0 8px; }

.static-field {
  min-height: 46px;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 11px 13px;
  background: #fff;
  color: var(--ink2);
  font-weight: 900;
}
.fixed-store select { display: none; }

.payment-box {
  display: grid;
  justify-items: center;
  align-items: center;
  align-content: center;
  gap: 10px;
  margin: 12px 0;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,240,246,.88), rgba(255,253,239,.9));
  padding: 18px;
  text-align: center;
  min-height: 220px;
}
.payment-box .section-title { width: 100%; margin-top: 0; }
.bank-layout {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  justify-content: center;
  width: min(560px, 100%);
}
.qr-img {
  width: 100%;
  max-width: 180px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.bank-info {
  display: grid;
  gap: 7px;
  justify-items: center;
  color: #624153;
  font-size: 13px;
  line-height: 1.5;
}
.bank-info strong { color: var(--ink2); }
.bank-info button { justify-self: center; margin-top: 4px; }
.shipping-bank-box {
  margin-top: 14px;
  min-height: 190px;
}

.history-panel { padding: 12px; }
.history-summary {
  margin: 0 0 10px;
}
.history-summary .section-title { margin: 0 0 2px; }
.history-list {
  display: grid;
  gap: 10px;
}
.history-card {
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 12px;
}
.history-card-head,
.history-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.history-card-head {
  margin-bottom: 7px;
}
.history-card time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}
.history-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.history-badge,
.history-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  background: #fff6fa;
  color: var(--ink2);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.history-status {
  background: rgba(255,255,255,.8);
  color: var(--muted);
}
.status-pending { background: #fff9d8; border-color: #ffe8a5; color: #8a5a00; }
.status-synced,
.status-confirmed { background: #ecfff7; border-color: #c7ebdc; color: var(--good); }
.status-failed { background: #fff5f7; border-color: #ffc5d0; color: var(--danger); }
.status-reversed { background: #f4edf3; border-color: #dfcbd8; color: var(--muted); }
.history-title-row h3 {
  margin: 0;
  color: var(--ink2);
  font-size: 16px;
  line-height: 1.35;
}
.history-title-row strong {
  color: var(--ink2);
  white-space: nowrap;
  font-size: 15px;
}
.history-card p {
  margin-top: 6px;
  color: #624153;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-line;
}
.history-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}
.history-codes span {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,240,246,.7);
  padding: 4px 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}
.history-transfer .history-badge { background: #eef8ff; border-color: #c8e5ff; color: #20628a; }
.history-shipping .history-badge { background: #ecfff7; border-color: #c7ebdc; color: var(--good); }
.history-credit .history-badge { background: #fff9d8; border-color: #ffe8a5; color: #8a5a00; }

.address-choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}
.address-choice {
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 10px;
}
.address-choice label { display: flex; align-items: flex-start; gap: 8px; margin: 0; }
.address-choice input { width: 18px; min-height: 18px; flex: 0 0 auto; margin-top: 2px; }
.address-choice strong { color: var(--ink2); }
.address-choice p { margin-top: 4px; color: #624153; font-size: 13px; line-height: 1.5; }

.check { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.check input { width: 18px; min-height: 18px; flex: 0 0 auto; margin: 0; }

.profile-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(240px, 320px);
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}
.password-card {
  display: grid;
  gap: 6px;
  align-content: start;
}
.password-card .section-title { margin: 0 0 2px; }
.password-card label { margin-top: 6px; }
.password-submit {
  justify-self: end;
  width: auto;
  margin-top: 6px;
}
.avatar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.avatar {
  width: 86px;
  height: 86px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pink3), var(--yellow2));
  display: grid;
  place-items: center;
  color: var(--ink2);
  font-size: 28px;
  font-weight: 900;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.file-button { background: #fff; box-shadow: none; }
.file-button input { display: none; }

.address-panel { margin-top: 12px; }
.address-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.address-card {
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 12px;
}
.address-card-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.address-card strong { color: var(--ink2); }
.address-card p { color: #624153; font-size: 13px; line-height: 1.55; margin: 3px 0; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #ecfff7;
  color: var(--good);
  border: 1px solid #c7ebdc;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.form-actions .primary { margin-top: 0; }
.address-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.address-form-wrap {
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.empty {
  border: 1.5px dashed var(--line2);
  border-radius: 16px;
  background: rgba(255,255,255,.68);
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 880px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
  }
  .brand p { max-width: 100%; }
  .brand { grid-column: 1; grid-row: 1; }
  .header-avatar { width: 58px; height: 58px; }
  .app-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .app-nav::-webkit-scrollbar { display: none; }
  .app-nav a { white-space: nowrap; }
  #logoutBtn {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    justify-self: end;
    align-self: start;
    margin-top: 6px;
  }
  .profile-layout, .grid.two, .address-form { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
  .view-head { align-items: flex-start; flex-direction: row; }
  .view-head button { width: auto; }
  .view-head h2 { font-size: 28px; }
  .form-actions { grid-template-columns: 1fr; }
  #changePasswordForm button { width: auto; }
}

@media (max-width: 520px) {
  .auth-screen { padding: 10px; }
  .app-screen { padding: 10px 10px 26px; }
  .topbar { margin-bottom: 12px; }
  .brand h1 { font-size: 20px; }
  .brand p { font-size: 13px; }
  .shop-mark { font-size: 11px; }
  .app-nav { gap: 6px; }
  .app-nav a { padding: 7px 10px; font-size: 12px; }
  .status-table th,
  .status-table td { padding: 9px 7px; font-size: 12px; }
  .status-table td:nth-child(2) { text-align: center; }
  .money { white-space: normal; }
  .select-row { grid-template-columns: auto minmax(0, 1fr); }
  .select-row.payment-row { grid-template-columns: auto minmax(0, 1fr) minmax(86px, 106px); gap: 7px; }
  .select-row:not(.payment-row) input.amount-input { grid-column: 1 / -1; }
  .credit-card { grid-template-columns: 1fr; text-align: center; }
  .credit-card button { justify-self: center; }
  .credit-notice { grid-template-columns: 1fr; text-align: center; }
  .credit-notice button { justify-self: center; }
  .bank-layout { grid-template-columns: 1fr; }
  .qr-img { max-width: 220px; justify-self: center; }
  .section-headline { align-items: flex-start; }
  .history-card-head,
  .history-title-row { align-items: flex-start; }
  .history-title-row { flex-direction: column; }
}
