/* #region zone:finance.style.pages — แผง สรุปยอด KPI รายการ บิล บัตร โลโก้ ตาราง และสถานะว่าง */
.panel {
  min-width: 0;
  padding: var(--sp-5);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.panel-head h2 {
  font-size: var(--t-section);
  line-height: 1.4;
  font-weight: 650;
}
.panel-total {
  color: var(--muted);
  font-size: var(--t-label);
}
.panel-total strong {
  color: var(--text);
  font-size: var(--t-body);
}
.list-panel {
  padding: var(--sp-5) 0 var(--sp-2);
  gap: var(--sp-2);
}
.list-panel > .panel-head,
.list-panel > .muted-line,
.list-panel > .empty-state {
  margin: 0 var(--sp-5);
}
.muted-line {
  color: var(--muted);
}
.grid {
  display: grid;
  gap: var(--sp-4);
}
.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Hero strip: the one number that matters this month. */
.summary-strip {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-6);
  flex-wrap: wrap;
  gap: var(--sp-4);
  padding: var(--sp-4) 18px;
  border-radius: var(--r-hero);
  border: 1px solid var(--hero-line);
  background: var(--hero-bg);
  color: var(--hero-text);
}
.summary-strip > div {
  display: grid;
  gap: var(--sp-1);
}
.summary-strip .kpi-label {
  color: var(--hero-muted);
  font-weight: 600;
}
.summary-strip small {
  color: var(--hero-muted);
  font-size: var(--t-label);
}
.hero-number {
  font-size: clamp(24px, 1.2vw + var(--u-text-sm), 30px);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.summary-strip.negative .hero-number {
  color: var(--hero-neg) !important;
}
.summary-strip .rate {
  text-align: right;
}
.summary-strip .rate strong {
  font-size: var(--t-kpi);
}
.summary-strip.negative {
  color: var(--hero-text) !important;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.kpi {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: var(--sp-3);
  background: var(--kpi-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-kpi);
  min-width: 0;
}
.kpi .kpi-label {
  font-weight: 500;
}
.kpi strong {
  font-size: var(--t-kpi);
  line-height: 1.3;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.kpi small {
  color: var(--muted);
  font-size: var(--t-caption);
}
.kpi.income strong {
  color: var(--money-pos);
}
.kpi.expense strong {
  color: var(--money-neg);
}

/* Rows (accounts, transactions, holdings, BNPL): money right-aligned and tabular. */
.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 64px;
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--line);
}
.row-main {
  display: grid;
  min-width: 0;
  flex: 1;
}
/* A long name (English labels run longer than Thai) wraps onto a second line instead of being cut off. */
.row-main b {
  overflow-wrap: anywhere;
  font-weight: 600;
}
.row-main small,
.row-end small,
.row time {
  color: var(--muted);
  font-size: var(--t-caption);
}
.row > strong,
.row-end strong {
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
  font-weight: 650;
}
.row-end {
  display: grid;
  justify-items: end;
  text-align: right;
}
.tx-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--panel2);
  color: var(--muted);
}
.tx-icon.income {
  color: var(--accent-text);
  background: var(--up-soft);
}
.tx-icon.expense {
  color: var(--money-neg);
  background: var(--money-neg-soft);
}

.bill-list,
.merchant-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}
.bill-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line);
}
.bill-row:first-child,
.merchant-row:first-child {
  border-top: 0;
}
.bill-date {
  display: grid;
  gap: var(--sp-1);
  justify-items: start;
}
.bill-date b {
  font-size: var(--t-body);
}
.bill-name {
  display: grid;
  min-width: 0;
}
.bill-name b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bill-name small {
  color: var(--muted);
  font-size: var(--t-caption);
}
.days-badge,
.status-badge {
  display: inline-block;
  padding: 2px var(--sp-2);
  border-radius: var(--u-radius-pill);
  font-size: var(--t-caption);
  font-weight: 600;
  background: var(--panel2);
  color: var(--muted);
}
.days-badge.soon,
.status-badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}
.days-badge.urgent {
  background: var(--error-soft);
  color: var(--error);
}
.status-badge.ok {
  background: var(--up-soft);
  color: var(--accent-text);
}
.merchant-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) minmax(48px, 30%) auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line);
}
.merchant-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank {
  color: var(--muted);
  font-weight: 600;
}
.meter {
  height: 8px;
  border-radius: 4px;
  background: var(--panel2);
  overflow: hidden;
}
.meter i,
.progress i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}
.w-0 {
  width: 2%;
}
.w-1 {
  width: 10%;
}
.w-2 {
  width: 20%;
}
.w-3 {
  width: 30%;
}
.w-4 {
  width: 40%;
}
.w-5 {
  width: 50%;
}
.w-6 {
  width: 60%;
}
.w-7 {
  width: 70%;
}
.w-8 {
  width: 80%;
}
.w-9 {
  width: 90%;
}
.w-10 {
  width: 100%;
}

