/* Phone Mirror - web UI */
:root {
  --brand: #4f46e5; --brand2: #7c3aed; --bg: #f4f6fb; --surface: #fff;
  --text: #0f172a; --muted: #64748b; --line: #e5e9f2;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --r: 16px; --hdr: 60px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body[data-view="view"] { overflow: hidden; }
h1, h2, h5 { margin: 0; }
.muted { color: var(--muted); }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- header ---------- */
.app-header { position: sticky; top: 0; z-index: 20; height: var(--hdr); display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; padding-top: env(safe-area-inset-top); background: linear-gradient(120deg, var(--brand), var(--brand2)); color: #fff;
  box-shadow: 0 2px 14px rgba(79, 70, 229, .35); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .18); display: grid; place-items: center; }
.hdr-right { display: flex; align-items: center; gap: 10px; }
.who { font-size: .85rem; background: rgba(255, 255, 255, .16); padding: 4px 12px; border-radius: 999px; }

/* ---------- buttons ---------- */
.btn-icon { width: 40px; height: 40px; border-radius: 12px; border: 0; display: inline-grid; place-items: center; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff; transition: background .15s; }
.btn-icon:hover { background: rgba(255, 255, 255, .26); }
.panel .btn-icon { background: #eef0f7; color: var(--text); }
.btn-brand { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 12px; padding: .65rem 1.15rem; font-weight: 600; color: #fff; cursor: pointer;
  background: linear-gradient(120deg, var(--brand), var(--brand2)); box-shadow: 0 6px 16px rgba(79, 70, 229, .3); transition: transform .1s, box-shadow .15s; }
.btn-brand:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(79, 70, 229, .38); }
.btn-brand:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 12px; padding: .6rem .9rem; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-ghost:hover { background: #f4f6fb; }
.btn-ghost.sm { padding: .35rem .7rem; font-size: .82rem; margin-top: 8px; }
.btn-ghost.danger:hover { background: #fee2e2; color: #b91c1c; }
.btn-ghost.danger.confirm { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.w-100 { width: 100%; justify-content: center; }

/* ---------- sign in ---------- */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: calc(100vh - var(--hdr)); min-height: calc(100dvh - var(--hdr)); }
.auth-hero { background: linear-gradient(145deg, #4338ca, #7c3aed 60%, #a855f7); color: #fff; padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; }
.auth-hero h1 { font-size: clamp(2rem, 4.4vw, 3.2rem); font-weight: 800; line-height: 1.08; margin-bottom: 14px; }
.auth-hero p { font-size: 1.05rem; opacity: .9; max-width: 30rem; }
.auth-hero ul { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; }
.auth-hero li { display: flex; align-items: center; gap: 10px; }
.auth-hero li .ic { background: rgba(255, 255, 255, .2); border-radius: 50%; padding: 3px; width: 24px; height: 24px; }
.auth-card { align-self: center; justify-self: center; width: min(420px, 92%); margin: 24px 0; background: #fff; border: 1px solid var(--line);
  border-radius: 20px; padding: 26px; box-shadow: 0 20px 50px rgba(15, 23, 42, .1); }
.tabs { display: flex; background: #eef0f7; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 6px; }
.tab { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 600; color: #475569; cursor: pointer; }
.tab.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(15, 23, 42, .12); }
.lbl { display: block; font-weight: 600; font-size: .85rem; margin: 14px 0 6px; }
.form-msg { min-height: 22px; margin-top: 12px; font-size: .88rem; color: var(--bad); }
.form-msg.ok { color: var(--ok); }
.form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .18); }

/* ---------- phones page ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 28px 18px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h2 { font-size: 1.6rem; font-weight: 700; }
.pm-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: 0 6px 24px rgba(15, 23, 42, .05); margin-bottom: 16px; }
.pm-card h5 { font-weight: 700; margin-bottom: 12px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-row .form-control { flex: 1 1 220px; }

.pair { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; }
.pair-qr { text-align: center; }
#qr { width: 240px; max-width: 100%; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
#qr svg { display: block; width: 100%; height: auto; }
.steps { padding-left: 1.2rem; margin: 0 0 14px; display: grid; gap: 8px; }
.url-row { display: flex; gap: 8px; align-items: center; }
.url-row code { flex: 1; background: #f1f4fb; padding: 8px 10px; border-radius: 10px; font-size: .8rem; word-break: break-all; color: #334155; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.dev { display: flex; flex-direction: column; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 18px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, .05); transition: transform .15s, box-shadow .15s; }
.dev:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(15, 23, 42, .1); }
.dev-top { display: flex; gap: 12px; align-items: center; min-width: 0; }
.avatar { width: 46px; height: 46px; border-radius: 14px; background: linear-gradient(135deg, #e0e7ff, #ede9fe); color: var(--brand); display: grid; place-items: center; flex: none; }
.avatar .ic { width: 24px; height: 24px; }
.dev-info { min-width: 0; display: grid; gap: 4px; }
.dev-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-actions { display: flex; gap: 8px; }
.dev-actions .btn-brand { flex: 1; justify-content: center; }
.empty { grid-column: 1 / -1; text-align: center; padding: 48px 16px; border: 2px dashed #cdd5e6; border-radius: var(--r); color: var(--muted); }
.empty .ic { width: 44px; height: 44px; color: var(--brand); margin-bottom: 8px; }

.pill { display: inline-flex; align-items: center; gap: 6px; width: fit-content; font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #f1f5f9; color: #64748b; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: #dcfce7; color: #15803d; }
.pill.live { background: #e0e7ff; color: #4338ca; }
.pill.live::before { animation: pulse 1.4s infinite; }
.pill.warn { background: #fef3c7; color: #b45309; }
.pill.bad { background: #fee2e2; color: #b91c1c; }

/* ---------- live viewer ---------- */
.viewer { display: flex; flex-direction: column; height: calc(100vh - var(--hdr)); height: calc(100dvh - var(--hdr)); background: #0b1020; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: #0f172a; color: #fff; }
.vtitle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.vtitle b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vactions { display: flex; gap: 8px; }
.viewer-body { flex: 1; min-height: 0; display: flex; }
.stage { flex: 1; min-width: 0; position: relative; overflow: auto; display: flex; padding: 12px;
  background: radial-gradient(circle at 50% 30%, #1e2748, #0b1020 70%); }
.stage canvas { margin: auto; flex: none; background: #000; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6), 0 0 0 6px #1b2342; }
.stage:fullscreen { padding: 0; background: #000; }
.stage:fullscreen canvas { border-radius: 0; box-shadow: none; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; text-align: center;
  padding: 20px; color: #cbd5e1; background: rgba(11, 16, 32, .74); backdrop-filter: blur(2px); transition: opacity .25s; }
.overlay.hide { opacity: 0; pointer-events: none; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255, 255, 255, .2); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }

.panel { width: 320px; flex: none; background: var(--surface); border-left: 1px solid var(--line); padding: 18px; overflow: auto; }
.viewer.no-panel .panel { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h5 { font-weight: 700; }
.field { margin-bottom: 20px; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-weight: 600; font-size: .92rem; }
.field-top small { font-weight: 400; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #eef0f7; border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 9px 6px; border-radius: 10px; font-weight: 600; font-size: .85rem; color: #475569; cursor: pointer; }
.seg button.active { background: #fff; color: var(--brand); box-shadow: 0 1px 5px rgba(15, 23, 42, .15); }
.rng { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; background: #dfe3f0; outline: none; }
.rng::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); cursor: pointer; }
.rng::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--brand); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); cursor: pointer; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; cursor: pointer; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: #f4f6fb; border-radius: 12px; padding: 8px 10px; display: grid; gap: 2px; }
.stats small { color: var(--muted); font-size: .7rem; }
.stats b { font-size: .82rem; }

.toast-lite { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 90vw; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.toast-lite.show { opacity: 1; transform: translate(-50%, 0); }
.toast-lite.err { background: #b91c1c; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; min-height: 0; }
  .auth-hero { padding: 32px 24px; }
  .auth-hero ul { display: none; }
  .pair { grid-template-columns: 1fr; justify-items: center; }
  .pair-steps { width: 100%; }
  .page { padding-top: 18px; }
  .btn-brand span { display: inline; }
  .panel { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 75vh; max-height: 75dvh; border-left: 0; border-radius: 20px 20px 0 0; z-index: 30;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .35); transform: translateY(105%); transition: transform .25s; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .panel.open { transform: none; }
  .viewer.no-panel .panel { display: block; }
  .stage { padding: 6px; }
  .stage canvas { border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); }
}
@media (max-width: 480px) {
  .page-head h2 { font-size: 1.3rem; }
  .grid { grid-template-columns: 1fr; }
}

/* ---------- fallbacks so the page also works when Bootstrap (CDN) is not reachable on an offline LAN ---------- */
.d-none { display: none !important; }
.who:empty { display: none !important; }
@media (min-width: 576px) { .d-sm-inline { display: inline !important; } }
@media (min-width: 768px) { .d-md-none { display: none !important; } }
.mt-2 { margin-top: .5rem; } .mt-3 { margin-top: 1rem; } .mb-0 { margin-bottom: 0; } .m-0 { margin: 0; }
.d-flex { display: flex; } .align-items-center { align-items: center; } .justify-content-between { justify-content: space-between; }
.small { font-size: .85rem; }
:where(.form-control) { display: block; width: 100%; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--text); }
:where(.form-control-lg) { padding: .75rem .95rem; font-size: 1.02rem; }
:where(.form-check-input) { width: 2.6em; height: 1.4em; }

/* ================= accounts, subscriptions, admin ================= */
.brand-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; }
.brand-mark.lg { width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(120deg, var(--brand), var(--brand2)); color: #fff; }
.brand-mark.lg .ic { width: 30px; height: 30px; }
.nav-link-pm { color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .12); white-space: nowrap; }
.nav-link-pm:hover { background: rgba(255, 255, 255, .26); color: #fff; }
.pg { max-width: 1100px; margin: 0 auto; padding: 28px 18px 70px; }
.pg h2 { font-size: 1.6rem; font-weight: 700; }
.center-card { max-width: 440px; margin: 40px auto; text-align: center; padding: 30px 24px; }
.center-card .lbl { text-align: left; }
.center-card .form-msg { text-align: left; }
.big-ico { font-size: 3rem; line-height: 1; margin-bottom: 10px; }
.note-warn { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.sub-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.add-row { display: flex; gap: 10px; flex-wrap: wrap; }
.add-row .form-control { flex: 1; min-width: 200px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-col > .pm-card { margin-bottom: 16px; }

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.plan { position: relative; border: 1.5px solid var(--line); border-radius: 14px; padding: 20px 16px 16px; text-align: center; background: #fff; }
.plan.featured { border-color: var(--brand); box-shadow: 0 8px 24px rgba(79, 70, 229, .18); }
.plan-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--ok); color: #fff; font-size: .7rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.plan-name { font-weight: 700; font-size: 1.05rem; }
.plan-price { font-size: 1.9rem; font-weight: 800; margin: 6px 0 2px; color: var(--brand); }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid #f0f2f8; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .flags { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 0; }
.tbl .acts { text-align: right; }
.tbl .acts .btn-ghost { margin: 2px 0 2px 4px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.pager .btn-ghost { margin-top: 0; }

.admin-tabs { display: flex; gap: 6px; overflow-x: auto; background: #eef0f7; border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.atab { border: 0; background: transparent; padding: 9px 16px; border-radius: 9px; font-weight: 600; color: #475569; cursor: pointer; white-space: nowrap; }
.atab.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(15, 23, 42, .12); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat small { display: block; color: var(--muted); font-weight: 600; font-size: .75rem; margin-bottom: 4px; }
.stat b { font-size: 1.4rem; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.checklist li > span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; color: #fff; flex: none; margin-top: 1px; }
.checklist li.ok > span { background: var(--ok); }
.checklist li.no > span { background: var(--warn); }
.vgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; }
.sm-btn { padding: .35rem .9rem; font-size: .85rem; }
.logo-prev { display: flex; align-items: center; gap: 14px; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: .88rem; }
.auth-links a, .link-btn { color: var(--brand); background: none; border: 0; padding: 0; font-weight: 600; cursor: pointer; text-decoration: none; }
.sub-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; background: #e0e7ff; color: #3730a3; font-size: .92rem; }
.sub-bar.warn { background: #fef3c7; color: #92400e; }
.sub-bar.bad { background: #fee2e2; color: #991b1b; }
.sub-bar a { font-weight: 700; color: inherit; }
@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; }
  .nav-link-pm { padding: 6px 9px; font-size: .8rem; }
  .brand-name { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tbl .acts { text-align: left; }
}
.center-card .spinner { border-color: #e5e9f2; border-top-color: var(--brand); }
