:root {
    --bg: #090b10;
    --card: #161920;
    --card-2: #1f2430;
    --border: #2d3444;
    --red: #E3000F;
    --blue: #0b509e;
    --cyan: #38bdf8;
    --text: #f8fafc;
    --muted: #94a3b8;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}
header {
    padding: max(10px, env(safe-area-inset-top)) 16px 10px;
    background: #14171d;
    border-bottom: 2px solid var(--red);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.brand {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand img { width: 32px; height: 32px; border-radius: 8px; display: block; }
.brand .slash { color: var(--red); }
.brand small { font-size: 11px; color: var(--muted); font-weight: 600; margin-left: 2px; }
main {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 14px 14px calc(24px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.card.drag-over {
    border-color: var(--cyan);
    background: #152030;
}
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.card-title {
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
}
.pick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.btn {
    border: 1px solid var(--border);
    background: var(--card-2);
    color: var(--text);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: transform 0.08s ease, opacity 0.12s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-blue {
    background: linear-gradient(135deg, #0b509e, #0284c7);
    border-color: var(--cyan);
    color: #fff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.28);
}
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.link-danger {
    display: none;
    background: none;
    border: none;
    color: #f87171;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 2px 4px;
}
.file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}
.empty-hint {
    text-align: center;
    padding: 14px 8px;
    color: #64748b;
    font-size: 12px;
    border: 1px dashed #2d3444;
    border-radius: 10px;
    line-height: 1.45;
}
.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: #101319;
    border: 1px solid #262c3a;
    border-radius: 9px;
    font-size: 12.5px;
}
.file-meta { min-width: 0; flex: 1; }
.file-name {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.file-size { font-size: 11px; color: var(--muted); }
.del-btn {
    background: rgba(239, 68, 68, 0.16);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 7px;
    width: 28px;
    height: 28px;
    font-weight: 800;
    cursor: pointer;
    flex-shrink: 0;
}
textarea, input[type="tel"] {
    width: 100%;
    background: #0e1117;
    border: 1px solid #333c4e;
    border-radius: 9px;
    color: #fff;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13.5px;
}
textarea:focus, input[type="tel"]:focus { outline: none; border-color: var(--cyan); }
.opt-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #cbd5e1;
    cursor: pointer;
}
.opt-row input { width: 16px; height: 16px; accent-color: var(--red); margin: 0; flex-shrink: 0; }
.code-row { display: flex; gap: 8px; }
#code-inp {
    font-family: monospace;
    font-size: 20px;
    font-weight: 800;
    text-align: center;
    letter-spacing: 3px;
    padding: 9px;
}
.prog-wrap {
    width: 100%;
    height: 8px;
    background: #0e1117;
    border-radius: 99px;
    overflow: hidden;
}
#prog-bar {
    width: 0%;
    height: 100%;
    background: #22c55e;
    transition: width 0.14s ease;
}
#status-lbl { font-size: 12px; color: var(--muted); text-align: center; font-weight: 600; }
#cam-box {
    display: none;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    border: 1px solid var(--cyan);
}
#cam-vid { width: 100%; max-height: 220px; object-fit: cover; display: block; }
#btn-stop-scan {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(15, 23, 42, 0.82);
    color: #fff;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 4px 9px;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
}
#toast {
    position: fixed;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 10px 18px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transition: top 0.22s ease;
    white-space: nowrap;
}
#install-btn {
    display: none;
    padding: 6px 11px;
    font-size: 11.5px;
    border-radius: 7px;
    background: var(--blue);
    border: 1px solid var(--cyan);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}