:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #687586;
    --line: #dfe4ea;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #c2410c;
    --ok: #15803d;
    --error: #b91c1c;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--primary);
}

.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .92);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}

nav {
    display: flex;
    gap: 16px;
}

nav a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 700;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 32px auto;
}

.hero {
    min-height: calc(100vh - 128px);
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    align-items: center;
    gap: 36px;
}

.hero h1,
.terminal-head h1,
.panel h1 {
    margin: 0 0 16px;
    font-size: 48px;
    line-height: 1.05;
    letter-spacing: 0;
}

.hero p {
    font-size: 20px;
    line-height: 1.55;
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-weight: 800;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0;
}

.actions,
.filters {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.button.primary:hover {
    background: var(--primary-dark);
}

.wide {
    width: 100%;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.status-grid div,
.panel,
.camera-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.status-grid strong {
    display: block;
    font-size: 34px;
}

.status-grid span,
td span,
.muted {
    color: var(--muted);
}

.terminal-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    min-height: calc(100vh - 128px);
}

.terminal-screen {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #0f172a;
    color: #fff;
    border-radius: 8px;
    padding: 28px;
}

.terminal-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.terminal-head select {
    align-self: start;
}

.qr-box {
    display: grid;
    place-items: center;
    gap: 16px;
    text-align: center;
}

#qrcode {
    padding: 20px;
    background: #fff;
    border-radius: 8px;
}

.qr-fallback {
    width: 320px;
    height: 320px;
    display: grid;
    place-items: center;
    color: var(--text);
}

#qrLink {
    color: #c7f9ef;
    overflow-wrap: anywhere;
}

.camera-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

video {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #111827;
    border-radius: 8px;
    object-fit: cover;
}

.event-toast,
.result {
    border: 1px solid var(--line);
    background: #f8fafc;
    border-radius: 8px;
    padding: 14px;
    min-height: 48px;
}

.auth-summary {
    display: grid;
    gap: 4px;
    border: 1px solid var(--line);
    background: #f8fafc;
    border-radius: 8px;
    padding: 14px;
    margin: 0 0 16px;
}

.auth-summary strong {
    font-size: 18px;
}

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

.auth-summary a {
    justify-self: start;
    font-weight: 800;
}

.auth-form {
    width: min(460px, 100%);
}

.scan-flash {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: opacity .12s ease;
}

.scan-flash.show {
    opacity: 1;
}

.scan-flash.ok {
    background: rgba(21, 128, 61, .94);
}

.scan-flash.error {
    background: rgba(185, 28, 28, .94);
}

.scan-flash span {
    color: #fff;
    font-size: 30px;
    font-weight: 900;
    text-align: center;
    padding: 24px;
}

.summary-tile {
    display: grid;
    gap: 6px;
    min-width: 220px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #f8fafc;
}

.summary-tile span {
    color: var(--muted);
    font-weight: 800;
}

.summary-tile strong {
    font-size: 28px;
}

.result.ok {
    color: var(--ok);
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.result.error {
    color: var(--error);
    border-color: #fecaca;
    background: #fef2f2;
}

.phone-layout {
    display: grid;
    place-items: start center;
}

.panel {
    margin-bottom: 20px;
}

.panel.narrow {
    max-width: 620px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 12px;
}

input,
select {
    min-height: 42px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 12px;
    color: var(--text);
    background: #fff;
}

.reader {
    width: 100%;
    min-height: 0;
    margin: 14px 0;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    text-align: left;
    padding: 12px;
    vertical-align: top;
}

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

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

.stack {
    display: grid;
    gap: 4px;
}

@media (max-width: 860px) {
    .topbar {
        height: auto;
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 18px;
    }

    nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .hero,
    .terminal-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .hero h1,
    .terminal-head h1,
    .panel h1 {
        font-size: 34px;
    }

    .terminal-head,
    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    #qrcode img,
    #qrcode canvas,
    .qr-fallback {
        width: 240px !important;
        height: 240px !important;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }
}
