* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #050505;
    --surface: #151515;
    --surface2: #1f1f1f;
    --surface3: #292929;
    --border: #2c2c2c;
    --text: #f6f6f6;
    --muted: #a4a4a4;
    --dim: #707070;
    --danger: #ef5350;
    --ok: #66bb6a;
    --blue: #6db7f5;
    --green: #7cc884;
    --amber: #f4aa35;
    --pink: #d78be8;
}
html {
    min-height: 100%;
    background:
        radial-gradient(54vmax 54vmax at 88% 8%, rgba(255,255,255,.055) 0%, transparent 58%),
        linear-gradient(145deg, #030303 0%, #111 54%, #050505 100%);
    overscroll-behavior-y: none;
}
body {
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    background:
        radial-gradient(54vmax 54vmax at 88% 8%, rgba(255,255,255,.055) 0%, transparent 58%),
        radial-gradient(48vmax 48vmax at 8% -10%, rgba(255,255,255,.085) 0%, transparent 55%),
        radial-gradient(42vmax 42vmax at 94% 28%, rgba(70,122,130,.10) 0%, transparent 60%),
        linear-gradient(145deg, #030303 0%, #111 54%, #050505 100%);
    background-attachment: fixed;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
body::before,
body::after {
    content: "";
    position: fixed;
    border-radius: 50%;
    filter: blur(88px);
    pointer-events: none;
    z-index: 0;
}
body::before {
    width: 58vmax;
    height: 58vmax;
    top: -26vmax;
    left: -20vmax;
    background: radial-gradient(circle at 32% 32%, rgba(255,255,255,.11) 0%, rgba(255,255,255,0) 62%);
}
body::after {
    width: 54vmax;
    height: 54vmax;
    right: -20vmax;
    bottom: -24vmax;
    background: radial-gradient(circle at 58% 58%, rgba(255,255,255,.07) 0%, rgba(255,255,255,0) 62%);
}
body > * {
    position: relative;
    z-index: 1;
}
button, input, select { font: inherit; }
.muted { color: var(--muted); }
.eyebrow {
    display: block;
    color: var(--dim);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 3px;
}
.brand-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    box-shadow: 0 14px 42px rgba(0,0,0,.42);
}
.brand-logo.small { width: 38px; height: 38px; border-radius: 10px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
    width: min(460px, 100%);
    background: rgba(18,18,18,.96);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 26px;
    box-shadow: 0 24px 90px rgba(0,0,0,.42);
}
.login-brand { justify-content: flex-start; text-align: left; }
h1 { font-size: 28px; line-height: 1.08; margin-bottom: 5px; }
.qr-box {
    position: relative;
    margin: 24px auto 14px;
    width: min(286px, 100%);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: linear-gradient(145deg, #1b1b1b, #101010);
    border: 1px solid #303030;
    padding: 18px;
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.05),
        0 18px 44px rgba(0,0,0,.28);
}
.qr-box.loading #qrCode,
.qr-box.expired #qrCode { display: none; }
.qr-box.loading .qr-loading,
.qr-box.expired .qr-loading { display: flex; }
#qrCode {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 10px;
    padding: 12px;
}
#qrCode img, #qrCode canvas {
    display: block;
    width: 224px;
    height: 224px;
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
}
#qrCode .qr-center-logo {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    padding: 6px;
    background: #fff;
    box-shadow: 0 0 0 4px #fff, 0 10px 22px rgba(0,0,0,.18);
    image-rendering: auto;
    z-index: 2;
}
.qr-fallback {
    color: #111;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    word-break: break-all;
}
.qr-loading {
    position: absolute;
    inset: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: #151515;
    background: #fff;
    border-radius: 10px;
    font-weight: 800;
}
.qr-loading img { width: 56px; height: 56px; border-radius: 14px; }
.state-text { color: var(--muted); min-height: 22px; margin: 12px 0; text-align: center; }
.state-text:empty { display: none; }
.btn {
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    border-radius: 11px;
    padding: 10px 14px;
    cursor: pointer;
}
.btn:hover { background: var(--surface3); }
.btn.primary { background: #fff; color: #050505; border-color: #fff; font-weight: 800; width: 100%; }
.qr-refresh { display: none; margin-top: 14px; }
.qr-refresh.visible { display: block; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 7px 10px; font-size: 12px; }
.dashboard-shell { display: none; min-height: 100vh; }
.is-auth .login-shell { display: none; }
.is-auth .dashboard-shell { display: block; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    padding: 14px 24px;
    background: rgba(8,8,8,.88);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
}
.topbar strong { display: block; font-size: 15px; }
.topbar nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    border-radius: 10px;
    padding: 9px 12px;
    cursor: pointer;
    font-weight: 800;
}
.nav-btn img { width: 17px; height: 17px; opacity: .8; }
.nav-btn.active, .nav-btn:hover { color: var(--text); background: var(--surface2); }
.nav-btn.danger { color: #ff8a80; }
.device-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin: 22px 24px 0;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(20,20,20,.82);
}
.status-dot {
    color: var(--ok);
    background: rgba(102,187,106,.12);
    border: 1px solid rgba(102,187,106,.26);
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .06em;
}
.session-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}
.session-timer {
    display: inline-flex;
    align-items: center;
    min-height: 31px;
    color: #f1f1f1;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.13);
    border-radius: 999px;
    padding: 7px 11px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .04em;
    white-space: nowrap;
}
.session-timer.warn {
    color: #ffcc80;
    border-color: rgba(255,204,128,.28);
    background: rgba(255,204,128,.10);
}
.session-timer.danger {
    color: #ff8a80;
    border-color: rgba(255,138,128,.30);
    background: rgba(255,138,128,.10);
}
.quota-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 14px;
    padding: 16px 24px 0;
}
.quota-card {
    display: flex;
    align-items: center;
    gap: 13px;
    background: rgba(20,20,20,.9);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 15px;
}
.quota-icon, .feature-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: #242424;
    border: 1px solid #333;
}
.quota-icon { width: 42px; height: 42px; border-radius: 12px; }
.quota-icon img { width: 22px; height: 22px; opacity: .92; }
.quota-card strong { display: block; font-size: 21px; line-height: 1; margin-bottom: 5px; }
.quota-card span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tab-panel { display: none; padding: 24px; }
.tab-panel.active { display: grid; }
#toolsTab {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.feature-list, .tool-panel, .history-panel {
    background: rgba(20,20,20,.92);
    border: 1px solid var(--border);
    border-radius: 16px;
}
.feature-list { padding: 10px; display: grid; gap: 7px; }
.feature-btn {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    border: 0;
    background: transparent;
    color: var(--muted);
    text-align: left;
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
}
.feature-btn:hover, .feature-btn.active { background: var(--surface2); color: var(--text); }
.feature-icon { width: 44px; height: 44px; border-radius: 13px; color: var(--feature-color, #8ab4f8); }
.feature-icon img { width: 23px; height: 23px; object-fit: contain; }
.feature-title { display: block; font-weight: 850; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feature-btn small { display: block; color: var(--dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-panel { padding: 22px; min-height: 520px; }
.panel-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.panel-head h2 { font-size: 23px; }
.query-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; }
.region-group { grid-column: 1 / -1; }
.region-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
input, select {
    width: 100%;
    border: 1px solid var(--border);
    background: #090909;
    color: var(--text);
    border-radius: 12px;
    padding: 13px;
    outline: none;
}
input:focus, select:focus { border-color: #777; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.form-actions .btn.primary { width: auto; min-width: 150px; }
#historyTab { display: none; }
#historyTab.active { display: block; }
.history-panel { padding: 16px; }
.history-filter { display: grid; grid-template-columns: minmax(0, 1fr) 220px auto; gap: 10px; margin-bottom: 14px; }
.history-list { display: grid; gap: 10px; }
.history-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 13px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: #151515;
}
.history-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #242424;
    border: 1px solid #333;
}
.history-icon img { width: 24px; height: 24px; object-fit: contain; }
.history-icon.photo { overflow: hidden; background: #111; }
.history-icon.photo img { width: 100%; height: 100%; object-fit: cover; }
.history-line { display: flex; align-items: center; gap: 10px; min-width: 0; margin-bottom: 3px; }
.history-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.history-main small { display: block; color: var(--dim); font-size: 11px; }
.history-by {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    color: #dcdcdc;
    font-size: 11px;
    font-weight: 800;
}
.history-main strong { font-size: 15px; }
.history-main span { font-size: 13px; }
}
.badge {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 8px;
    background: #222;
    color: #ddd;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}
.history-main { min-width: 0; }
.history-main strong, .history-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-line .badge { display: inline-block; flex: 0 0 auto; }
.empty-state { padding: 38px; text-align: center; color: var(--muted); }
.modal {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.72);
    padding: 24px;
}
.modal-card {
    width: min(920px, 100%);
    max-height: 88vh;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
}
.image-modal-card { width: min(520px, 100%); }
.image-modal-body { display: grid; place-items: center; }
.image-modal-body img {
    max-width: 100%;
    max-height: 72vh;
    border-radius: 12px;
    border: 1px solid #303030;
    background: #111;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; align-items: center; }
.close { border: 0; background: transparent; color: var(--muted); font-size: 26px; cursor: pointer; }
.copy-icon-btn,
.row-copy {
    display: inline-grid;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    border-radius: 999px;
}
.copy-icon-btn {
    width: 44px;
    height: 44px;
}
.copy-icon-btn:hover,
.row-copy:hover { background: rgba(255,255,255,.08); }
.copy-icon-btn img {
    width: 24px;
    height: 24px;
    opacity: .96;
}
.result-card { background: #202020; border: 1px solid #303030; border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.result-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; }
.result-name { font-size: 22px; font-weight: 850; margin: 8px 0 14px; }
.person-head { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 16px; align-items: center; margin-bottom: 16px; }
.person-title .result-name { margin: 0 0 10px; }
.person-photo {
    width: 92px;
    height: 112px;
    border: 1px solid #343434;
    border-radius: 13px;
    background: #141414;
    color: var(--dim);
    display: grid;
    place-items: center;
    overflow: hidden;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    padding: 0;
    cursor: pointer;
}
.person-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.person-photo.empty { cursor: default; }
.result-rows { display: grid; gap: 10px; }
.result-row {
    display: grid;
    grid-template-columns: 190px minmax(0,1fr) 34px;
    gap: 14px;
    align-items: center;
    padding: 5px 0;
}
.rl { color: var(--muted); font-weight: 800; text-transform: uppercase; }
.rv { word-break: break-word; }
.row-copy {
    width: 34px;
    height: 34px;
    justify-self: end;
    opacity: .86;
}
.row-copy img {
    width: 22px;
    height: 22px;
    display: block;
}
.copy-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 120;
    transform: translate(-50%, 12px);
    opacity: 0;
    pointer-events: none;
    background: #f5f5f5;
    color: #050505;
    border-radius: 999px;
    padding: 10px 16px;
    font-weight: 900;
    box-shadow: 0 18px 48px rgba(0,0,0,.36);
    transition: opacity .18s ease, transform .18s ease;
}
.copy-toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}
.score-badge, .nik-code { background: #303030; border-radius: 8px; padding: 5px 8px; }
.cp-map-render {
    position: relative;
    height: 320px;
    border: 1px solid #303030;
    border-radius: 14px;
    overflow: hidden;
    margin: 16px 0 12px;
    background: #101010;
}
.cp-map-render iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    filter: grayscale(1) invert(.92) contrast(.86) brightness(.72);
}
.cp-radius {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 164px;
    height: 164px;
    border-radius: 999px;
    background: rgba(255,255,255,.13);
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.cp-sector {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 122px;
    height: 92px;
    transform-origin: 50% 100%;
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    background: rgba(255,255,255,.28);
    pointer-events: none;
}
.cp-pin {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #fff;
    border: 4px solid #151515;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 2px rgba(255,255,255,.5), 0 10px 22px rgba(0,0,0,.32);
}
.cp-map-caption {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 10px 12px;
    border-radius: 11px;
    background: rgba(10,10,10,.78);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    backdrop-filter: blur(10px);
}
.cp-map-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    margin-top: 12px;
    border-radius: 24px;
    background: #fff;
    color: #050505;
    text-decoration: none;
    font-size: 14px;
    font-weight: 850;
}
.cp-map-link:hover { background: #eaeaea; }
pre { white-space: pre-wrap; word-break: break-word; }
@media (max-width: 960px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .device-strip { margin: 14px 14px 0; }
    .quota-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px 14px 0; }
    .tab-panel { padding: 14px; }
    #toolsTab { grid-template-columns: 1fr; }
    .query-form { grid-template-columns: 1fr; }
    .history-filter { grid-template-columns: 1fr; }
    .history-row { grid-template-columns: 1fr; }
    .history-icon { display: none; }
    .region-grid { grid-template-columns: 1fr; }
    .person-head { grid-template-columns: 72px minmax(0, 1fr); gap: 12px; }
    .person-photo { width: 72px; height: 92px; }
    .result-row { grid-template-columns: minmax(0,1fr) 34px; gap: 2px 10px; }
    .result-row .rl { grid-column: 1 / -1; }
    .result-row .rv { grid-column: 1; }
    .result-row .row-copy { grid-column: 2; grid-row: 2; }
}
@media (max-width: 520px) {
    .login-card { padding: 20px; border-radius: 18px; }
    .brand-logo { width: 48px; height: 48px; }
    h1 { font-size: 24px; }
    .quota-grid { grid-template-columns: 1fr; }
    .topbar nav { width: 100%; }
    .nav-btn { flex: 1; justify-content: center; }
}
