:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-soft: #fff3f4;
    --text: #111827;
    --muted: #667085;
    --line: #e6e9ef;
    --red: #f3242d;
    --red-dark: #c5121c;
    --green: #16a34a;
    --green-soft: #e9f9ef;
    --yellow: #d97706;
    --yellow-soft: #fff7e6;
    --danger: #dc2626;
    --danger-soft: #fff1f2;
    --shadow: 0 18px 60px rgba(15, 23, 42, .12);
    --radius: 28px;
    --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
}

body {
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

[hidden] {
    display: none !important;
}

.login-screen {
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 10% 0%, rgba(243, 36, 45, .18), transparent 34%),
        radial-gradient(circle at 90% 12%, rgba(17, 24, 39, .12), transparent 30%),
        linear-gradient(180deg, #ffffff, #f4f6f8);
}

.login-card {
    width: min(440px, 100%);
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 32px;
    background: rgba(255, 255, 255, .88);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: #fff;
    background: linear-gradient(145deg, var(--red), #ff6b72);
    font-size: 26px;
    font-weight: 900;
    box-shadow: 0 14px 30px rgba(243, 36, 45, .28);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--red);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(27px, 7vw, 38px);
    line-height: 1.02;
    letter-spacing: -.05em;
}

h2 {
    margin-bottom: 8px;
    font-size: 22px;
    line-height: 1.08;
    letter-spacing: -.04em;
}

.muted {
    color: var(--muted);
    line-height: 1.55;
}

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

label {
    display: grid;
    gap: 7px;
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
}

input {
    width: 100%;
    min-height: 50px;
    padding: 0 15px;
    border: 1px solid var(--line);
    border-radius: 16px;
    outline: none;
    background: #fff;
    color: var(--text);
    transition: border-color .18s ease, box-shadow .18s ease;
}

input:focus {
    border-color: rgba(243, 36, 45, .55);
    box-shadow: 0 0 0 4px rgba(243, 36, 45, .1);
}

.primary-btn,
.ghost-btn {
    min-height: 48px;
    border: 0;
    border-radius: 999px;
    padding: 0 18px;
    font-weight: 900;
}

.primary-btn {
    color: #fff;
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    box-shadow: 0 14px 26px rgba(243, 36, 45, .23);
}

.primary-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.ghost-btn {
    border: 1px solid var(--line);
    color: var(--text);
    background: #fff;
}

.ghost-btn.small {
    min-height: 38px;
    padding: 0 14px;
    font-size: 12px;
}

.form-message {
    min-height: 20px;
    margin: 0;
    color: var(--danger);
    font-size: 13px;
    font-weight: 800;
}

.security-note {
    display: grid;
    gap: 5px;
    margin-top: 20px;
    padding: 14px;
    border-radius: 18px;
    background: #f7f8fb;
    color: var(--muted);
    font-size: 13px;
}

.security-note strong {
    color: var(--text);
}

.app-shell {
    width: min(100%, 720px);
    min-height: 100svh;
    margin: 0 auto;
    padding: max(16px, env(safe-area-inset-top)) 16px calc(94px + env(safe-area-inset-bottom));
    background: var(--bg);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: -16px -16px 14px;
    padding: max(16px, env(safe-area-inset-top)) 16px 14px;
    border-bottom: 1px solid rgba(230, 233, 239, .86);
    background: rgba(245, 246, 248, .92);
    backdrop-filter: blur(18px);
}

.app-header h1 {
    margin: 0;
    font-size: 28px;
}

.page {
    display: none;
    animation: pageIn .2s ease both;
}

.page.active {
    display: block;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-card,
.scan-event-card,
.panel,
.ticket-result,
.search-panel,
.camera-card,
.result-card {
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 12px 38px rgba(15, 23, 42, .07);
}

.hero-card {
    position: relative;
    overflow: hidden;
    padding: 24px;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(17, 24, 39, .92), rgba(54, 18, 24, .92)),
        radial-gradient(circle at 100% 0%, rgba(243, 36, 45, .82), transparent 42%);
}

.hero-card:after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -50px;
    width: 170px;
    height: 170px;
    border-radius: 999px;
    border: 38px solid rgba(255, 255, 255, .08);
}

.hero-card h2,
.hero-card p,
.hero-card .eyebrow {
    position: relative;
    z-index: 1;
}

.hero-card .eyebrow {
    color: rgba(255, 255, 255, .76);
}

.hero-card p {
    margin-bottom: 22px;
    color: rgba(255, 255, 255, .72);
}

.progress-wrap {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, .24);
}

.progress-bar.wide {
    background: #edf0f5;
}

.progress-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #18c26b, #72e0a5);
    transition: width .25s ease;
}

