:root {
    --bg: #eef2f7;
    --panel: rgba(255, 255, 255, 0.96);
    --surface: #ffffff;
    --line: rgba(28, 51, 94, 0.12);
    --text: #162033;
    --muted: #61708b;
    --accent: #1f5fbf;
    --accent-strong: #164b99;
    --accent-soft: #e8f0ff;
    --accent-secondary: #ef233c;
    --accent-secondary-soft: #ffe7ea;
    --ok: #146c43;
    --ok-soft: #dff2e8;
    --error: #c62839;
    --error-soft: #ffe5e8;
    --shadow: 0 28px 64px rgba(22, 32, 51, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(239, 35, 60, 0.18), transparent 24%),
        radial-gradient(circle at top right, rgba(31, 95, 191, 0.18), transparent 28%),
        linear-gradient(155deg, #f9fbff, var(--bg));
}

.shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.app-footer {
    margin-top: 14px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.card {
    width: min(100%, 620px);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 30px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.notice--hidden {
    display: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand--login {
    justify-content: center;
    margin-bottom: 24px;
}

.brand__logo {
    display: block;
    width: 210px;
    max-width: 100%;
    height: auto;
}

.brand__logo--hero {
    width: 280px;
}

.brand__name {
    font-size: 18px;
    font-weight: 900;
}

.brand__tag {
    color: var(--muted);
    font-size: 13px;
}

.auth-panel {
    min-height: 560px;
    display: grid;
    align-content: center;
}

.auth-panel.auth-panel--hidden {
    display: none;
}

.auth-card {
    width: min(100%, 390px);
    margin: 0 auto;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--surface);
}

.auth-card h1 {
    margin: 0 0 8px;
    font-size: 30px;
}

.auth-card p {
    margin: 0 0 18px;
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 14px;
}

.hero {
    margin-bottom: 16px;
}

.portal-panel.portal-panel--hidden {
    display: none;
}

.hero__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.session-box {
    padding: 12px 14px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--surface);
    text-align: right;
}

.session-box__label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.session-box__name {
    margin-top: 4px;
    font-size: 16px;
    font-weight: 900;
}

.session-box__action {
    margin-top: 8px;
    border: 0;
    background: transparent;
    color: var(--accent-secondary);
    font-weight: 800;
    cursor: pointer;
    padding: 0;
}

.notice {
    margin: 0 0 16px;
    padding: 14px 16px;
    border-radius: 18px;
    font-weight: 800;
}

.notice--ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.notice--error {
    background: var(--error-soft);
    color: var(--error);
}

.view {
    display: grid;
    gap: 18px;
}

.view.view--hidden,
.view--hidden {
    display: none;
}

.view__intro {
    text-align: center;
    padding: 24px 12px 8px;
}

.view__intro h1 {
    margin: 0 0 8px;
    font-size: clamp(34px, 7vw, 46px);
    line-height: 0.95;
}

.view__intro p {
    margin: 0 auto;
    max-width: 30ch;
    color: var(--muted);
}

.view__head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.view__title h2 {
    margin: 0 0 4px;
    font-size: 24px;
}

.view__title p {
    margin: 0;
    color: var(--muted);
}

.panel,
.result__person,
.result__summary,
.charge-form,
.receipt,
.receipt__ticket {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
}

.panel {
    padding: 22px;
}

.panel--search {
    display: grid;
    gap: 14px;
}

.mode-switch {
    display: inline-grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 6px;
    border-radius: 18px;
    background: var(--accent-soft);
}

.mode-switch__button {
    min-width: 88px;
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
}

.mode-switch__button--active {
    background: #fff;
    color: var(--accent);
    box-shadow: 0 8px 16px rgba(22, 75, 153, 0.10);
}

.label {
    display: grid;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}

.input {
    width: 100%;
    min-height: 58px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font-size: 17px;
}

.input:focus {
    outline: 2px solid rgba(155, 85, 32, 0.18);
    border-color: rgba(155, 85, 32, 0.38);
}

.input--xl {
    text-align: center;
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.input--pin {
    letter-spacing: 0.2em;
}

.input--amount {
    text-align: right;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.button {
    min-height: 56px;
    border: 0;
    border-radius: 18px;
    padding: 14px 18px;
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
}

.button:disabled {
    opacity: 0.68;
    cursor: wait;
}

.button--primary {
    color: #fff;
    background: linear-gradient(145deg, var(--accent), var(--accent-strong));
    box-shadow: 0 12px 24px rgba(31, 95, 191, 0.24);
}

.button--secondary {
    background: #fff;
    color: var(--accent);
    border: 1px solid rgba(31, 95, 191, 0.22);
}

.button--wide {
    width: 100%;
}

.button--success {
    background: var(--ok);
    color: #fff;
}

.result__person {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
}

.avatar {
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: linear-gradient(145deg, var(--accent-secondary), #cc1931);
    color: #fff;
    font-size: 24px;
    font-weight: 900;
}

.person-name {
    font-size: 24px;
    font-weight: 900;
}

.person-meta {
    color: var(--muted);
}

.result__summary {
    padding: 22px;
    background: linear-gradient(160deg, #edf4ff, #ffffff);
}

.summary-label {
    display: block;
    color: var(--muted);
    margin-bottom: 6px;
}

.amount {
    display: block;
    font-size: clamp(40px, 9vw, 60px);
    line-height: 0.92;
    letter-spacing: -0.05em;
}

.detail-list {
    margin-top: 18px;
    display: grid;
    gap: 10px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
}

.detail-item span {
    color: var(--muted);
}

.charge-form {
    padding: 20px;
}

.charge-form .input--amount {
    min-height: 66px;
}

.charge-form .input--amount:focus {
    outline: 3px solid rgba(31, 95, 191, 0.18);
    border-color: rgba(31, 95, 191, 0.44);
    box-shadow: 0 0 0 6px rgba(31, 95, 191, 0.08);
}

.matches-list {
    display: grid;
    gap: 12px;
}

.debt-box,
.empty-card {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    padding: 18px;
}

.debt-box__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.debt-box__head h3 {
    margin: 0;
    font-size: 18px;
}

.debt-box__total {
    font-weight: 900;
    color: var(--accent);
}

.debt-list {
    display: grid;
    gap: 10px;
}

.debt-item {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.debt-item--active {
    border-color: rgba(31, 95, 191, 0.34);
    background: var(--accent-soft);
    box-shadow: 0 10px 20px rgba(31, 95, 191, 0.12);
}

.debt-item__top,
.debt-item__bottom {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.debt-item__top {
    margin-bottom: 4px;
    align-items: flex-start;
}

.debt-item__bottom {
    color: var(--muted);
    font-size: 13px;
}

.debt-item__meta {
    display: grid;
    gap: 6px;
}

.debt-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 24px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.02em;
}

.debt-badge--warning {
    background: #fff1d8;
    color: #a45a00;
    border: 1px solid rgba(164, 90, 0, 0.16);
}

.empty-card {
    text-align: center;
    background: linear-gradient(160deg, #fff8f8, #ffffff);
}

.empty-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 24px;
    color: var(--error);
}

.empty-card p {
    margin: 0;
    color: var(--muted);
}

.match-card {
    width: 100%;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.match-card__top,
.match-card__bottom {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.match-card__top {
    margin-bottom: 6px;
    font-size: 16px;
}

.match-card__bottom {
    color: var(--muted);
    font-size: 13px;
}

.actions {
    margin-top: 16px;
    display: grid;
    gap: 10px;
}

.receipt {
    padding: 22px;
    text-align: center;
}

.receipt__badge {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--accent-secondary-soft);
    color: var(--accent-secondary);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.receipt h2 {
    margin: 14px 0 8px;
    font-size: 30px;
}

.receipt p {
    margin: 0 0 18px;
    color: var(--muted);
}

.receipt__ticket {
    margin-top: 12px;
    padding: 18px;
    text-align: left;
}

.receipt__row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line);
}

.receipt__row:last-child {
    border-bottom: 0;
}

.receipt__row--hidden {
    display: none;
}

.receipt__row span {
    color: var(--muted);
}

.ticket {
    display: none;
    width: 58mm;
    max-width: 58mm;
    padding: 4mm 3mm;
    color: #000;
    background: #fff;
    font-family: "Courier New", monospace;
    font-size: 11px;
    line-height: 1.28;
    font-weight: 700;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.ticket__brand {
    text-align: center;
}

.ticket__logo {
    display: block;
    width: 23mm;
    max-width: 100%;
    margin: 0 auto 2px;
    height: auto;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    filter: grayscale(1) contrast(1.55) brightness(0.72);
}

.ticket__meta {
    margin-top: 2px;
    text-align: center;
    font-size: 9.5px;
    line-height: 1.18;
    font-weight: 700;
}

.ticket__title {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.ticket__divider {
    margin: 7px 0;
    border-top: 1px dashed #222;
}

.ticket__line {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    padding: 3px 0;
    align-items: flex-start;
}

.ticket__line--stack {
    display: block;
}

.ticket__line--stack strong {
    display: block;
    margin-top: 2px;
}

.ticket__line span {
    font-weight: 700;
}

.ticket__line strong {
    font-weight: 900;
    text-align: right;
}

.ticket__line--total {
    font-size: 13px;
    font-weight: 900;
}

.ticket__line--compact {
    font-size: 9px;
    line-height: 1.15;
}

.ticket__line--compact strong {
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.ticket__foot {
    margin-top: 10px;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
}

@media print {
    body {
        background: #fff;
    }

    .shell,
    .card {
        width: auto;
        padding: 0;
        box-shadow: none;
        border: 0;
        background: #fff;
    }

    .auth-panel,
    .portal-panel,
    .app-footer {
        display: none !important;
    }

    .ticket {
        display: block;
        width: 58mm;
        max-width: 58mm;
        margin: 0 auto;
    }

    @page {
        size: 58mm auto;
        margin: 0;
    }
}

@media (max-width: 640px) {
    .card {
        padding: 18px;
        border-radius: 24px;
    }

    .hero__top,
    .view__head,
    .detail-item,
    .receipt__row {
        flex-direction: column;
        align-items: flex-start;
    }

    .session-box {
        width: 100%;
        text-align: left;
    }

    .input--xl {
        font-size: 26px;
    }

    .charge-form {
        position: sticky;
        bottom: 0;
        z-index: 5;
        box-shadow: 0 -12px 24px rgba(22, 32, 51, 0.08);
    }

    .charge-form .label:first-child {
        color: var(--accent-strong);
    }
}