.empty-state {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding: var(--sp-4);
  border: 1px dashed var(--line);
  border-radius: var(--r-inner);
  color: var(--muted);
}
.empty-state > .icon {
  color: var(--accent-text);
}
.empty-state p {
  flex: 1 1 220px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-body);
}
.data-table caption {
  text-align: left;
  color: var(--muted);
  font-size: var(--t-caption);
  padding-bottom: var(--sp-2);
}
.data-table th,
.data-table td {
  padding: 10px var(--sp-3);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-weight: 500;
}
.data-table thead th {
  color: var(--muted);
  font-size: var(--t-caption);
  font-weight: 600;
}
.data-table .num {
  text-align: right;
}
.table-scroll {
  overflow-x: auto;
}
.stat-line {
  display: grid;
  gap: var(--sp-1);
}
.stat-line small {
  color: var(--muted);
}
.bullets {
  margin: 0;
  padding-left: var(--sp-5);
  display: grid;
  gap: var(--sp-2);
}

/* Credit cards. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  align-items: start;
  gap: var(--sp-4);
}
/* A credit card is a white statement panel holding the card itself: the face wears the issuer's colour
   (--brand / --brand-ink from the logo registry in finance-v2.css; graphite when the issuer is unknown) and
   the amounts below it sit on the panel in normal ink, so every number reads at full contrast. */
.credit-card {
  --brand: var(--card-face-default);
  --brand-ink: var(--card-face-ink-default);
  --brand-2: color-mix(in oklab, var(--brand) 72%, #000);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  color: var(--text);
  background: var(--card-panel);
  box-shadow: var(--card-shadow);
  min-width: 0;
}
.card-face {
  display: grid;
  align-content: space-between;
  gap: var(--sp-4);
  min-height: 148px;
  padding: var(--sp-4) var(--sp-4) var(--sp-4) 18px;
  border-radius: var(--u-radius-inner);
  color: var(--text);
  background: var(--u-card-2);
  box-shadow: none;
}
.card-face .card-title small,
.card-face .card-balance > span {
  color: inherit;
  opacity: 0.88;
}
.card-face .brand-logo:not(.is-mono, .tile-dark, .tile-brand) {
  background: #fff;
}
.card-face .brand-logo:not(.is-mono, .tile-dark, .tile-brand) img {
  width: calc(var(--logo-size) * 0.72);
  height: calc(var(--logo-size) * 0.72);
}
.card-face .brand-logo {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55);
}
.card-face .row-menu-btn {
  color: inherit;
}
.card-face .row-menu-btn:hover {
  background: var(--u-card);
  color: inherit;
}
.card-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: 0 10px;
}
.card-body > p {
  margin: 0;
}
.card-title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.card-title small,
.card-body span,
.card-body dt {
  color: var(--card-ink-2);
}
.credit-card h3 {
  font-size: var(--t-section);
}
.card-balance {
  display: grid;
}
.card-balance b {
  font-size: var(--t-kpi);
}
.util-row,
.credit-card footer {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  font-size: var(--t-label);
}
.progress {
  height: 8px;
  background: var(--card-track);
  border-radius: 4px;
  overflow: hidden;
}
.credit-card .progress i {
  background: var(--card-fill);
}
.card-facts {
  display: grid;
  gap: var(--sp-1);
  margin: 0;
}
.card-facts div {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
}
.card-facts dd {
  margin: 0;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .grid.two {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 600px) {
  .kpis {
    gap: var(--sp-2);
  }
  .kpi {
    padding: var(--sp-3);
  }
  .summary-strip {
    padding: var(--sp-4);
  }
  .summary-strip .rate {
    text-align: left;
  }
  .panel {
    padding: var(--sp-4);
  }
  .list-panel {
    padding: var(--sp-4) 0 var(--sp-2);
  }
  .list-panel > .panel-head,
  .list-panel > .muted-line,
  .list-panel > .empty-state {
    margin: 0 var(--sp-4);
  }
  .row {
    padding: var(--sp-3) var(--sp-4);
  }
  .bill-row {
    grid-template-columns: 76px minmax(0, 1fr) auto;
    gap: var(--sp-2);
  }
  .merchant-row {
    grid-template-columns: 20px minmax(0, 1fr) auto;
  }
  .merchant-row .meter {
    display: none;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
  .page-head > button {
    width: 100%;
  }
}
/* Row menu ⋯ (edit / delete): a 44px target; revealed on hover or focus only where a pointer can hover. */
.row-menu-btn {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-color: transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}
.row-menu-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.row-menu-btn[aria-expanded='true'] {
  background: var(--acc-soft);
  color: var(--accent-text);
}
.card-title .row-menu-btn,
.panel-head .row-menu-btn {
  margin-left: auto;
}
.row-menu {
  min-width: 224px;
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-2);
}
.row-menu button {
  justify-content: flex-start;
  width: 100%;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--r-inner);
  background: transparent;
  color: var(--text);
  font-size: var(--t-body);
  font-weight: 600;
  text-align: left;
}
.row-menu button:hover,
.row-menu button:focus-visible {
  background: var(--hover);
}
.row-menu button.is-danger {
  color: var(--error);
}
.row-menu button:active {
  background: var(--u-press, var(--hover));
}
td > button {
  margin: var(--sp-1);
}
@media (hover: hover) and (pointer: fine) {
  .row-menu-btn {
    opacity: 0;
  }
  /* A narrow window is used by touch: the ⋯ stays visible there even if the pointer reports hover. */
  @media (max-width: 600px) {
    .row-menu-btn {
      opacity: 1;
    }
  }
  .row:hover .row-menu-btn,
  .row:focus-within .row-menu-btn,
  tr:hover .row-menu-btn,
  tr:focus-within .row-menu-btn,
  .panel:hover > .panel-head .row-menu-btn,
  .panel-head:focus-within .row-menu-btn,
  .credit-card:hover .card-title .row-menu-btn,
  .credit-card:focus-within .card-title .row-menu-btn,
  .subscription-card:hover > .card-title .row-menu-btn,
  .row-menu-btn:focus-visible,
  .row-menu-btn[aria-expanded='true'] {
    opacity: 1;
  }
}