.progress-bar span.w0 { width: 0%; }
.progress-bar span.w5 { width: 5%; }
.progress-bar span.w10 { width: 10%; }
.progress-bar span.w15 { width: 15%; }
.progress-bar span.w20 { width: 20%; }
.progress-bar span.w25 { width: 25%; }
.progress-bar span.w30 { width: 30%; }
.progress-bar span.w35 { width: 35%; }
.progress-bar span.w40 { width: 40%; }
.progress-bar span.w45 { width: 45%; }
.progress-bar span.w50 { width: 50%; }
.progress-bar span.w55 { width: 55%; }
.progress-bar span.w60 { width: 60%; }
.progress-bar span.w65 { width: 65%; }
.progress-bar span.w70 { width: 70%; }
.progress-bar span.w75 { width: 75%; }
.progress-bar span.w80 { width: 80%; }
.progress-bar span.w85 { width: 85%; }
.progress-bar span.w90 { width: 90%; }
.progress-bar span.w95 { width: 95%; }
.progress-bar span.w100 { width: 100%; }

.quick-grid,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.action-tile,
.stat-card {
    min-height: 136px;
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, .74);
    border-radius: 26px;
    background: #fff;
    text-align: left;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .07);
}

.action-tile {
    display: grid;
    align-content: space-between;
    gap: 12px;
}

.action-tile b,
.stat-card b {
    display: block;
    color: var(--text);
    font-size: 16px;
}

.action-tile small,
.stat-card small {
    color: var(--muted);
    line-height: 1.35;
}

.tile-icon,
.nav-home,
.nav-scan,
.nav-search,
.nav-overview {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 9px;
    background: var(--red);
    box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .1);
}

.scan-icon {
    clip-path: polygon(0 0, 40% 0, 40% 18%, 18% 18%, 18% 40%, 0 40%, 0 0, 60% 0, 100% 0, 100% 40%, 82% 40%, 82% 18%, 60% 18%);
}

.search-icon {
    border-radius: 50%;
}

.chart-icon {
    border-radius: 6px;
    background: linear-gradient(90deg, var(--red) 33%, #ff7b82 33% 66%, #111827 66%);
}

.sync-icon {
    border-radius: 50%;
    background: conic-gradient(from 30deg, var(--red), #111827, var(--red));
}

.scan-event-card {
    padding: 18px;
    margin-bottom: 14px;
}

.scan-event-card h2 {
    margin-bottom: 4px;
    font-size: 20px;
}

.scan-event-card p {
    margin-bottom: 0;
    color: var(--muted);
}

.camera-card {
    position: relative;
    overflow: hidden;
    aspect-ratio: 3 / 4;
    min-height: 380px;
    background: #111827;
}

.camera-card video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    padding: 30px;
    color: #fff;
    text-align: center;
    background:
        radial-gradient(circle at 50% 38%, rgba(243, 36, 45, .25), transparent 34%),
        linear-gradient(180deg, #151b29, #090c13);
}

.camera-placeholder small {
    color: rgba(255, 255, 255, .64);
}

.qr-frame {
    width: 136px;
    height: 136px;
    border: 4px solid rgba(255, 255, 255, .86);
    border-radius: 28px;
    box-shadow: 0 0 0 10px rgba(255, 255, 255, .05);
}

.scan-frame {
    position: absolute;
    inset: 18%;
    border: 3px solid rgba(255, 255, 255, .8);
    border-radius: 30px;
    pointer-events: none;
}

.scan-frame:before {
    content: "";
    position: absolute;
    left: 16px;
    right: 16px;
    top: 50%;
    height: 2px;
    border-radius: 99px;
    background: var(--red);
    box-shadow: 0 0 16px rgba(243, 36, 45, .85);
    animation: scanLine 1.8s ease-in-out infinite;
}

@keyframes scanLine {
    0%,
    100% {
        transform: translateY(-78px);
    }
    50% {
        transform: translateY(78px);
    }
}

.scan-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin: 14px 0;
}

.manual-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
}

.manual-form label {
    min-width: 0;
}

.search-panel {
    position: sticky;
    top: 78px;
    z-index: 10;
    padding: 14px;
    margin-bottom: 12px;
}

.search-box {
    display: block;
}

.search-box input {
    padding-left: 45px;
    background:
        linear-gradient(#fff, #fff) padding-box,
        linear-gradient(135deg, rgba(243, 36, 45, .35), rgba(17, 24, 39, .12)) border-box;
}

.search-box span:before {
    content: "";
    position: absolute;
    width: 17px;
    height: 17px;
    margin: 17px 0 0 16px;
    border: 2px solid #9aa3b2;
    border-radius: 50%;
}

.search-box span:after {
    content: "";
    position: absolute;
    width: 8px;
    height: 2px;
    margin: 33px 0 0 31px;
    background: #9aa3b2;
    transform: rotate(45deg);
}

.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-top: 12px;
}

.chip {
    flex: 0 0 auto;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 12px;
    color: var(--muted);
    background: #fff;
    font-size: 12px;
    font-weight: 900;
}

.chip.active {
    border-color: transparent;
    color: #fff;
    background: var(--text);
}

.result-list,
.activity-list {
    display: grid;
    gap: 10px;
}

.result-card,
.activity-row {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
}

