:root {
    color-scheme: light;
    --page-bg: #f5f7f8;
    --surface: #ffffff;
    --text: #17222e;
    --muted: #68727d;
    --line: #e8edf0;
    --green: #63c849;
    --green-dark: #183e24;
    --danger: #ba2d3c;
    --shadow: 0 22px 52px rgba(20, 35, 27, 0.13);
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-bottom: 8rem;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--page-bg);
    color: var(--text);
    font-family: "Manrope", "Segoe UI", sans-serif;
    font-size: 1rem;
    line-height: 1.5;
}

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

.app-shell {
    width: min(100%, 46rem);
    min-height: 100vh;
    margin: 0 auto;
    padding: 1.25rem 1.25rem 8.5rem;
}

.card-label, .days-left, .card-plan { margin: 0; }

.page-section { scroll-margin-top: 1.25rem; }

.account-card {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: 23.5rem;
    padding: clamp(1.5rem, 5vw, 2.75rem);
    border-radius: clamp(1.75rem, 6vw, 3rem);
    background:
        radial-gradient(circle at 14% 18%, rgba(136, 231, 96, 0.72), transparent 34%),
        linear-gradient(125deg, #55a83d 0%, #275c31 49%, #061009 100%);
    color: #ffffff;
    box-shadow: var(--shadow);
}

.account-card::after {
    position: absolute;
    z-index: -1;
    right: -25%;
    bottom: -45%;
    width: 70%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.18);
    content: "";
}

.account-card__top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(0.85rem, 3vw, 1.5rem);
}

.client-identity { min-width: 0; }

