:root {
    --blue: #2D3BC9;
    --purple: #7A3BC9;
    --green: #ADBA3F;
    --green-dark: #6f7a1c;
    --ink: #1c2040;
    --muted: #666c8a;
    --line: #e3e5f0;
    --bg: #f5f6fb;
    --card: #fff;
    --danger: #c0392b;
    --gradient: linear-gradient(90deg, var(--purple), var(--blue));
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

a { color: var(--blue); }
h1 { margin: 0; font-size: 1.6rem; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}
.brand img { display: block; height: 26px; width: auto; }
.topbar nav { display: flex; align-items: center; gap: 16px; font-size: .95rem; }
.topbar nav a { color: var(--ink); text-decoration: none; }
.topbar nav a:hover { color: var(--blue); }
.topbar form { margin: 0; }

/* ---- shared ---- */
.page { max-width: 960px; margin: 0 auto; padding: 20px 16px 40px; }
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.sub { margin: 4px 0 0; color: var(--muted); }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn.primary { border: 0; background: var(--gradient); color: #fff; }
.btn:disabled { opacity: .6; cursor: default; }

.link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}

.alert {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #fdecea;
    color: var(--danger);
    font-weight: 600;
}

label { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }
input, select {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ---- login ---- */
.login {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 16px;
}
.login .logo { width: min(340px, 80vw); height: auto; }
.login form { display: grid; gap: 14px; width: min(360px, 100%); padding: 22px; }

/* ---- flights list ---- */
.flights {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.flight { display: grid; gap: 4px; padding: 16px; color: var(--ink); text-decoration: none; }
.flight:hover { border-color: var(--blue); }
.flight-number { font-size: 1.4rem; font-weight: 700; color: var(--blue); }
.flight-meta { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); }

/* ---- dashboard ---- */
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.live.stale i { background: var(--danger); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tile { display: grid; gap: 4px; padding: 20px; }
.tile-label { color: var(--muted); font-weight: 600; }
.tile-num { font-size: clamp(2.6rem, 9vw, 4.5rem); font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tile-note { color: var(--muted); font-size: .9rem; }
.tile.accent { border: 0; background: var(--gradient); color: #fff; }
.tile.accent .tile-label, .tile.accent .tile-note { color: rgba(255, 255, 255, .85); }

.meter-card { margin-top: 12px; padding: 18px 20px; }
.meter { height: 14px; border-radius: 7px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 7px; background: var(--gradient); transition: width .4s; }
.meter-fill.full { background: var(--danger); }
.meter-legend { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; color: var(--muted); font-size: .9rem; }

@media (max-width: 640px) {
    .tiles { grid-template-columns: 1fr; }
}

/* ---- scan ---- */
.scan { max-width: 560px; }
.viewfinder {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    overflow: hidden;
    background: #11132a;
    margin-bottom: 16px;
}
.viewfinder video { width: 100%; height: 100%; object-fit: cover; }
.frame {
    position: absolute;
    inset: 22% 8%;
    border: 3px solid var(--green);
    border-radius: 12px;
    pointer-events: none;
}
.hint {
    position: absolute;
    inset-inline: 0;
    bottom: 10px;
    margin: 0;
    padding: 0 12px;
    text-align: center;
    color: #fff;
    font-size: .9rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}

.toast {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f1f4dc;
    color: var(--green-dark);
    font-weight: 600;
}

.manual { padding: 14px 16px; }
.manual summary { cursor: pointer; font-weight: 600; }
.manual form { display: grid; gap: 12px; margin-top: 14px; }

.sheet {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    background: rgba(17, 19, 42, .55);
}
.sheet-body { width: min(520px, 100%); padding: 22px; text-align: center; }
.sheet-body p { margin: 0; }
.sheet-flight { color: var(--muted); font-weight: 600; }
.sheet-seat { font-size: 2.4rem; font-weight: 800; color: var(--blue); }
.sheet-pax { color: var(--muted); min-height: 1.3em; }
.sheet-free { margin-top: 8px !important; font-weight: 600; }
.sheet-free.full { color: var(--danger); }
.choices { display: grid; gap: 10px; margin: 18px 0 14px; }
.choice { min-height: 60px; font-size: 1.15rem; border: 2px solid transparent; }
.choice.cabin { background: var(--gradient); color: #fff; }
.choice.none { background: #eceef6; }
.choice.hold { background: var(--green); color: #1f2400; }
.choice.current { border-color: var(--ink); }

@media (min-width: 700px) {
    .sheet { align-items: center; }
}
