:root {
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bg: #f5f5f5;
    --surface: #ffffff;
    --text: #111111;
    --muted: #666666;
    --border: #e0e0e0;
    --black: #000000;
    --accent: #111111;
    --danger: #b00020;
    --success: #1a7a3a;
    --info: #333333;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --header-h: 56px;
    --logo-header-w: 72px;
    --logo-welcome-w: 88px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

input,
button,
textarea {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.bonus-app {
    min-height: 100dvh;
}

.app-frame {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    background: var(--bg);
    box-shadow: 0 0 0 1px var(--border);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 12px;
    background: var(--black);
    color: #fff;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    min-width: 0;
    max-width: calc(100% - 48px);
}

.app-header .brand-logo-img,
.welcome-logo {
    display: block;
    width: auto;
    height: auto;
    object-fit: contain;
}

.app-header .brand-logo-img {
    width: var(--logo-header-w);
    max-width: 50vw;
}

.welcome-logo {
    width: var(--logo-welcome-w);
    max-width: 100%;
}

.header-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.app-main {
    padding: 16px 16px calc(24px + var(--safe-bottom));
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.4;
    background: var(--surface);
    border: 1px solid var(--border);
}

.flash-danger {
    border-color: #f0c4c4;
    background: #fff5f5;
    color: var(--danger);
}

.flash-info {
    background: #f7f7f7;
}

.flash-success {
    border-color: #b8dfc4;
    background: #f3fbf5;
    color: var(--success);
}

.hero-card {
    text-align: center;
    padding: 8px 8px 20px;
}

.hero-card h1 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 800;
}

.hero-card p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.panel-head {
    margin-bottom: 12px;
}

.panel-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-scan {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--black);
    margin-bottom: 4px;
}

.form-stack {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.field label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.field label i {
    width: 16px;
    text-align: center;
    color: var(--black);
}

.field input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 14px;
    font-size: 16px;
    background: #fafafa;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
    outline: none;
    border-color: var(--black);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
    background: #fff;
}

.input-row {
    display: flex;
    gap: 8px;
}

.input-row input {
    flex: 1;
    min-width: 0;
}

.btn-icon {
    flex-shrink: 0;
    width: 52px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--black);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary {
    background: var(--black);
    color: #fff;
}

.btn-block {
    width: 100%;
}

.qr-reader-wrap {
    width: 100%;
    min-height: 220px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #111;
    border: 1px solid var(--border);
}

.qr-reader-wrap video {
    border-radius: var(--radius-sm);
}

.qr-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.65);
}

.qr-modal.show {
    display: flex;
}

.qr-modal-dialog {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border-radius: 20px 20px 16px 16px;
    padding: 16px;
}

.qr-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.qr-modal-head button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #eee;
    font-size: 22px;
    cursor: pointer;
}

.welcome-card {
    display: flex;
    gap: 14px;
    align-items: center;
    background: var(--black);
    color: #fff;
    border-radius: var(--radius);
    padding: 18px 16px;
    margin-bottom: 14px;
}

.welcome-brand {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.welcome-label {
    margin: 0 0 4px;
    font-size: 12px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.welcome-card h1 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 800;
}

.welcome-meta {
    margin: 0;
    font-size: 13px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 8px;
}

.welcome-meta + .welcome-meta {
    margin-top: 4px;
}

.card-chip code {
    font-family: inherit;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

.stat-card-accent {
    background: var(--black);
    color: #fff;
    border-color: var(--black);
}

.stat-card-accent .stat-label,
.stat-card-accent .stat-sub {
    color: rgba(255, 255, 255, 0.7);
}

.stat-icon {
    font-size: 18px;
    margin-bottom: 8px;
    opacity: 0.8;
}

.stat-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
}

.stat-sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.sale-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.sale-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: #fafafa;
}

.sale-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.sale-code {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 13px;
}

.sale-code code {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    font-weight: 600;
    word-break: break-all;
}

.sale-amount {
    font-weight: 800;
    font-size: 15px;
    white-space: nowrap;
}

.sale-item-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.sale-item-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sale-bonus {
    font-size: 13px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sale-bonus strong {
    font-weight: 800;
}

.sale-bonus-rate {
    color: var(--muted);
    font-size: 12px;
}

.empty-state {
    text-align: center;
    padding: 28px 12px;
    color: var(--muted);
}

.empty-state i {
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.4;
}

.footnote {
    margin: 16px 0 0;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.4;
}

@media (min-width: 520px) {
    .app-frame {
        margin-top: 12px;
        margin-bottom: 12px;
        min-height: calc(100dvh - 24px);
        border-radius: 24px;
        overflow: hidden;
    }
}

@media (display-mode: standalone) {
    .app-header {
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    }
}
