:root {
  --bg: #f4f6f8; --card: #fff; --ink: #18202a; --muted: #5d6b7a; --line: #dde3ea;
  --brand: #1f7a4d; --brand-ink: #fff; --brand-soft: #e6f3ec;
  --danger: #c0392b; --warn: #b7791f; --ok: #1f7a4d;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.hidden { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.2rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.logo { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: #fff; font-size: 15px; }
.spacer { flex: 1; }
.topbar .who { font-size: .85rem; color: var(--muted); text-align: right; }

/* layout */
.wrap { max-width: 1100px; margin: 0 auto; padding: 1.2rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; }
.auth-card { max-width: 420px; margin: 6vh auto 2rem; }

/* forms */
label { display: block; font-weight: 600; font-size: .85rem; margin: .8rem 0 .3rem; }
input[type=text], input[type=email], input[type=tel], input[type=password] {
  width: 100%; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff;
}
input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.code-input { font-size: 1.6rem; letter-spacing: .5rem; text-align: center; font-variant-numeric: tabular-nums; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f0f3f6; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: .35rem .6rem; font-size: .82rem; }
.btn.block { width: 100%; margin-top: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.msg { margin-top: .8rem; padding: .6rem .8rem; border-radius: 8px; font-size: .9rem; }
.msg.err { background: #fdecea; color: var(--danger); }
.msg.ok { background: var(--brand-soft); color: var(--ok); }

.tabs { display: flex; border-bottom: 1px solid var(--line); margin: -.2rem 0 1rem; }
.tabs button { flex: 1; background: none; border: 0; padding: .7rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-color: var(--brand); }

.steps { padding-left: 1.2rem; margin: .4rem 0; } .steps li { margin: .25rem 0; }
.qr { display: grid; place-items: center; padding: .8rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; margin: .8rem 0; min-height: 200px; }
.qr img, .qr svg { width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: #f2f4f7; padding: .45rem .6rem; border-radius: 6px; word-break: break-all; font-size: .9rem; }

/* my id */
.myid { font-size: 2.1rem; font-weight: 800; letter-spacing: .08em; font-variant-numeric: tabular-nums; color: var(--brand); }
.connect-input { font-size: 1.4rem; letter-spacing: .12em; text-align: center; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef1f4; color: var(--muted); }
.pill.on { background: var(--brand-soft); color: var(--ok); }
.pill.warn { background: #fdf3e1; color: var(--warn); }
.pill.off { background: #fdecea; color: var(--danger); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,32,.5); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal { background: #fff; border-radius: var(--radius); padding: 1.4rem; width: min(440px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); }

/* session */
.session { position: fixed; inset: 0; background: #0f141a; z-index: 40; display: flex; flex-direction: column; }
.session-bar { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; background: #1a222c; color: #e6edf3; flex-wrap: wrap; }
.session-bar .btn { background: #26313d; color: #e6edf3; border-color: #34414f; }
.session-bar .btn:hover { background: #2f3c4a; }
.session-bar .btn.danger { background: var(--danger); border-color: var(--danger); }
.session-bar .btn.primary { background: var(--brand); border-color: var(--brand); }
.session-bar input { background: #0f141a; color: #fff; border: 1px solid #34414f; border-radius: 6px; padding: .35rem .5rem; font: inherit; width: 200px; }
.stage { flex: 1; position: relative; display: grid; place-items: center; overflow: hidden; }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; outline: none; }
.stage video.controlling { cursor: crosshair; }
.stage .overlay { position: absolute; color: #c9d4df; text-align: center; padding: 1rem; }
.sharer-panel { max-width: 560px; margin: auto; color: #e6edf3; text-align: center; padding: 1.5rem; }
.sharer-panel video { width: 100%; max-height: 40vh; border-radius: 10px; background: #000; margin: 1rem 0; }
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; user-select: none; }
.switch input { width: 42px; height: 24px; appearance: none; background: #4a5663; border-radius: 999px; position: relative; cursor: pointer; transition: .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 21px; }
.switch input:disabled { opacity: .4; cursor: not-allowed; }
.focus-hint { position: absolute; top: .6rem; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.65); color: #fff; padding: .3rem .7rem; border-radius: 6px; font-size: .8rem; pointer-events: none; }

/* tables (admin) */
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; background: #fafbfc; position: sticky; top: 0; }
.table-wrap { overflow: auto; max-height: 65vh; border: 1px solid var(--line); border-radius: 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .9rem; }
.stat b { display: block; font-size: 1.6rem; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: #18202a; color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 100; font-size: .9rem; }
pre.cmd { background: #18202a; color: #d7e3ee; padding: .7rem .8rem; border-radius: 8px; overflow: auto; font-size: .82rem; white-space: pre-wrap; word-break: break-all; }
@media (max-width: 600px) { .myid { font-size: 1.6rem; } .session-bar input { width: 140px; } }
