:root {
  color-scheme: light;
  --brand: #58080d;
  --canvas: #EFEFEF;
  --surface: #d0c2b0;
  --surface-strong: #bca395;
  --surface-accent: #a8847a;
  --ink: #24211f;
  --muted: #423936;
  --line: rgba(88, 8, 13, .18);
  --line-strong: rgba(88, 8, 13, .34);
  --on-brand: #e4e1cc;
  --radius-control: 10px;
  --radius-panel: 12px;
  --radius-pill: 999px;
  --ease-state: cubic-bezier(.16, 1, .3, 1);
  font-family: Manrope, Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Manrope, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

a,
button,
input {
  -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 450, "GRAD" 0, "opsz" 24;
}

.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 0 16px 108px;
}

.app-header {
  display: flex;
  height: 76px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--brand);
  text-decoration: none;
}

.brand-wordmark {
  display: block;
  width: 104px;
  height: auto;
  max-height: 24px;
  object-fit: contain;
}

.brand-auth .brand-wordmark {
  width: 126px;
  max-height: 30px;
}

.profile-chip {
  display: flex;
  max-width: 56%;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.profile-chip .material-symbols-outlined {
  color: var(--brand);
  font-size: 17px;
}

.profile-chip b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
}

.page-heading {
  padding: 27px 2px 25px;
}

.page-heading h1 {
  margin: 8px 0 0;
  color: var(--brand);
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -.03em;
}

.page-heading > p:last-child {
  max-width: 65ch;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.timeline {
  display: grid;
  gap: 22px;
}

.day-group {
  overflow: hidden;
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.day-group h2 {
  margin: 0;
  padding: 16px 18px 13px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.transaction-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 72px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: transparent;
}

.transaction-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: var(--radius-control);
  background: var(--surface-strong);
  color: var(--ink);
}

.transaction-icon.payment {
  background: var(--surface-accent);
}

.transaction-icon .material-symbols-outlined {
  font-size: 19px;
}

.transaction-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.transaction-main strong,
.transaction-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-main strong {
  font-size: 15px;
}

.transaction-main small {
  color: var(--muted);
  font-size: 12px;
}

.transaction-amount {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.transaction-amount span {
  color: var(--muted);
  font-size: 11px;
}

.transaction-amount b {
  color: var(--brand);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-state {
  padding: 32px 18px;
  color: var(--muted);
  text-align: center;
  font-size: 15px;
}

.empty-state.card-empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.empty-state .material-symbols-outlined {
  display: block;
  margin-bottom: 8px;
  color: var(--brand);
  font-size: 28px;
}

.auth-body {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 18px;
  background: var(--brand);
}

.auth-card {
  width: min(100%, 450px);
  min-height: 600px;
  padding: 30px;
  border-radius: var(--radius-panel);
  background: var(--canvas);
  color: var(--ink);
}

.auth-copy {
  margin-top: 78px;
}

.auth-card h1 {
  margin: 11px 0 0;
  color: var(--ink);
  font-size: 42px;
  line-height: 1.05;
  letter-spacing: -.035em;
}

.auth-card h1 em {
  color: var(--brand);
  font-family: inherit;
  font-weight: 700;
}

.auth-copy > p:last-child {
  max-width: 320px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.telegram-login-widget {
  display: flex;
  justify-content: center;
  min-height: 48px;
  margin-top: 38px;
}

.telegram-qr-login {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.telegram-qr-login__title {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.telegram-qr-login__copy,
.telegram-qr-login__status {
  margin: 7px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.telegram-qr-login__code {
  display: block;
  width: 132px;
  height: 132px;
  margin: 14px auto 0;
  padding: 8px;
  border-radius: 12px;
  background: #fff;
}

.telegram-qr-login .secondary-button {
  margin-top: 14px;
}

.form-error {
  margin: 30px 0 0;
  color: var(--brand);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.auth-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.auth-note a {
  color: var(--brand);
  font-weight: 700;
  text-underline-offset: 3px;
}

.secondary-button {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 14px 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--brand);
  font: 800 15px Manrope, Arial, sans-serif;
  text-decoration: none;
  transition: background 180ms var(--ease-state), transform 180ms var(--ease-state);
}

.secondary-button:hover {
  background: var(--surface-strong);
}

.secondary-button:active {
  transform: scale(.98);
}

.waiting-card {
  display: flex;
  flex-direction: column;
}

.waiting-card > .eyebrow {
  margin-top: 82px;
}

.waiting-card h1 {
  font-size: 41px;
}

.waiting-card > p:last-of-type {
  max-width: 330px;
  margin: 18px 0 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

[hidden] {
  display: none !important;
}

@media (min-width: 700px) {
  .app-shell {
    padding: 0 32px 100px;
  }

  .app-header {
    height: 84px;
  }

  .transaction-card {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    padding-inline: 20px;
  }
}

@media (max-width: 420px) {
  .auth-card {
    min-height: 0;
    padding: 26px 24px;
  }

  .auth-copy {
    margin-top: 62px;
  }

  .auth-card h1 {
    font-size: 38px;
  }

  .transaction-card {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    padding-inline: 14px;
  }
}

/* Header Controls & Refresh Button */
.header-controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 70%;
}

.header-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--brand);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

.header-refresh-btn:hover {
  background: rgba(88, 8, 13, 0.06);
  border-color: var(--brand);
}

.header-refresh-btn:active {
  transform: scale(0.94);
}

.header-refresh-btn .material-symbols-outlined {
  font-size: 20px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.header-refresh-btn.is-spinning .material-symbols-outlined,
.pull-to-refresh-indicator.is-refreshing .pull-to-refresh-indicator__icon {
  animation: spin-refresh 0.75s linear infinite;
}

@keyframes spin-refresh {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Pull to Refresh Indicator */
.pull-to-refresh-indicator {
  position: fixed;
  top: -56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
}

.pull-to-refresh-indicator.is-active,
.pull-to-refresh-indicator.is-refreshing {
  opacity: 1;
}

.pull-to-refresh-indicator__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--brand);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(88, 8, 13, 0.15);
}

.pull-to-refresh-indicator__icon {
  font-size: 22px;
  transition: transform 0.1s linear;
}

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