:root {
  --bg: #050505;
  --surface: #101010;
  --surface-raised: #171717;
  --text: #f5f5f3;
  --muted: #7d7d79;
  --soft: #b8b8b2;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .17);
  --danger: #d77171;
  font-family: "Segoe UI Variable Text", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 90% -5%, rgba(255, 255, 255, .09), transparent 22rem),
    radial-gradient(circle at -15% 55%, rgba(255, 255, 255, .035), transparent 24rem),
    var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; }
button { color: inherit; }
button, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .72);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(26px, env(safe-area-inset-top)) 18px calc(116px + env(safe-area-inset-bottom));
}

.topbar, .sheet-header, .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-symbol {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: linear-gradient(145deg, #242424, #0a0a0a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 12px 30px rgba(0, 0, 0, .35);
  font-family: "Segoe UI Variable Display", Inter, sans-serif;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.04em;
}

h1, h2, p { margin: 0; }
h1 {
  margin-top: 5px;
  font-size: clamp(32px, 8.5vw, 45px);
  font-weight: 720;
  letter-spacing: -.055em;
  line-height: .88;
}
h1 span {
  color: var(--soft);
  font-size: .93em;
  font-weight: 360;
  font-style: normal;
  letter-spacing: -.045em;
}
h2 { font-size: 21px; font-weight: 650; letter-spacing: -.035em; }
.eyebrow { color: var(--muted); font-size: 8px; font-weight: 650; letter-spacing: .17em; text-transform: uppercase; }

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, .045);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  cursor: pointer;
  transition: background .18s, transform .18s;
}
.icon-button:active { background: rgba(255, 255, 255, .11); transform: scale(.95); }
.icon-button svg, .fab svg { width: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.summary {
  position: relative;
  overflow: hidden;
  margin-top: 34px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    radial-gradient(circle at 88% 15%, rgba(255, 255, 255, .10), transparent 12rem),
    linear-gradient(145deg, #1a1a1a, #0d0d0d 68%);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .36), inset 0 1px 0 rgba(255, 255, 255, .05);
}
.total-card {
  position: relative;
  min-height: 204px;
  padding: 25px 25px 23px;
  overflow: hidden;
}
.card-label { color: #a3a39e; font-size: 9px; font-weight: 650; letter-spacing: .13em; }
.total-card strong {
  display: block;
  margin-top: 34px;
  font-size: clamp(43px, 12vw, 62px);
  font-weight: 560;
  line-height: .95;
  letter-spacing: -.075em;
  font-variant-numeric: tabular-nums lining-nums;
}
.total-card strong.multi-currency { max-width: calc(100% - 88px); font-size: clamp(27px, 7vw, 42px); line-height: 1.15; }
.total-card p { margin-top: 10px; color: var(--muted); font-size: 11px; }
.total-arrow {
  position: absolute;
  top: 53px;
  right: 25px;
  display: grid;
  width: 80px;
  height: 80px;
  place-items: center;
  isolation: isolate;
  border: 0;
  border-radius: 50%;
  background: conic-gradient(from -38deg, rgba(247, 247, 243, .88) 0 72deg, rgba(255, 255, 255, .10) 72deg 360deg);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .2);
}
.total-arrow::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 2px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: inherit;
  background: linear-gradient(145deg, #202020, #121212);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
}
.total-arrow span {
  position: relative;
  margin-top: -8px;
  font-family: "Segoe UI Variable Display", Inter, sans-serif;
  font-size: 24px;
  font-weight: 330;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -.06em;
  line-height: 1;
}
.total-arrow small {
  position: absolute;
  bottom: 18px;
  color: #888883;
  font-size: 7px;
  font-weight: 600;
  letter-spacing: .12em;
  line-height: 1;
  text-transform: uppercase;
}

.summary-meta { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.metric-card { display: grid; min-height: 83px; padding: 16px 24px; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; border-right: 1px solid var(--line); }
.metric-card:last-child { border-right: 0; }
.metric-card small { grid-column: 1 / -1; color: var(--muted); font-size: 7px; font-weight: 650; letter-spacing: .14em; }
.metric-card b {
  margin-top: 2px;
  font-family: "Segoe UI Variable Display", "SF Pro Display", Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 28px;
  font-weight: 300;
  font-style: normal;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -.06em;
  line-height: 1;
}
.metric-card span { align-self: end; margin: 0 0 5px 7px; color: var(--soft); font-size: 9px; }

.week-panel {
  margin-top: 22px;
  padding: 13px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, .025);
}
.week-caption { display: flex; padding: 0 10px 10px; align-items: flex-end; justify-content: space-between; gap: 12px; }
.week-caption > div { display: grid; gap: 4px; }
.week-caption small { color: #666662; font-size: 6px; font-weight: 700; letter-spacing: .14em; }
.week-caption strong { font-size: 13px; font-weight: 580; letter-spacing: -.025em; }
.week-caption > span { padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: #777772; font-size: 8px; font-variant-numeric: tabular-nums lining-nums; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.week-strip > span { display: flex; min-width: 0; height: 49px; align-items: center; justify-content: center; flex-direction: column; border-radius: 13px; }
.week-strip small { color: #656561; font-size: 6px; font-weight: 700; letter-spacing: .06em; }
.week-strip b { margin-top: 4px; color: #8d8d88; font-size: 13px; font-weight: 440; font-variant-numeric: tabular-nums lining-nums; letter-spacing: -.02em; }
.week-strip .today { background: #f1f1ed; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.week-strip .today small { color: #666; font-size: 6px; }
.week-strip .today b { color: #111; font-size: 15px; }

.section-heading { margin: 35px 2px 15px; }
.section-heading h2 { margin-top: 5px; }
.text-button { display: flex; align-items: center; gap: 8px; border: 0; padding: 8px 0 8px 13px; background: transparent; color: var(--soft); font-size: 10px; font-weight: 550; cursor: pointer; }
.text-button b { display: grid; width: 26px; height: 26px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--text); font-size: 16px; font-weight: 300; }

.subscription-list, .loading-list { display: grid; gap: 10px; }
.subscription-card {
  position: relative;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  min-height: 111px;
  padding: 15px 15px 12px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .018));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 14px 35px rgba(0, 0, 0, .16);
  backdrop-filter: blur(16px);
}
.brand-mark {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: linear-gradient(145deg, #292929, #121212) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .09);
  color: #e7e7e2 !important;
  font-family: "Segoe UI Variable Display", Inter, sans-serif;
  font-size: 16px;
  font-weight: 620;
  font-style: normal;
  text-transform: uppercase;
}
.card-main { min-width: 0; }
.card-name { overflow: hidden; font-size: 14px; font-weight: 620; letter-spacing: -.015em; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { margin-top: 6px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.card-side { min-width: 86px; text-align: right; }
.card-amount { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.due-badge { display: inline-block; margin-top: 7px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; color: #92928d; font-size: 8px; }
.due-badge.soon { border-color: #deded8; background: #e9e9e5; color: #111; }
.card-actions { grid-column: 2 / -1; display: flex; justify-content: flex-end; gap: 16px; margin-top: -3px; }
.card-action { min-height: 28px; border: 0; padding: 6px 0 4px; background: transparent; color: #858580; font-size: 9px; cursor: pointer; }
.card-action.delete { color: #9d6767; }

.skeleton { height: 111px; border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(100deg, #0d0d0d 20%, #191919 45%, #0d0d0d 70%); background-size: 300% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position-x: -150%; } }

.empty-state, .error-state { padding: 48px 25px; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); text-align: center; }
.empty-icon { display: grid; width: 66px; height: 66px; margin: 0 auto 20px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface-raised); }
.empty-icon svg { width: 31px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }
.empty-state p, .error-state p { max-width: 330px; margin: 10px auto 23px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.primary-button, .secondary-button { min-height: 51px; padding: 0 22px; border-radius: 999px; font-size: 11px; font-weight: 650; cursor: pointer; }
.primary-button { border: 1px solid #f5f5f2; background: #f5f5f2; color: #090909; }
.secondary-button { border: 1px solid var(--line-strong); background: transparent; color: var(--text); }

.fab {
  position: fixed;
  z-index: 10;
  right: max(18px, calc((100vw - 684px) / 2));
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex;
  width: min(calc(100vw - 36px), 275px);
  height: 56px;
  padding: 0 19px;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 999px;
  background: #f1f1ed;
  box-shadow: 0 16px 45px rgba(0, 0, 0, .55), inset 0 -1px 0 rgba(0, 0, 0, .12);
  color: #080808;
  cursor: pointer;
}
.fab span { font-size: 11px; font-weight: 670; }
.fab svg { width: 19px; }

.sheet-backdrop { position: fixed; z-index: 20; inset: 0; background: rgba(0, 0, 0, .78); backdrop-filter: blur(8px); opacity: 1; transition: opacity .2s ease; }
.sheet {
  position: fixed;
  z-index: 21;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(100%, 720px);
  max-height: min(93vh, 780px);
  margin: 0 auto;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 31px 31px 0 0;
  background: #0e0e0e;
  box-shadow: 0 -30px 90px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .045);
  transform: translateY(105%);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 42px; height: 4px; margin: 3px auto 20px; border-radius: 999px; background: #343434; }
.sheet-header { margin-bottom: 24px; }
.sheet-header h2 { margin-top: 5px; font-size: 26px; font-weight: 580; }

form { display: grid; gap: 18px; }
label, fieldset, .form-field { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
label > span, legend, .field-label { color: #8d8d88; font-size: 9px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; }
legend { margin-bottom: 8px; }
input { width: 100%; min-width: 0; height: 52px; padding: 0 14px; border: 1px solid var(--line); border-radius: 15px; outline: 0; background: #171717; color: var(--text); font-variant-numeric: tabular-nums lining-nums; transition: border-color .15s, background .15s, box-shadow .15s; }
input:focus { border-color: rgba(255, 255, 255, .34); background: #1b1b1b; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035); }
input::placeholder { color: #62625f; opacity: 1; }
input[type="date"] { color-scheme: dark; }
.form-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 12px; }
.input-with-currency { position: relative; }
.input-with-currency > input[type="text"] { padding-right: 120px; }
.currency-switch {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  width: 106px;
  height: 38px;
  padding: 3px;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f0f0f;
}
.currency-option, .period-switch button {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #777772;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.currency-option:active, .period-switch button:active { transform: scale(.94); }
.currency-option.is-active, .period-switch button.is-active {
  background: #eeeeea;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .32);
  color: #111;
}
.interval-row { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; }
.period-switch {
  display: grid;
  height: 52px;
  padding: 4px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #171717;
}
.period-switch button { min-width: 0; padding: 0 5px; font-size: 9px; }
.date-trigger {
  display: flex;
  width: 100%;
  height: 52px;
  padding: 0 14px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #171717;
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums lining-nums;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.date-trigger[aria-expanded="true"] { border-color: rgba(255, 255, 255, .34); background: #1b1b1b; }
.date-trigger svg, .calendar-nav svg { width: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.65; }
.date-trigger svg { color: #c7c7c2; }
.date-field { position: relative; }
.date-picker {
  position: fixed;
  z-index: 24;
  top: 50%;
  left: 50%;
  display: grid;
  width: min(calc(100% - 40px), 390px);
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: linear-gradient(145deg, #191919, #101010);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .48), 0 24px 60px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 255, 255, .045);
  transform: translate(-50%, -50%);
}
.calendar-topbar { display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; }
.calendar-topbar strong { text-align: center; font-size: 14px; font-weight: 620; letter-spacing: -.02em; text-transform: capitalize; }
.calendar-nav {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, .025);
  color: #a4a49f;
  cursor: pointer;
}
.calendar-nav:active { background: rgba(255, 255, 255, .09); transform: scale(.95); }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.calendar-weekdays { margin: 9px 0 4px; }
.calendar-weekdays span { color: #5f5f5b; font-size: 7px; font-weight: 700; text-align: center; }
.calendar-day {
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #b0b0aa;
  font-size: 11px;
  font-variant-numeric: tabular-nums lining-nums;
  cursor: pointer;
}
.calendar-day.outside { color: #535350; }
.calendar-day.today:not(.selected) { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); color: #f0f0eb; }
.calendar-day.selected { background: #efefeb; box-shadow: 0 7px 18px rgba(0, 0, 0, .35); color: #111; font-weight: 700; }
.calendar-day:disabled { opacity: .2; cursor: not-allowed; }
.calendar-today {
  justify-self: end;
  margin-top: 8px;
  padding: 8px 4px 2px 12px;
  border: 0;
  background: transparent;
  color: #bdbdb7;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}
.form-error { padding: 11px 13px; border: 1px solid rgba(215, 113, 113, .35); border-radius: 13px; background: rgba(215, 113, 113, .08); color: #dd8989; font-size: 11px; }
.save-button { width: 100%; }
.save-button:disabled { opacity: .55; cursor: wait; }

.toast { position: fixed; z-index: 40; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom)); left: 18px; width: fit-content; max-width: calc(100% - 36px); margin: auto; padding: 12px 17px; border: 1px solid var(--line-strong); border-radius: 999px; background: #ededE9; box-shadow: 0 14px 40px rgba(0, 0, 0, .5); color: #111; font-size: 10px; opacity: 0; pointer-events: none; transform: translateY(15px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.hidden { display: none !important; }
.spin { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .app-shell { padding-right: 14px; padding-left: 14px; }
  .brand-symbol { width: 42px; height: 42px; }
  .summary { margin-top: 30px; }
  .total-card { min-height: 195px; padding: 22px 20px 20px; }
  .total-arrow { top: 50px; right: 20px; width: 70px; height: 70px; }
  .metric-card { min-height: 79px; padding: 14px 20px; }
  .week-strip { gap: 2px; }
  .subscription-card { grid-template-columns: 46px minmax(0, 1fr) auto; gap: 11px; padding: 14px 12px 11px; }
  .brand-mark { width: 46px; height: 46px; border-radius: 14px; }
  .card-side { min-width: 79px; }
  .fab { right: 14px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 365px) {
  .total-arrow { right: 14px; width: 64px; height: 64px; }
  .total-arrow span { font-size: 21px; }
  .total-arrow small { bottom: 14px; }
  .week-strip small { font-size: 5px; }
  .week-strip b { font-size: 12px; }
  .section-heading h2 { font-size: 18px; }
  .text-button { font-size: 0; }
  .text-button b { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
