:root {
    --bg: #0f1412;
    --bg-2: #171d1a;
    --surface: #1e2622;
    --line: rgba(255, 255, 255, 0.08);
    --text: #f2f5f3;
    --text-2: #a8b3ad;
    --text-3: #6f7b74;
    --accent: #f0a04b;
    --accent-2: #e07a2f;
    --ok: #3ecf8e;
    --warn: #f0c14b;
    --bad: #ef6b6b;
    --radius: 16px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --font: "Manrope", system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font);
    background:
        radial-gradient(120% 80% at 100% -10%, rgba(240, 160, 75, 0.18), transparent 50%),
        radial-gradient(90% 60% at 0% 100%, rgba(62, 207, 142, 0.08), transparent 45%),
        var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.wrap {
    width: min(560px, 100%);
    margin: 0 auto;
    padding: 20px 16px 110px;
}

.top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: block;
}
.brand-name {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.03em;
}
.brand-sub {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.logout {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text-2);
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}
.stat {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 10px;
    text-align: center;
}
.stat b {
    display: block;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.04em;
}
.stat span {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-3);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.panel { display: none; }
.panel.active { display: block; }

.scan-box, .card {
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}

.label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 8px;
}

.field {
    display: flex;
    gap: 8px;
}
.field input {
    flex: 1;
    min-width: 0;
    height: 52px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--bg-2);
    color: var(--text);
    padding: 0 14px;
    font-family: var(--mono);
    font-size: 16px;
    letter-spacing: 0.02em;
    outline: none;
}
.field input:focus {
    border-color: rgba(240, 160, 75, 0.55);
    box-shadow: 0 0 0 3px rgba(240, 160, 75, 0.15);
}

.btn {
    height: 52px;
    border: 0;
    border-radius: 14px;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s var(--ease), opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #1a1008;
}
.btn-ok {
    background: linear-gradient(135deg, #49d99a, #2bbf7a);
    color: #062214;
}
.btn-ghost {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text-2);
}
.btn-block {
    width: 100%;
    margin-top: 12px;
}

.status-line {
    margin-top: 10px;
    min-height: 18px;
    font-size: 13px;
    color: var(--text-2);
}
.status-line.err { color: var(--bad); }
.status-line.ok { color: var(--ok); }

.result {
    margin-top: 14px;
    display: none;
}
.result.show { display: block; }

.meta {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}
.meta-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}
.meta-row span { color: var(--text-3); }
.meta-row b {
    font-weight: 700;
    text-align: right;
    word-break: break-word;
}
.meta-row b.mono { font-family: var(--mono); font-size: 13px; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(240,160,75,0.14);
    color: var(--accent);
}
.badge.ok { background: rgba(62,207,142,0.14); color: var(--ok); }
.badge.warn { background: rgba(240,193,75,0.14); color: var(--warn); }

.parcel-list {
    display: grid;
    gap: 8px;
    margin: 12px 0;
}
.parcel-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: rgba(0,0,0,0.18);
}
.parcel-item .t {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
}
.parcel-item .s {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-3);
}

.nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(15, 20, 18, 0.92);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    z-index: 20;
}
.nav button {
    height: 52px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--text-3);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}
.nav button.active {
    background: rgba(240, 160, 75, 0.14);
    color: var(--accent);
}

/* login */
.login-wrap {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}
.login-card {
    width: min(420px, 100%);
    background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 28px 22px;
}
.login-card h1 {
    margin: 14px 0 6px;
    font-size: 28px;
    letter-spacing: -0.04em;
}
.login-card p {
    margin: 0 0 18px;
    color: var(--text-2);
    line-height: 1.45;
}
.login-card .field { margin-top: 10px; }
.login-card .field input { font-family: var(--font); }
.hint {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-3);
    line-height: 1.4;
}

.btn-cam {
    height: 52px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0 12px;
    background: rgba(255,255,255,0.04);
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
}
.btn-cam-wide {
    width: 100%;
    margin-top: 10px;
    height: 48px;
    border: 1px dashed rgba(240,160,75,0.45);
    border-radius: 14px;
    background: rgba(240,160,75,0.08);
    color: var(--accent);
    font-weight: 700;
}
.field .btn-cam { flex-shrink: 0; }

.cam-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0,0,0,0.72);
    display: grid;
    place-items: end center;
    padding: 12px;
}
.cam-overlay[hidden] { display: none !important; }
.cam-sheet {
    width: min(560px, 100%);
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 20px 20px 16px 16px;
    padding: 14px 14px 18px;
    max-height: min(92dvh, 720px);
    overflow: auto;
}
.cam-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.cam-title {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.03em;
}
.cam-sub {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-3);
}
.cam-close {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text-2);
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
}
.cam-reader {
    border-radius: 14px;
    overflow: hidden;
    background: #000;
    min-height: 240px;
}
.cam-reader video {
    width: 100% !important;
    border-radius: 14px;
}
#camReader img { display: none; }

.divider-or {
    margin: 18px 0 14px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    position: relative;
}
.divider-or::before,
.divider-or::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 32%;
    height: 1px;
    background: var(--line);
}
.divider-or::before { left: 0; }
.divider-or::after { right: 0; }


.track-actions {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}
.result.show,
.result.show.card {
    display: block !important;
}
