/* Palette, spacing and components follow Awesome K-Design MD's Toss guide.
   https://github.com/hjsh200219/awesome-k-design-md/blob/main/design-md/toss/DESIGN.md */
:root {
  color-scheme: light dark;
  font-family: "Toss Product Sans", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-synthesis: none;
  --canvas: #f9fafb;
  --surface: #fff;
  --control: #f2f4f6;
  --line: #e5e8eb;
  --grid-zero: #b0b8c1;
  --ink: #191f28;
  --secondary: #333d4b;
  --muted: #4e5968;
  --blue: #0064ff;
  --blue-text: #1957c2;
  --blue-soft: #e8f3ff;
  --hero: #f2f7ff;
  --hero-line: #dce9fb;
  --red: #c91c32;
  --samsung: #1452ad;
  --samsung-line: #2067d3;
  --kb: #755414;
  --kb-line: #f2bc23;
  --kb-soft: #fff3d6;
  --elevation: 0 2px 8px rgb(25 31 40 / .055);
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0d0d0f;
    --surface: #17171c;
    --control: #202027;
    --line: #2c2c35;
    --grid-zero: #596174;
    --ink: #ececef;
    --secondary: #e0e0e6;
    --muted: #acaeba;
    --blue: #4a9dff;
    --blue-text: #91c4ff;
    --blue-soft: #1c3453;
    --hero: #172438;
    --hero-line: #304461;
    --red: #ff8790;
    --samsung: #85baff;
    --kb: #ffd478;
    --kb-soft: #473719;
    --elevation: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.5; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
button, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.shell { width: min(1140px, calc(100% - 64px)); margin-inline: auto; }
main { padding-block: 36px calc(94px + env(safe-area-inset-bottom)); }
.bottom-bar { position: fixed; z-index: 3; inset: auto 0 0; padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
.view-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 400px; gap: 12px; min-height: 54px; }
.view-tabs button { display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-top: 2px solid transparent; padding: 0 4px; background: transparent; color: var(--muted); font-size: 15px; font-weight: 650; }
.view-tabs button[aria-selected="true"] { border-top-color: var(--blue); color: var(--blue-text); }
.tab-icon { position: relative; width: 16px; height: 16px; flex: 0 0 auto; }
.list-icon::before, .list-icon::after { content: ""; position: absolute; top: 3px; height: 2px; border-radius: 1px; background: currentColor; box-shadow: 0 4px currentColor, 0 8px currentColor; }
.list-icon::before { left: 1px; width: 2px; }
.list-icon::after { left: 5px; width: 10px; }
.bars-icon { background: linear-gradient(currentColor, currentColor) 1px 13px / 14px 1.5px, linear-gradient(currentColor, currentColor) 2px 8px / 2px 5px, linear-gradient(currentColor, currentColor) 7px 5px / 2px 8px, linear-gradient(currentColor, currentColor) 12px 2px / 2px 11px; background-repeat: no-repeat; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.3; letter-spacing: -.045em; }
.period { display: inline-flex; flex: none; align-items: center; width: max-content; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.period button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--secondary); font-size: 0; }
.period button::before { content: ""; width: 8px; height: 8px; border-top: 1.5px solid; border-right: 1.5px solid; transform: rotate(45deg); }
#previous::before { transform: rotate(-135deg); }
.period button:hover:not(:disabled), .quiet:hover { background: var(--control); }
.period input { width: 148px; min-height: 44px; border: 0; border-radius: 6px; padding-inline: 8px; background: transparent; text-align: center; font-size: 16px; font-weight: 650; }
.period input::-webkit-calendar-picker-indicator { cursor: pointer; }

