﻿:root {
  --bg: #F4F8FC;
  --surface: #FFFFFF;
  --surface-2: #EDF5FB;
  --primary: #2D6BFF;
  --primary-deep: #0B1F5C;
  --secondary: #4A8DFF;
  --light-blue: #58C6F3;
  --accent-cyan: #7EE7FF;
  --success: #20B486;
  --warning: #F59E0B;
  --text: #0B1F5C;
  --subtext: #7A8EA6;
  --line: rgba(22, 86, 132, .12);
  --shadow: 0 18px 45px rgba(28, 86, 132, .14);
  --soft-shadow: 0 8px 24px rgba(28, 86, 132, .1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% -8%, rgba(35, 137, 201, .12), transparent 34%),
    linear-gradient(180deg, #FFFFFF 0%, var(--bg) 190px, #EEF5FA 100%);
  color: var(--text);
  font-family: "Noto Sans Thai", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
  font-weight: 400;
}

button, input, select, textarea { font: inherit; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  padding: 22px 18px 98px;
}

.loading-view {
  min-height: 82vh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 8px;
}

.loading-view h1 { font-size: 32px; margin: 0; }
.loading-view p, .eyebrow, small { color: var(--subtext); }

.orb {
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 18px 42px rgba(35, 137, 201, .28);
  animation: breathe 1.8s ease-in-out infinite;
}

.brand-logo {
  width: 54px;
  height: 54px;
  margin: 0;
  border-radius: 18px;
  object-fit: cover;
  display: block;
  background: #EAF6FF;
  box-shadow: 0 10px 26px rgba(35, 137, 201, .18);
}

.brand-logo.large {
  width: 112px;
  height: 112px;
  margin: 0 auto 12px;
  border-radius: 50%;
}

.screen { display: none; animation: rise .25s ease both; }
.screen.active { display: block; }
#loading.hidden { display: none; }

.topbar, .page-head, .section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.brand-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h1, .page-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  color: var(--text);
  font-weight: 800;
}

.eyebrow { margin: 0 0 4px; font-size: 13px; }

.icon-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--primary);
  background: var(--surface);
  display: grid;
  place-items: center;
  box-shadow: var(--soft-shadow);
}

.balance-card, .form-card, .pocket-card, .goal-card, .summary-strip, .chart-card, .mini-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.balance-card {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 22px;
  padding: 24px;
  margin-bottom: 18px;
  color: white;
  background:
    linear-gradient(135deg, rgba(255,255,255,.22), rgba(255,255,255,0) 36%),
    linear-gradient(135deg, var(--primary-deep), var(--primary) 56%, var(--secondary));
  box-shadow: 0 22px 48px rgba(35, 137, 201, .32);
}

.balance-card::before,
.balance-card::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
}

.balance-card::before {
  width: 170px;
  height: 170px;
  right: -58px;
  top: -54px;
}

.balance-card::after {
  width: 120px;
  height: 120px;
  right: 22px;
  bottom: -70px;
}

.balance-card p { margin: 0 0 8px; color: rgba(255,255,255,.8); }
.balance-card h2 { margin: 0 0 20px; font-size: 34px; position: relative; z-index: 1; }

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.metric-row span, .summary-strip span {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.18);
  position: relative;
  z-index: 1;
}

.progress-wrap {
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(22, 86, 132, .1);
}

.balance-card .progress-wrap {
  background: rgba(255,255,255,.25);
  position: relative;
  z-index: 1;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width .35s ease;
}

.balance-card .progress-fill { background: rgba(255,255,255,.94); }

.section-title h2, .form-card h2, .chart-card h2 {
  margin: 0;
  font-size: 18px;
}

