/* Dashboard + installer */

:root {
    --accent: #0086fd;
    --accent-dark: #06b6d4;
    --on-accent: #fff;
    --accent-soft-light: #0c2438;
    --accent-soft-dark: #0c2438;
    --accent-soft: var(--accent-soft-dark);

    --bg: #05080c;
    --surface: #0d1420;
    --surface-2: #121b29;
    --text: #e8edf5;
    --muted: #94a3b8;
    --border: #1e2b3d;
    --ok: #2ee68a;
    --ok-bg: #0f2a1e;
    --warn: #fbbf24;
    --warn-bg: #2a2110;
    --err: #f87171;
    --err-bg: #2b1515;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 26px rgba(0, 0, 0, .45);
}

:root[data-theme="light"] {
    --accent-soft: var(--accent-soft-light);
    --bg: #f4f6f9;
    --surface: #fff;
    --surface-2: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --ok: #15803d;
    --ok-bg: #e9f8ef;
    --warn: #a16207;
    --warn-bg: #fef6e0;
    --err: #b42318;
    --err-bg: #fdeceb;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    transition: background-color .35s ease, color .35s ease;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1, h2, h3 { letter-spacing: -.01em; }

.topbar, .panel, .stat, .auth-box, input, select, textarea {
    transition: background-color .35s ease, border-color .35s ease, color .35s ease, box-shadow .35s ease;
}

::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
}

.theme-toggle:hover { color: var(--text); background: var(--surface-2); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
.theme-toggle .icon { margin: 0; }

.auth-box { position: relative; }
.auth-box .theme-toggle { position: absolute; top: 18px; right: 18px; }

.back-home {
    position: fixed;
    top: 24px;
    left: 24px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 13px 8px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: .86rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .2s, border-color .2s, color .2s;
    z-index: 5;
}

.back-home:hover { color: var(--text); background: var(--surface-2); }
.back-home .icon { margin: 0; }

@media (max-width: 480px) {
    .back-home { position: static; margin: 0 0 18px; }
}

.icon { flex: 0 0 auto; vertical-align: -.2em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }

/* ----------------------------------------------------------------- topbar */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 60px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 9px;
}

.brand-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
}

.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

.navlink {
    color: var(--muted);
    text-decoration: none;
    padding: 8px 11px;
    border-radius: 9px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.navlink:hover { background: var(--surface-2); color: var(--text); }
.navlink.active { background: var(--accent); color: #fff; }

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.page-head h1 { margin: 0; font-size: 1.45rem; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.page-head .spacer { margin-left: auto; }

/* ------------------------------------------------------------------ panels */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel + .panel { margin-top: 18px; }
.panel-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.panel-head h2 { margin: 0; font-size: 1rem; }
.panel-head .spacer { margin-left: auto; }
.panel-body { padding: 18px; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 17px;
    box-shadow: var(--shadow);
}

.stat b { display: block; font-size: 1.7rem; line-height: 1.1; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }

/* ------------------------------------------------------------------ tables */

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

table.list {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

table.list th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}

table.list td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--surface-2); }

.person { display: flex; align-items: center; gap: 11px; min-width: 0; }

.ava {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    flex: 0 0 auto;
}

.ava-fallback {
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: .85rem;
    color: var(--on-accent);
    background: linear-gradient(140deg, var(--accent), var(--accent-dark));
}

.person strong { display: block; }
.person small { color: var(--muted); }

.qr-thumb {
    width: 48px;
    height: 48px;
    display: block;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    image-rendering: pixelated;
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .73rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
}

.badge-on { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-off { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.actions-cell { display: flex; gap: 6px; justify-content: flex-end; }

/* ----------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, filter .12s ease;
}

.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn-danger { color: var(--err); border-color: var(--border); }
.btn-danger:hover { background: var(--err-bg); }
.btn-google {
    background: #fff;
    border-color: #dadce0;
    color: #3c4043;
    font-weight: 600;
}

.btn-google:hover { background: #f7f8f8; border-color: #c9ccd1; }

@media (prefers-color-scheme: dark) {
    .btn-google { background: #fff; color: #3c4043; }
}

.btn-sm { min-height: 34px; padding: 0 11px; font-size: .86rem; }
.btn-icon { width: 34px; padding: 0; min-height: 34px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------------- forms */

.field { margin-bottom: 15px; }
.field label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); font-size: .79rem; margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=tel], input[type=number], select, textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

textarea { min-height: 96px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}

input[type=color] {
    width: 54px;
    height: 42px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

input[type=file] {
    width: 100%;
    padding: 9px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    font: inherit;
    color: var(--muted);
}

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

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

.inline { display: flex; align-items: center; gap: 10px; }

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    margin-bottom: 15px;
}

.check input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; }
.check span { font-size: .88rem; }
.check strong { display: block; }