.total { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--elevation); }
.total-label { color: var(--secondary); font-weight: 680; font-size: 15px; letter-spacing: -.015em; }
strong, #count, td:last-child { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card-totals { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.month-total { display: grid; align-items: center; padding: 12px 16px; background: var(--hero); border-color: var(--hero-line); }
.month-total-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 8px; }
.month-total strong { font-size: clamp(22px, 2.5vw, 30px); line-height: 1.2; letter-spacing: -.04em; }
.card-total { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; padding: 14px 16px; border-top: 3px solid var(--issuer-line); }
.samsung-card { --issuer: var(--samsung); --issuer-soft: var(--blue-soft); --issuer-line: var(--samsung-line); }
.kb-card { --issuer: var(--kb); --issuer-soft: var(--kb-soft); --issuer-line: var(--kb-line); }
.card-summary { min-width: 0; }
.card-identity { display: flex; flex-wrap: wrap; gap: 4px 7px; align-items: center; margin-bottom: 3px; }
.issuer-logo { display: inline-block; flex: 0 0 auto; position: relative; width: 93px; height: 20px; overflow: hidden; border-radius: 5px; background: #edf4ff; }
.issuer-logo img { position: absolute; top: 50%; left: 50%; width: 101px; transform: translate(-50%, -50%); }
.kb-card .issuer-logo { background: #f8d445; }
.kb-card .issuer-logo img { width: 106px; }
.export-menu { position: relative; }
.export-menu summary { display: grid; place-items: center; list-style: none; width: 44px; height: 44px; border-radius: 10px; color: var(--issuer); cursor: pointer; }
.export-menu summary::-webkit-details-marker { display: none; }
.export-menu summary:hover, .export-menu[open] summary { background: var(--issuer-soft); }
.export-menu summary[aria-disabled="true"] { opacity: .4; cursor: default; background: transparent; }
.export-icon { position: relative; width: 16px; height: 11px; margin-top: 5px; border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 4px 4px; }
.export-icon::before, .export-icon::after { content: ""; position: absolute; left: 50%; }
.export-icon::before { top: -6px; width: 1.5px; height: 11px; border-radius: 1px; background: currentColor; transform: translateX(-50%); }
.export-icon::after { top: -6px; width: 7px; height: 7px; box-sizing: border-box; border-top: 1.5px solid; border-left: 1.5px solid; transform: translateX(-50%) rotate(45deg); }
.export-actions { position: absolute; z-index: 2; top: calc(100% + 4px); right: 0; min-width: 132px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 4px 16px rgb(0 0 0 / .14); }
.export-actions button { display: block; width: 100%; min-height: 44px; padding-inline: 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 14px; font-weight: 650; text-align: left; white-space: nowrap; }
.export-actions button:hover:not(:disabled) { background: var(--issuer-soft); color: var(--issuer); }
.export-feedback { grid-column: 1 / -1; color: var(--secondary); font-size: 13px; }
.export-feedback:empty { position: absolute; }
.card-total strong { display: block; line-height: 1.3; font-size: clamp(18px, 2.1vw, 24px); letter-spacing: -.035em; }

.ledger { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--elevation); overflow: hidden; }
.ledger-heading, .controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-inline: 24px; }
.ledger-heading { padding-top: 20px; }
.ledger-title { display: flex; align-items: center; gap: 8px; }
#ledger-title { font-size: 24px; font-weight: 750; letter-spacing: -.035em; }
#count { color: var(--blue-text); font-size: 14px; font-weight: 680; }
.quiet { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; background: transparent; border: 0; border-radius: 8px; padding-inline: 10px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.refresh-icon { position: relative; width: 13px; height: 13px; border: 1.5px solid; border-right-color: transparent; border-radius: 50%; }
.refresh-icon::after { content: ""; position: absolute; right: -2px; top: -1px; width: 5px; height: 5px; border-right: 1.5px solid; border-bottom: 1.5px solid; }
.controls { padding-block: 12px 18px; }
.card-filter { display: flex; gap: 4px; padding: 4px; background: var(--control); border-radius: 12px; }
.card-filter button { min-height: 36px; padding: 5px 14px; border: 0; background: transparent; border-radius: 8px; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; transition: background-color 150ms ease; }
.card-filter button[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue-text); }
.card-filter button:hover[aria-pressed="false"] { background: var(--surface); }
.search { display: flex; align-items: center; gap: 12px; width: min(100%, 268px); border: 1.5px solid transparent; border-radius: 10px; padding-inline: 14px; background: var(--control); }
.search:focus-within { border-color: var(--blue); background: var(--surface); }
.search input { min-width: 0; width: 100%; padding: 9px 0; outline: none; border: 0; font-size: 16px; background: transparent; }
.search input::placeholder { color: var(--muted); }
.search-icon { position: relative; width: 13px; height: 13px; border: 1.5px solid var(--muted); border-radius: 50%; flex: 0 0 auto; }
.search-icon::after { content: ""; position: absolute; left: 9px; top: 9px; width: 5px; height: 1.5px; transform: rotate(45deg); background: var(--muted); }
.status { min-height: 152px; display: grid; place-items: center; text-align: center; border-top: 1px solid var(--line); padding: 20px; color: var(--muted); font-size: 15px; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 15px; }
th, td { padding: 14px 12px; text-align: left; overflow-wrap: anywhere; }
th:first-child, td:first-child { width: 20%; padding-left: 24px; }
th:nth-child(3), td:nth-child(3) { width: 22%; }
th:last-child, td:last-child { width: 22%; text-align: right; padding-right: 24px; }
th { color: var(--muted); background: var(--control); font-size: 13px; font-weight: 650; }
td { border-top: 1px solid var(--line); }
td:first-child { color: var(--muted); font-variant-numeric: tabular-nums; }
td:nth-child(2) { font-weight: 650; }
td:last-child { font-weight: 750; }
.cancellation { color: var(--red); }
.card-name { display: inline-flex; align-items: center; gap: 7px; color: var(--secondary); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.dot.samsung { background: var(--samsung); }
.dot.kb { background: var(--kb); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 860px) {
  .card-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .month-total { grid-column: 1 / -1; }
}
@media (max-width: 639px) {
  .shell { width: calc(100% - 32px); }
  main { padding-block: 24px calc(84px + env(safe-area-inset-bottom)); }
  .page-heading { display: grid; gap: 14px; margin-bottom: 16px; }
  .card-totals { gap: 8px; margin-bottom: 16px; }
  .card-total { padding: 8px 5px 8px 8px; column-gap: 2px; }
  .month-total { padding: 10px 12px; }
  .card-total { grid-template-columns: minmax(0, 1fr); }
  .card-total .export-menu { position: absolute; right: 3px; bottom: 2px; }
  .card-summary strong { display: flex; align-items: center; min-height: 40px; padding-right: 42px; }
  .card-total .export-feedback { padding-right: 42px; }
  .card-identity { column-gap: 4px; }
  .issuer-logo { width: 70px; height: 16px; }
  .issuer-logo img { width: 75px; }
  .kb-card .issuer-logo img { width: 80px; }
  .card-total .total-label { font-size: 13px; }
  .ledger-heading, .controls { padding-inline: 12px; }
  .ledger-heading { padding-top: 10px; }
  #ledger-title { font-size: 20px; }
  .controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding-block: 8px 12px; }
  .card-filter { width: max-content; }
  .search { width: 100%; }
  th, td { padding: 11px 4px; font-size: 12px; }
  th:first-child, td:first-child { width: 20%; padding-left: 8px; }
  th:nth-child(3), td:nth-child(3) { width: 24%; }
  th:last-child, td:last-child { width: 24%; padding-right: 8px; }
  .card-name { gap: 4px; }
  .dot { width: 5px; height: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .card-filter button { transition: none; }
}

.clipboard-field { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; font-size: 16px; }


.stats-compare { margin-bottom: 16px; overflow: hidden; }
.stats-section-heading, .stats-chart { padding: 18px 20px; }
.stats-section-heading h2, .chart-heading h2 { font-size: 22px; letter-spacing: -.03em; }
.stats-section-heading p, .chart-heading p, .chart-legend, .trend-empty { color: var(--muted); font-size: 13px; }
.comparison th, .comparison td { width: 25%; text-align: right; font-variant-numeric: tabular-nums; }
.comparison th:first-child { text-align: left; }
.comparison tbody th { background: var(--surface); border-top: 1px solid var(--line); color: var(--secondary); }
.comparison tbody tr:first-child :is(th, td) { background: var(--hero); font-weight: 750; }
.comparison .dot { display: inline-block; margin-right: 6px; vertical-align: .1em; }
.comparison td.increase { color: var(--red); }
.comparison td.decrease { color: var(--blue-text); }
.chart-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.trend-period select { min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--control); color: var(--ink); font: inherit; font-size: 16px; }
.chart-legend, .chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend { gap: 14px; margin-top: 12px; }
#trend { display: block; width: 100%; height: clamp(190px, 32vw, 285px); margin-top: 12px; }
.trend-empty { padding-block: 24px; }
.trend-details { margin-top: 8px; }
.trend-details summary { min-height: 44px; align-content: center; color: var(--blue-text); cursor: pointer; font-size: 14px; }
.trend-values :is(th, td) { text-align: right; font-variant-numeric: tabular-nums; }
.trend-values :is(th, td):first-child { text-align: left; }
.trend-values tbody th { background: var(--surface); border-top: 1px solid var(--line); }
#stats-retry { margin-top: 8px; }
@media (max-width: 639px) {
  .stats-section-heading, .stats-chart { padding: 14px 12px; }
  .stats-section-heading h2, .chart-heading h2 { font-size: 19px; }
  .comparison .dot { display: none; }
  .comparison th, .comparison td { overflow-wrap: anywhere; }
}

#table .payment-type { color: var(--muted); }
#table :is(th, td):first-child { width: 17%; }
#table :is(th, td):nth-child(3) { width: 20%; }
#table :is(th, td):nth-child(4) { width: 16%; }
#table :is(th, td):last-child { width: 20%; }
@media (max-width: 639px) {
  #table :is(th, td):nth-child(3) { width: 21%; }
  #table :is(th, td):nth-child(4) { width: 19%; }
  #table :is(th, td):last-child { width: 22%; }
}

@media (max-width: 375px) {
  .issuer-logo { width: 62px; }
  .issuer-logo img { width: 68px; }
  .kb-card .issuer-logo img { width: 70px; }
}