/* Card detail: the instalment plans, then purchases and payments listed on the card, each with its own ⋯.
   Amounts sit in one right-aligned tabular column (a fixed 44px menu slot after it, so nothing shifts). */
.card-detail {
  padding-top: var(--sp-1);
  border-top: 1px solid var(--line);
}
.card-detail summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 44px;
  margin: 0 -8px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-control);
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--text);
}
.card-detail summary::-webkit-details-marker {
  display: none;
}
.card-detail summary:hover {
  background: var(--hover);
}
.card-detail summary .icon {
  flex: 0 0 auto;
  color: var(--card-ink-2);
  transition: transform var(--fm-press, 100ms) ease-out;
}
.card-detail[open] summary .icon {
  transform: rotate(180deg);
}
.card-detail h4,
.card-plans h4 {
  margin: var(--sp-4) 0 var(--sp-1);
  color: var(--card-ink-2);
  font-size: var(--t-label);
  font-weight: 600;
}

.plan-row .row-main small,
.plan-meta {
  color: var(--card-ink-2);
  font-size: var(--t-caption);
}

/* Slim progress: one segment per instalment (billed ones filled), or one bar for a long plan. */

.credit-card .rows {
  margin: 0;
}
.credit-card .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 44px;
  gap: var(--sp-3);
  min-height: 56px;
  padding: 6px 0;
  border-top-color: var(--line);
}
.credit-card .row-main {
  gap: 2px;
}
.credit-card .row-main small {
  color: var(--card-ink-2);
}
.credit-card .row > strong {
  margin-left: 0;
  justify-self: end;
  color: var(--text);
}
.credit-card .row > strong.positive {
  color: var(--money-pos) !important;
}
.credit-card .card-body .row-menu-btn {
  color: var(--card-ink-2);
}
.credit-card .card-body .row-menu-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.credit-card .card-title .row-menu-btn {
  margin-left: auto;
}
/* #endregion */
.row-main .income-status {
  display: block;
  margin-top: var(--sp-1);
}
.row-main .income-status.received {
  color: var(--accent-text);
}