.form-footer {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 15px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    flex-wrap: wrap;
}

.form-footer .spacer { margin-left: auto; }

fieldset { border: 0; padding: 0; margin: 0 0 6px; }
legend {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    font-weight: 700;
    padding: 0 0 10px;
}

/* ------------------------------------------------------------------ alerts */

.alert {
    padding: 12px 15px;
    border-radius: 11px;
    margin-bottom: 15px;
    font-size: .9rem;
}

.alert p { margin: 5px 0 0; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-err { background: var(--err-bg); color: var(--err); }
.alert code { background: rgba(0, 0, 0, .08); padding: 1px 5px; border-radius: 5px; }

.code-block {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 13px;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state h3 { margin: 0 0 6px; color: var(--text); }

/* -------------------------------------------------------------- auth pages */

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 28px 18px;
}

.auth-box {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.auth-logo { display: block; margin: 0 0 14px; }
.auth-box h1 { margin: 0 0 4px; font-size: 1.3rem; }
.auth-box h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 24px 0 12px; }
.auth-box > p.muted { margin: 0 0 20px; font-size: .9rem; }

.req-list { margin: 0 0 22px; display: grid; gap: 6px; }

.req {
    display: flex;
    gap: 9px;
    align-items: center;
    font-size: .86rem;
    padding: 7px 11px;
    border-radius: 9px;
    background: var(--surface-2);
}

.req em { color: var(--muted); font-size: .8rem; margin-left: auto; }
.req span { font-weight: 700; }
.req-ok span { color: var(--ok); }
.req-bad { background: var(--err-bg); }
.req-bad span { color: var(--err); }
.req-warn { background: var(--warn-bg); }
.req-warn span { color: var(--warn); }

/* ------------------------------------------------------------- qr workshop */

.qr-layout {
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

@media (max-width: 760px) {
    .qr-layout { grid-template-columns: 1fr; }
}

.qr-preview {
    display: grid;
    justify-items: center;
    gap: 14px;
    padding: 22px;
}

.qr-stage {
    background: #fff;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    line-height: 0;
}

.qr-stage img { width: 240px; height: 240px; display: block; image-rendering: pixelated; }

/* ------------------------------------------------------------- print sheet */

.sheet {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.sheet-item {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    background: var(--surface);
    break-inside: avoid;
}

.sheet-item img { width: 100%; max-width: 150px; height: auto; image-rendering: pixelated; }
.sheet-item strong { display: block; font-size: .85rem; margin-top: 6px; }
.sheet-item span { display: block; font-size: .72rem; color: var(--muted); }

@media print {
    .topbar, .page-head, .no-print { display: none !important; }
    body { background: #fff; }
    .wrap { padding: 0; max-width: none; }
    .panel { border: 0; box-shadow: none; }
    .panel-body { padding: 0; }
    .sheet { grid-template-columns: repeat(3, 1fr); gap: 6mm; }
    .sheet-item { border: 1px dashed #bbb; }
    .sheet-item span, .sheet-item strong { color: #000; }
}

/* ------------------------------------------------------------ plan usage */

.usage {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.usage-bar {
    display: block;
    width: 54px;
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.usage-bar span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
}

.usage-full { color: var(--warn); border-color: var(--warn); }
.usage-full .usage-bar span { background: var(--warn); }

.topbar-admin { border-bottom-width: 2px; border-bottom-color: var(--accent-dark); }

/* --------------------------------------------------------------- pricing */

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--muted);
    font-size: .82rem;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.plan-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.plan-card h3 { margin: 0 0 4px; font-size: 1.12rem; }
.plan-card > p.muted { margin: 0 0 14px; font-size: .88rem; }

.plan-current { border-color: var(--accent); border-width: 2px; }

.plan-flag {
    position: absolute;
    top: -10px;
    right: 16px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 999px;
}

.plan-price {
    margin: 0 0 4px;
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.plan-features {
    list-style: none;
    margin: 14px 0 16px;
    padding: 0;
    display: grid;
    gap: 8px;
    font-size: .89rem;
}

.plan-features li {
    display: flex;
    align-items: flex-start;
    gap: 9px;
}

.plan-features .icon { color: var(--ok); margin-top: 3px; }

.plan-card .btn:last-child { margin-top: auto; }