.text-button {
  border: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 700;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.quick-actions button {
  min-width: 0;
  border: 0;
  border-radius: 18px;
  padding: 12px 6px;
  color: var(--primary);
  background: var(--surface);
  box-shadow: var(--soft-shadow);
  display: grid;
  place-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
}

.quick-actions i {
  width: 38px;
  height: 38px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  font-size: 17px;
}

.card-list { display: grid; gap: 12px; margin-bottom: 22px; }
.card-list.compact { gap: 10px; }

.pocket-card, .goal-card, .mini-card {
  border-radius: 18px;
  padding: 16px;
}

.pocket-head, .goal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.name-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.emoji {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px rgba(35, 137, 201, .08);
}

.badge-soft {
  color: var(--primary);
  border-radius: 99px;
  padding: 6px 10px;
  font-size: 12px;
  background: rgba(35, 137, 201, .1);
}

.badge-soft.warning { color: #A35A00; background: rgba(245,158,11,.16); }
.badge-soft.success { color: #087853; background: rgba(32,180,134,.14); }

.pocket-values, .goal-values {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pocket-values span, .goal-values span {
  min-width: 0;
  color: var(--subtext);
  font-size: 12px;
}

.pocket-values strong, .goal-values strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.form-card {
  display: grid;
  gap: 14px;
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--subtext);
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 14px;
  color: var(--text);
  background: #F8FBFE;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(35, 137, 201, .45);
  box-shadow: 0 0 0 4px rgba(35, 137, 201, .1);
}

.file-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-upload span {
  min-height: 54px;
  border: 1px dashed rgba(35, 137, 201, .28);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--primary);
  background: #F8FBFE;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-upload i {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.slip-preview {
  display: none;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--soft-shadow);
}

.slip-preview.show { display: block; }

textarea { resize: vertical; }

.inline-balance {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 15px;
  color: var(--subtext);
  background: var(--surface-2);
}

.primary-button, .secondary-button {
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 14px 28px rgba(35, 137, 201, .22);
}

.secondary-button {
  color: var(--primary);
  background: #F8FBFE;
  border: 1px solid var(--line);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-radius: 18px;
  padding: 10px;
  margin-bottom: 16px;
}

.summary-strip span {
  background: var(--surface-2);
}

.wallet-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.wallet-hero h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.epocket-card {
  position: relative;
  overflow: hidden;
  min-height: 210px;
  border-radius: 28px;
  padding: 22px;
  color: white;
  background: linear-gradient(145deg, #2F4653, #18232D);
  box-shadow: 0 22px 50px rgba(24, 35, 45, .24);
  margin-bottom: 18px;
}

.epocket-card::before {
  content: "";
  position: absolute;
  inset: 18px 38px 28px;
  border: 2px solid rgba(135, 236, 223, .86);
  border-radius: 24px;
}

.epocket-card::after {
  content: "";
  position: absolute;
  left: 40px;
  right: 38px;
  top: 67px;
  height: 32px;
  border-top: 2px solid rgba(135, 236, 223, .86);
  border-radius: 50%;
}

.epocket-card > * {
  position: relative;
  z-index: 1;
}

.epocket-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: #BFFCF4;
  margin-bottom: 56px;
}

.epocket-card p {
  margin: 0 0 6px;
  text-align: center;
  color: rgba(255,255,255,.86);
}

.epocket-card h2 {
  text-align: center;
  font-size: 38px;
  margin: 0 0 42px;
}

.epocket-card small {
  display: block;
  text-align: center;
  color: rgba(255,255,255,.72);
}

.wallet-tabs {
  width: max-content;
  max-width: 100%;
  margin: 0 auto 16px;
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: #DCE7ED;
}

.wallet-tabs button {
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  color: #526574;
  background: transparent;
  font-weight: 700;
}

.wallet-tabs button.active {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.wallet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.wallet-panel {
  border-radius: 24px;
  padding: 18px;
  margin-bottom: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.wallet-panel h2,
.wallet-section-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.wallet-panel p {
  margin: 0;
  color: var(--subtext);
}

.hidden-panel { display: none; }

.pocket-tab-panel { display: none; }
.pocket-tab-panel.active { display: block; }

.wallet-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}

.wallet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wallet-card {
  min-height: 176px;
  border-radius: 18px;
  padding: 14px;
  color: white;
  background: linear-gradient(180deg, #546774, #22313E);
  box-shadow: var(--soft-shadow);
  display: grid;
  align-content: space-between;
  position: relative;
}

.wallet-card.primary-wallet {
  background: linear-gradient(180deg, #BAF5A4, #203040 76%);
}

.wallet-visual,
.wallet-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(131, 237, 217, .32);
  display: grid;
  place-items: center;
  font-size: 24px;
}

.wallet-card h3 {
  margin: 10px 0 4px;
  font-size: 16px;
  font-weight: 800;
}

.wallet-card p {
  margin: 0;
  color: rgba(255,255,255,.75);
}

.wallet-card strong {
  font-size: 18px;
}

.pocket-detail-card {
  position: relative;
  border-radius: 26px;
  padding: 22px;
  margin-bottom: 18px;
  color: white;
  background: linear-gradient(135deg, var(--primary-deep), var(--primary), var(--light-blue));
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.pocket-detail-card .wallet-visual {
  background: rgba(255,255,255,.22);
}

.pocket-detail-card h2 {
  margin: 6px 0 0;
  font-size: 26px;
  font-weight: 800;
}

.pocket-detail-card p,
.pocket-detail-card small {
  margin: 0;
  color: rgba(255,255,255,.78);
}

.pocket-detail-card > strong {
  font-size: 34px;
}

.moneyflow-pocket-card {
  background:
    radial-gradient(circle at 88% 6%, rgba(126,231,255,.34), transparent 30%),
    linear-gradient(135deg, var(--primary), var(--secondary) 62%, var(--light-blue, #58C6F3));
}

.card-gear {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: rgba(255,255,255,.92);
}

.epocket-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 22px;
}

.epocket-metrics span {
  padding: 10px;
  border-radius: 16px;
  background: rgba(255,255,255,.18);
  display: grid;
  gap: 2px;
}

.wallet-status {
  position: absolute;
  top: 12px;
  right: 12px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #075E4B;
  background: #CFF9EC;
  font-size: 11px;
  font-weight: 800;
}

.wallet-status.low { color: #925400; background: #FFF0C2; }
.wallet-status.empty { color: #9F1239; background: #FFE0E8; }

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

.filter-row select:last-child {
  grid-column: 1 / -1;
}

.form-hero {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  margin-bottom: 20px;
}

.form-hero h1 {
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
}

.back-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 15px;
  color: var(--text);
  background: rgba(255,255,255,.8);
  box-shadow: var(--soft-shadow);
}

.bank-form {
  min-height: calc(100vh - 150px);
  border-radius: 28px 28px 20px 20px;
  padding: 22px 18px;
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.bank-form > p {
  margin: 0;
  color: var(--subtext);
}

.pocket-form-icon {
  width: 92px;
  height: 92px;
  margin: 0 auto;
  border-radius: 28px;
  display: grid;
  place-items: center;
  font-size: 42px;
  background: linear-gradient(135deg, #EAF4FF, #D9FBFF);
  box-shadow: var(--soft-shadow);
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

legend {
  color: var(--subtext);
  font-size: 13px;
  margin-bottom: 8px;
}

.chip-group {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip-group label { display: block; }
.chip-group input { display: none; }

.chip-group span {
  display: block;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--subtext);
  background: #F8FBFE;
}

.chip-group input:checked + span {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.cancel-button {
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  color: #6B7280;
  background: #EEF3F8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}

.source-pocket-card,
.destination-row,
.transfer-total {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: #F8FBFE;
  border: 1px solid var(--line);
}

.source-pocket-card small,
.destination-row small {
  display: block;
  color: var(--subtext);
}

.down-arrow {
  display: grid;
  place-items: center;
  color: white;
}

.down-arrow i {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.destination-list {
  display: grid;
  gap: 10px;
}

.destination-list h3 {
  margin: 10px 0 0;
  color: var(--subtext);
  font-size: 14px;
}

.destination-row {
  grid-template-columns: 22px 48px 1fr 112px;
}

.destination-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.transfer-total {
  grid-template-columns: 1fr auto;
  font-weight: 800;
}

.warning-text {
  min-height: 20px;
  margin: 0;
  color: #C24154;
  font-weight: 700;
}

.history-icon.transfer { background: var(--primary); }

.wallet-allocate-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.allocate-row {
  display: grid;
  grid-template-columns: 54px 1fr 118px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--soft-shadow);
  color: var(--text);
}

.allocate-row small {
  display: block;
  color: var(--subtext);
}

.history-list {
  display: grid;
  gap: 8px;
  padding-bottom: 18px;
}

.history-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line);
}

.history-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--success);
}

.history-icon.out { background: #EF6676; }
.history-item small { display: block; color: var(--subtext); }
.amount-out { color: #C24154; }
.amount-in { color: #07865F; }

.editable .pocket-card {
  display: grid;
  grid-template-columns: 1fr 128px;
  align-items: center;
  gap: 12px;
}

.sticky-action {
  position: sticky;
  bottom: 88px;
  width: 100%;
}

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

.goal-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.mini-card strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.bar-chart { display: grid; gap: 12px; }
.bar-row { display: grid; gap: 6px; }
.bar-row div { height: 12px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.bar-row div { background: var(--surface-2); }
.bar-row span { display: block; height: 100%; border-radius: inherit; }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(calc(100% - 28px), 500px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 38px rgba(28, 86, 132, .18);
  z-index: 10;
}

.bottom-nav button {
  min-width: 0;
  border: 0;
  border-radius: 16px;
  padding: 8px 4px;
  color: var(--subtext);
  background: transparent;
  display: grid;
  gap: 2px;
  place-items: center;
  font-size: 11px;
}

.bottom-nav button i { font-size: 18px; }
.bottom-nav button.active { color: white; background: linear-gradient(135deg, var(--primary), var(--secondary)); }

.toast-pill {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%) translateY(20px);
  width: min(calc(100% - 40px), 440px);
  padding: 12px 16px;
  border-radius: 18px;
  color: white;
  background: rgba(23,32,51,.86);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
  z-index: 20;
}

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

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes breathe {
  50% { transform: scale(1.08); }
}

@media (max-width: 390px) {
  .app-shell { padding-inline: 12px; }
  .balance-card h2 { font-size: 31px; }
  .pocket-values, .goal-values, .summary-strip { grid-template-columns: 1fr; }
  .editable .pocket-card, .two-col, .report-grid, .goal-actions { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .quick-actions button { font-size: 11px; padding-inline: 4px; }
  .wallet-grid { grid-template-columns: 1fr; }
  .allocate-row { grid-template-columns: 48px 1fr; }
  .allocate-row input { grid-column: 1 / -1; }
  .wallet-tabs { width: 100%; }
  .wallet-tabs button { flex: 1; padding-inline: 8px; }
}