.client-identity h1 {
    overflow: hidden;
    margin: 0 0 0.2rem;
    font-size: clamp(1.25rem, 5.3vw, 2rem);
    font-weight: 800;
    letter-spacing: 0.015em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.client-identity p {
    overflow: hidden;
    margin: 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: clamp(0.85rem, 3.7vw, 1.05rem);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-button {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #ffffff;
    transition: background 160ms ease, transform 160ms ease;
}

.icon-button:hover, .icon-button:focus-visible {
    background: rgba(255, 255, 255, 0.13);
    outline: none;
}

.icon-button:active { transform: rotate(35deg) scale(0.96); }

.icon-button svg {
    width: 1.9rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.account-card__summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(9.5rem, auto);
    align-items: end;
    gap: 1.5rem;
    margin-top: clamp(4rem, 12vw, 6rem);
}

.card-label {
    color: rgba(255, 255, 255, 0.78);
    font-size: clamp(0.9rem, 3.6vw, 1.05rem);
}

.amount {
    margin: 0.3rem 0 0;
    font-size: clamp(3.25rem, 14vw, 5.4rem);
    font-weight: 700;
    letter-spacing: -0.075em;
    line-height: 1;
}

.expiry-block { text-align: right; }

.expiry-block > p:first-child {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: clamp(0.85rem, 3.6vw, 1.05rem);
}

.expiry-block strong { color: #ffffff; font-weight: 800; }
.days-left { color: rgba(255, 255, 255, 0.78); font-size: 0.9rem; }
.days-left.is-expired { color: #ffd4d9; }

.pay-button {
    min-width: 10.5rem;
    min-height: 3.5rem;
    margin-top: 1.35rem;
    padding: 0.75rem 1.5rem;
    border: 2px solid #ffffff;
    border-radius: 1.2rem;
    background: rgba(0, 0, 0, 0.06);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 800;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.pay-button:not(:disabled):hover, .pay-button:not(:disabled):focus-visible {
    background: #ffffff;
    color: var(--green-dark);
    outline: none;
}

.pay-button:not(:disabled):active { transform: scale(0.98); }
.pay-button:disabled { cursor: not-allowed; opacity: 0.48; }

.card-plan {
    margin-top: 0.75rem;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.84rem;
}

.card-plan strong { color: #ffffff; font-weight: 800; }

.client-identity .card-plan { margin-top: 0.35rem; }

.qr-loading {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
    margin-top: 0.85rem;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.84rem;
}

.content-section, .history-section { padding: clamp(2rem, 7vw, 3.25rem) 0 0; }

.content-section h2, .history-section h2 {
    margin: 0 0 1.35rem;
    font-size: clamp(1.35rem, 5vw, 1.75rem);
    font-weight: 800;
    letter-spacing: -0.035em;
}

.portal-message {
    margin-top: 1rem;
    padding: 1rem 1.1rem;
    border-radius: 1rem;
}

.payment-details {
    margin-top: 2rem;
    padding: 1.4rem;
    border: 1px solid var(--line);
    border-radius: 1.5rem;
    background: var(--surface);
}

.portal-message h2, .payment-details h2 { margin-bottom: 0.75rem; font-size: 1.15rem; }
.portal-message p, .instructions { margin: 0; white-space: pre-line; }
.portal-message p { color: var(--bs-danger-text, #58151c); }
.home-recent-history { padding-top: clamp(2rem, 7vw, 3.25rem); }
.home-recent-history .section-heading { margin-bottom: 0.5rem; }
.home-recent-history .section-heading h2 { margin: 0; font-size: clamp(1.35rem, 5vw, 1.75rem); font-weight: 800; letter-spacing: -0.035em; }
.home-recent-history .history-count { margin-bottom: 0; }

.provider-section { padding-top: 0.5rem; }

.provider-hero {
    position: relative;
    overflow: hidden;
    border-radius: 1.75rem;
    background: transparent;
}

.provider-image { display: block; width: 100%; height: auto; border-radius: inherit; object-fit: contain; }
.home-provider-hero { margin-bottom: 1rem; }
.history-provider-hero { margin-bottom: 1rem; }
.provider-heading { padding: 1.65rem 0 1rem; }
.provider-kicker { margin: 0 0 0.35rem; color: var(--muted); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.provider-heading h2 { margin: 0; font-size: clamp(1.6rem, 6vw, 2.15rem); font-weight: 800; letter-spacing: -0.045em; }
.provider-name { margin: 0.3rem 0 0; color: var(--muted); font-size: 1rem; }
.provider-info-list { overflow: hidden; border: 1px solid var(--line); border-radius: 1.35rem; background: var(--surface); }
.provider-info-item { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.provider-info-item:last-child { border-bottom: 0; }
.provider-info-item > span { color: var(--muted); font-size: 0.9rem; }
.provider-info-item > strong { text-align: right; overflow-wrap: anywhere; }
.provider-info-item--instructions { display: grid; gap: 0.45rem; }
.provider-info-item--instructions p { margin: 0; color: var(--text); white-space: pre-line; }

.notice {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.notice--error { background: #fff0f2; color: var(--danger); }

.payment-channels {
    display: grid;
    gap: 0.75rem;
    margin: 1.2rem 0;
}

.payment-channel, .payment-options li {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 3.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: #f8faf9;
    color: var(--text);
    font-weight: 700;
}

.payment-channel img { width: 2.3rem; height: 2.3rem; object-fit: contain; }
.payment-options { display: grid; gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
.payment-form { display: grid; gap: 1rem; margin-top: 1.2rem; }

.payment-form label {
    display: grid;
    gap: 0.45rem;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 700;
}

.payment-form input {
    width: 100%;
    min-height: 3.25rem;
    padding: 0.75rem 0.95rem;
    border: 1px solid #cfd7dc;
    border-radius: 0.9rem;
    background: #ffffff;
    color: var(--text);
    font-size: 1rem;
    outline: none;
}

.payment-form input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(99, 200, 73, 0.14); }
.payment-form input:disabled { background: #eef2f0; color: #56615b; }

.primary-button, .secondary-button {
    min-height: 3.15rem;
    padding: 0.72rem 1.25rem;
    border-radius: 0.95rem;
    font-weight: 800;
}

.primary-button { border: 1px solid var(--green-dark); background: var(--green-dark); color: #ffffff; }
.secondary-button { border: 1px solid #b9c7be; background: #ffffff; color: var(--green-dark); }

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.section-heading h2 { margin-top: 0.2rem; }

.history-count {
    display: grid;
    min-width: 2rem;
    height: 2rem;
    margin-bottom: 1.35rem;
    padding: 0 0.55rem;
    place-items: center;
    border-radius: 999px;
    background: #e8f5e4;
    color: #327229;
    font-size: 0.8rem;
    font-weight: 800;
}

.history-filter-shell {
    position: relative;
    margin: 0.85rem 0 1.1rem;
}

.history-date-toggle {
    display: grid;
    width: 100%;
    min-height: 4.25rem;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border: 1px solid #dbe4de;
    border-radius: 1.15rem;
    background: #ffffff;
    color: var(--text);
    text-align: left;
    box-shadow: 0 8px 24px rgba(23, 54, 35, 0.07);
}

.history-date-toggle > svg:first-child {
    width: 1.45rem;
    fill: none;
    stroke: var(--green-dark);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.history-date-toggle span { display: grid; gap: 0.12rem; }
.history-date-toggle small { color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.history-date-toggle strong { font-size: 0.94rem; }

.history-date-chevron {
    width: 1.25rem;
    fill: none;
    stroke: #718078;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    transition: transform 160ms ease;
}

.history-date-toggle[aria-expanded="true"] .history-date-chevron { transform: rotate(180deg); }
.history-date-toggle:focus-visible, .history-date-filter input:focus-visible, .history-date-filter button:focus-visible {
    outline: 3px solid rgba(99, 200, 73, 0.28);
    outline-offset: 2px;
}

.history-date-filter {
    display: grid;
    gap: 1rem;
    margin-top: 0.6rem;
    padding: 1rem;
    border: 1px solid #dbe4de;
    border-radius: 1.2rem;
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(21, 41, 30, 0.12);
}

.history-date-filter[hidden] { display: none; }

.history-date-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: end;
    gap: 0.65rem;
}

.history-date-fields label { display: grid; gap: 0.42rem; }
.history-date-fields label > span { color: var(--muted); font-size: 0.74rem; font-weight: 800; }

.history-date-fields input {
    width: 100%;
    min-width: 0;
    min-height: 3rem;
    padding: 0.65rem 0.72rem;
    border: 1px solid #ced9d2;
    border-radius: 0.85rem;
    background: #f9fbfa;
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
}

.history-date-separator { padding-bottom: 0.78rem; color: #91a097; }

.history-date-presets { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.history-date-presets button {
    min-height: 2.25rem;
    padding: 0.45rem 0.7rem;
    border: 1px solid #d7e4d8;
    border-radius: 999px;
    background: #f2f8f0;
    color: #386b35;
    font-size: 0.74rem;
    font-weight: 800;
}

.history-date-actions { display: flex; justify-content: flex-end; gap: 0.65rem; }
.history-date-actions button { min-height: 2.75rem; padding: 0.6rem 1rem; border-radius: 0.82rem; font-weight: 800; }
.history-date-clear { border: 0; background: transparent; color: #647169; }
.history-date-apply { border: 1px solid var(--green-dark); background: var(--green-dark); color: #ffffff; }
.history-date-apply:disabled { cursor: wait; opacity: 0.65; }
.history-date-error { margin: 0; color: var(--danger); font-size: 0.78rem; font-weight: 700; }
.history-range-summary { min-height: 1.2rem; margin: -0.35rem 0 0.75rem; color: var(--muted); font-size: 0.78rem; }

.history-list { border-top: 1px solid var(--line); }

.history-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    padding: 1.35rem 0;
    border-bottom: 1px solid var(--line);
}

.history-reference {
    overflow: hidden;
    margin: 0 0 0.3rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-date, .history-description { margin: 0; color: var(--muted); font-size: 0.86rem; }
.history-description { margin-top: 0.2rem; }
.history-meta { min-width: 5.6rem; text-align: right; }
.history-amount { margin: 0 0 0.35rem; font-weight: 800; }

.history-status {
    color: #18a34a;
    font-size: 0.73rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.history-status[data-status="pending"] { color: #a96800; }
.history-status[data-status="failed"], .history-status[data-status="declined"] { color: var(--danger); }

.empty-state {
    display: grid;
    justify-items: center;
    gap: 0.35rem;
    padding: 2.5rem 1rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    text-align: center;
}

.empty-state svg {
    width: 2.5rem;
    margin-bottom: 0.35rem;
    fill: none;
    stroke: #9ca7ad;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
}

.empty-state strong { color: var(--text); }
.empty-state span { font-size: 0.86rem; }

@media (max-width: 430px) {
    .history-date-fields { grid-template-columns: 1fr; }
    .history-date-separator { display: none; }
    .history-date-actions button { flex: 1; }
}

.bottom-nav {
    position: fixed;
    z-index: 100;
    right: max(1rem, calc((100vw - 43.5rem) / 2));
    bottom: max(1rem, env(safe-area-inset-bottom));
    left: max(1rem, calc((100vw - 43.5rem) / 2));
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    padding: 0.55rem;
    border: 1px solid rgba(220, 228, 224, 0.9);
    border-radius: 1.7rem;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 16px 42px rgba(21, 41, 30, 0.2);
    backdrop-filter: blur(16px);
}

.bottom-nav .nav-link {
    display: flex;
    min-height: 4.1rem;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    border-radius: 1.2rem;
    color: #53616a;
    font-size: 0.76rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 160ms ease, color 160ms ease;
}

.bottom-nav .nav-link.active { background: #eef8eb; color: #55b43d; }

.bottom-nav svg {
    width: 1.55rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.full-page-payment {
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: #ffffff;
}

.full-page-payment iframe { display: block; width: 100%; height: 100%; border: 0; }
.status-modal { border: 0; border-radius: 1.5rem; }
.modal-kicker { margin: 0 0 0.25rem; color: var(--muted); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.modal-helper { margin: -0.25rem 0 0.25rem; color: var(--muted); font-size: 0.88rem; }

.payment-status-icon {
    display: grid;
    width: 4.75rem;
    height: 4.75rem;
    place-items: center;
    border-radius: 50%;
    font-size: 2rem;
    font-weight: 800;
}

.payment-status-icon-success { background: rgba(31, 155, 98, 0.12); color: #1f9b62; }
.payment-status-icon-failed { background: rgba(211, 72, 90, 0.12); color: #d3485a; }
.status-title { margin: 0 0 0.55rem; font-size: 1.45rem; font-weight: 800; }
.status-message, .status-meta { color: var(--muted); }

@media (max-width: 520px) {
    .app-shell { padding: 1rem 1rem 8rem; }
    .account-card { min-height: 21rem; padding: 1.35rem; }
    .account-card__summary { grid-template-columns: 1fr auto; gap: 0.75rem; margin-top: 4.25rem; }
    .pay-button { min-width: 8.5rem; min-height: 3.2rem; }
}

@media (max-width: 390px) {
    .icon-button { position: absolute; top: 1.1rem; right: 1.1rem; }
    .client-identity { padding-right: 2.4rem; }
    .account-card__summary { align-items: start; grid-template-columns: 1fr; margin-top: 3rem; }
    .expiry-block { display: grid; grid-template-columns: 1fr auto; align-items: center; text-align: left; }
    .days-left { grid-column: 1; }
    .pay-button { grid-row: 1 / span 2; grid-column: 2; margin: 0; }
}

@media (max-width: 430px) {
    .bottom-nav .nav-link { gap: 0.3rem; font-size: 0.68rem; }
    .bottom-nav svg { width: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