.avatar {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(145deg, var(--red), #ff7d83);
    font-weight: 900;
}

.result-card b,
.activity-row b {
    display: block;
    margin-bottom: 2px;
    font-size: 14px;
}

.result-card small,
.activity-row small {
    color: var(--muted);
}

.status-badge {
    border-radius: 999px;
    padding: 7px 10px;
    background: #eef2f7;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.status-badge.confirmed,
.status-badge.approved,
.status-badge.success {
    background: var(--green-soft);
    color: var(--green);
}

.status-badge.pending,
.status-badge.warning {
    background: var(--yellow-soft);
    color: var(--yellow);
}

.status-badge.blocked,
.status-badge.cancelled,
.status-badge.duplicate,
.status-badge.rejected {
    background: var(--danger-soft);
    color: var(--danger);
}

.panel {
    padding: 18px;
    margin-top: 12px;
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.panel-title h2 {
    margin: 0;
    font-size: 18px;
}

.panel-title span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.stat-card {
    min-height: auto;
}

.stat-card b {
    margin-bottom: 4px;
    font-size: 28px;
    letter-spacing: -.05em;
}

.activity-row {
    grid-template-columns: 38px 1fr auto;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.activity-row:last-child {
    border-bottom: 0;
}

.ticket-result {
    overflow: hidden;
}

.result-top {
    padding: 28px 22px;
    color: #fff;
    background: linear-gradient(145deg, var(--green), #45c97a);
}

.result-top.warning {
    background: linear-gradient(145deg, #d97706, #f59e0b);
}

.result-top.blocked,
.result-top.duplicate {
    background: linear-gradient(145deg, #dc2626, #ef4444);
}

.result-mark {
    position: relative;
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    margin-bottom: 16px;
    border-radius: 28px;
    background: rgba(255, 255, 255, .18);
    font-size: 42px;
    font-weight: 900;
}

.result-mark:before {
    content: "";
    width: 30px;
    height: 18px;
    border-left: 6px solid #fff;
    border-bottom: 6px solid #fff;
    transform: rotate(-45deg) translate(2px, -4px);
}

.result-top.warning .result-mark:before {
    width: 6px;
    height: 34px;
    border-left: 6px solid #fff;
    border-bottom: 0;
    transform: none;
}

.result-top.blocked .result-mark:before,
.result-top.duplicate .result-mark:before {
    width: 34px;
    height: 6px;
    border-left: 0;
    border-bottom: 6px solid #fff;
    transform: rotate(45deg);
    box-shadow: 0 0 0 #fff;
}

.result-top.blocked .result-mark:after,
.result-top.duplicate .result-mark:after {
    content: "";
    position: absolute;
    width: 34px;
    height: 6px;
    border-radius: 999px;
    background: #fff;
    transform: rotate(-45deg);
}

.result-top h2 {
    margin-bottom: 8px;
    font-size: 30px;
}

.result-top p {
    margin-bottom: 0;
    color: rgba(255, 255, 255, .78);
}

.detail-grid {
    display: grid;
    gap: 12px;
    padding: 18px;
}

.detail-card {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: #fff;
}

.detail-card span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.detail-card b {
    display: block;
    font-size: 16px;
    line-height: 1.35;
}

.access-list {
    display: grid;
    gap: 10px;
    padding: 0 18px 18px;
}

.access-row {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 10px;
    align-items: center;
    padding: 13px;
    border-radius: 18px;
    background: #f8fafc;
}

.access-dot {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    background: var(--green-soft);
}

.access-dot:before {
    content: "";
    display: block;
    width: 14px;
    height: 8px;
    margin: 10px auto 0;
    border-left: 3px solid var(--green);
    border-bottom: 3px solid var(--green);
    transform: rotate(-45deg);
}

.access-row small {
    display: block;
    color: var(--muted);
}

.sticky-actions {
    position: sticky;
    bottom: calc(76px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 24px;
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 18px 38px rgba(15, 23, 42, .12);
    backdrop-filter: blur(14px);
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 0;
    z-index: 40;
    width: min(100%, 720px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(230, 233, 239, .92);
    background: rgba(255, 255, 255, .94);
    transform: translateX(-50%);
    backdrop-filter: blur(18px);
}

.bottom-nav button {
    display: grid;
    place-items: center;
    gap: 4px;
    min-height: 58px;
    border: 0;
    border-radius: 18px;
    color: var(--muted);
    background: transparent;
    font-size: 11px;
    font-weight: 900;
}

.bottom-nav button span {
    width: 21px;
    height: 21px;
    background: #a5adbb;
}

.bottom-nav button.active {
    color: var(--red);
    background: var(--surface-soft);
}

.bottom-nav button.active span {
    background: var(--red);
}

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

@media (min-width: 740px) {
    .app-shell {
        margin-top: 18px;
        margin-bottom: 18px;
        border: 1px solid var(--line);
        border-radius: 34px;
        box-shadow: var(--shadow);
    }

    .bottom-nav {
        border-radius: 26px 26px 0 0;
    }
}

@media (max-width: 430px) {
    .manual-form {
        grid-template-columns: 1fr;
    }

    .quick-grid,
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .sticky-actions {
        grid-template-columns: 1fr;
    }
}
