/* Niz-Tech customer portal — matches niztechusa.com */
:root {
  --bg: #07080b; --bg-2: #0c0e13; --surface: #11141a; --surface-2: #171b23;
  --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14);
  --text: #f4f5f7; --muted: #9aa2b1; --red: #e31b23; --red-2: #ff4146; --green: #3ddc84; --amber: #fbbf24;
  --radius: 16px;
  --font-head: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --ease: cubic-bezier(.2,.7,.2,1);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.55 var(--font-body); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
h1, h2, h3 { font-family: var(--font-head); font-stretch: 118%; letter-spacing: -.01em; line-height: 1.1; margin: 0; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; }
.h2, h2 { font-size: 1.45rem; font-weight: 750; }
.h3, h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0; }
code { font-family: var(--font-mono); font-size: .9em; background: rgba(255,255,255,.06); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font: 500 .72rem/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--red-2); margin-bottom: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red-2); display: inline-block; flex-shrink: 0; }
.dot--live { animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,65,70,.6); } 70% { box-shadow: 0 0 0 9px rgba(255,65,70,0); } 100% { box-shadow: 0 0 0 0 rgba(255,65,70,0); } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 .92rem/1 var(--font-body); padding: 12px 18px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; transition: background .2s, border-color .2s, transform .2s var(--ease); }
.btn--primary { background: linear-gradient(180deg, var(--red-2), var(--red)); box-shadow: 0 8px 24px -8px rgba(227,27,35,.5), inset 0 1px 0 rgba(255,255,255,.2); color: #fff; }
.btn--primary:hover { transform: translateY(-1px); }
.btn--ghost { background: rgba(255,255,255,.04); border-color: var(--line-2); }
.btn--ghost:hover { background: rgba(255,255,255,.09); }
.btn--danger { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.4); color: #fecaca; }
.btn--danger:hover { background: rgba(248,113,113,.22); }
.btn--sm { padding: 8px 14px; font-size: .84rem; }
.btn--block { width: 100%; }
.iconbtn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(255,255,255,.04); color: var(--text); cursor: pointer; font-size: 1.2rem; }
.iconbtn:hover { background: rgba(255,255,255,.1); }
.linkbtn { background: none; border: 0; padding: 6px 0; color: #c9ced8; font: 500 .9rem var(--font-body); cursor: pointer; text-align: left; }
.linkbtn:hover { color: #fff; text-decoration: underline; }
.linkbtn--danger { color: #fca5a5; }
:focus-visible { outline: 2px solid var(--red-2); outline-offset: 2px; }

/* ---------- app bar ---------- */
.appbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; height: 64px; padding: 0 clamp(14px, 3vw, 28px); background: rgba(7,8,11,.85); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { background: #fff; border-radius: 9px; padding: 2px; }
.brand span { display: flex; flex-direction: column; font: 800 .98rem/1 var(--font-head); font-stretch: 125%; letter-spacing: .02em; }
.brand small { font: 500 .6rem/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 4px; font-stretch: normal; }
.appbar__nav { display: flex; gap: 4px; }
.appbar__nav a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: #c9ced8; font-weight: 500; font-size: .92rem; }
.appbar__nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.appbar__nav a.is-active { color: #fff; background: rgba(255,255,255,.08); }
.appbar__user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.appbar__user form { margin: 0; }
.appbar__who { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.appbar__who small { color: var(--muted); font: 500 .68rem var(--font-mono); text-transform: uppercase; letter-spacing: .06em; }

.main { padding: clamp(18px, 3vw, 32px) clamp(14px, 3vw, 28px) 60px; max-width: 1500px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-content: start; }
.main > *, .cols > * { min-width: 0; }
.appbar__nav a { white-space: nowrap; }
.narrow { max-width: 520px; width: 100%; margin: 4vh auto 0; }

/* ---------- page head / toolbar ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 4px; }
.backlink { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: .88rem; margin-bottom: 8px; }
.backlink:hover { color: #fff; }
.backlink svg { width: 16px; height: 16px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.seg button { display: grid; place-items: center; width: 38px; height: 34px; border: 0; border-radius: 9px; background: none; color: var(--muted); cursor: pointer; }
.seg button.is-on { background: rgba(255,255,255,.1); color: #fff; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font: 500 .84rem var(--font-body); padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: #c9ced8; cursor: pointer; }
.chip.is-on { background: #fff; color: #0b0d12; border-color: #fff; }
.relay { display: inline-flex; align-items: center; gap: 8px; font: 500 .74rem var(--font-mono); text-transform: uppercase; letter-spacing: .05em; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line-2); }
.relay--ok .dot { background: var(--green); }
.relay--down { color: #fecaca; border-color: rgba(248,113,113,.4); }

/* ---------- camera grid ---------- */
.grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid[data-layout="1"] { grid-template-columns: 1fr; }
.grid[data-layout="9"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000 radial-gradient(circle at 50% 50%, #151a23, #06070a 70%); border: 1px solid var(--line); isolation: isolate; }
.tile[hidden] { display: none; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: transparent; z-index: -1; }
.tile__top { position: absolute; inset: 0 0 auto 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 14px 28px; background: linear-gradient(180deg, rgba(0,0,0,.7), transparent); }
.tile__title { display: flex; flex-direction: column; min-width: 0; }
.tile__title strong { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__title span { font: 500 .7rem var(--font-mono); color: #c9ced8; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; align-items: center; gap: 6px; font: 600 .66rem/1 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; padding: 6px 9px; border-radius: 999px; background: rgba(7,8,11,.7); border: 1px solid var(--line-2); flex-shrink: 0; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.tile[data-state="live"] .pill { border-color: rgba(255,65,70,.6); }
.tile[data-state="live"] .pill::before { background: var(--red-2); animation: pulse 1.8s infinite; }
.tile[data-state="connecting"] .pill::before { background: var(--amber); animation: blink 1s infinite; }
.tile[data-state="offline"] .pill::before { background: #6b7280; }
@keyframes blink { 50% { opacity: .2; } }
.tile__msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); font-size: .9rem; pointer-events: none; }
.tile__msg:empty { display: none; }
.tile[data-state="connecting"] .tile__msg:empty { display: grid; }
.tile[data-state="connecting"] .tile__msg:empty::after { content: ""; width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); border-top-color: var(--red-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tile__actions { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s var(--ease); }
.tile:hover .tile__actions, .tile:focus-within .tile__actions { opacity: 1; transform: none; }
@media (hover: none) { .tile__actions { opacity: 1; transform: none; } }
.tile__actions > * { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(7,8,11,.75); color: #fff; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tile__actions > *:hover { background: var(--red); border-color: var(--red); }
.tile__actions .hdbtn { width: auto; padding: 0 10px; font: 700 .72rem/1 var(--font-mono); letter-spacing: .04em; }
.tile__actions .hdbtn.is-on { background: #fff; color: #0b0d12; border-color: #fff; }
.tile__actions .hdbtn:disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.tile__actions .hdbtn:disabled:hover { background: rgba(7,8,11,.75); border-color: var(--line-2); }
.streamlabel { display: inline-block; min-width: 62px; font: 500 .64rem/1 var(--font-mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.streamlabel--hd { color: #fff; }
.tile:fullscreen { border-radius: 0; border: 0; aspect-ratio: auto; }
.tile:fullscreen .tile__actions { opacity: 1; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--muted); font: 500 .8rem var(--font-mono); }
.pager[hidden] { display: none; }

.solo { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.tile--solo { border-radius: 16px; }
.solo__list h3 { font-size: .8rem; font-family: var(--font-mono); font-stretch: normal; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.solo__list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 70vh; overflow: auto; }
.solo__list a { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; text-decoration: none; }
.solo__list a:hover { background: rgba(255,255,255,.05); }
.solo__list span:last-child { display: flex; flex-direction: column; }
.solo__list small { color: var(--muted); font-size: .78rem; }
.solo__list .dot { background: var(--muted); }

.idle { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(7,8,11,.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.idle[hidden] { display: none; }
.idle .card { max-width: 420px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.idle .card > svg { width: 34px; height: 34px; color: var(--red-2); }

/* ---------- cards, forms, tables ---------- */
.card { background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--line-2); border-radius: var(--radius); padding: clamp(18px, 2.4vw, 26px); }
.card__head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.cols > .card { display: grid; gap: 14px; align-content: start; }
.form { display: grid; gap: 14px; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form > .btn, .cols > .card > .btn { justify-self: start; }
.form > .btn--block { justify-self: stretch; }
.form__actions { display: flex; gap: 10px; flex-wrap: wrap; }
label { display: grid; gap: 6px; font-size: .84rem; font-weight: 500; color: #c3c8d2; }
input, select, textarea { width: 100%; font: 400 .98rem/1.4 var(--font-body); color: var(--text); background: rgba(7,8,11,.6); border: 1px solid var(--line-2); border-radius: 10px; padding: 11px 13px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(227,27,35,.2); }
input:disabled { opacity: .6; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--red); padding: 0; margin: 0; }
.check, .radio { display: flex; align-items: center; gap: 9px; font-weight: 400; color: var(--text); }
.check small { color: var(--muted); }
.access { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 0; display: grid; gap: 8px; }
.access legend { font: 500 .72rem var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; padding-left: 25px; }
.danger { border-color: rgba(248,113,113,.3); }
.tablewrap { margin: 0 -6px; } /* no overflow clipping on desktop, so Edit/Manage panels aren't cut off */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font: 500 .7rem var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table a { text-decoration: none; }
.table a:hover strong { text-decoration: underline; }
.actions { text-align: right; white-space: nowrap; }
.tag { display: inline-block; font: 500 .68rem/1 var(--font-mono); text-transform: uppercase; letter-spacing: .05em; padding: 5px 8px; border-radius: 6px; background: rgba(255,255,255,.07); color: #c9ced8; }
.tag--owner, .tag--admin { background: rgba(227,27,35,.15); color: #ffb3b5; }
.tag--ok { background: rgba(61,220,132,.12); color: #86efac; }
.tag--off { background: rgba(248,113,113,.12); color: #fca5a5; }
.menu { position: relative; display: inline-block; text-align: left; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu__panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: min(420px, 86vw); display: grid; gap: 2px; box-shadow: 0 24px 60px -10px rgba(0,0,0,.7); white-space: normal; }
.table code { word-break: break-all; }
.inline { margin: 0; }
.addbox { margin-top: 16px; }
.addbox summary { list-style: none; display: inline-flex; }
.addbox summary::-webkit-details-marker { display: none; }
.addbox[open] summary { margin-bottom: 14px; }
.flash { padding: 12px 14px; border-radius: 12px; font-size: .92rem; border: 1px solid; }
.flash--ok { background: rgba(61,220,132,.1); border-color: rgba(61,220,132,.35); color: #a7f3c7; }
.flash--warn { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.35); color: #fde68a; }
.flash--err { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.35); color: #fecaca; }
.empty { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 48px 24px; }
.empty > svg { width: 36px; height: 36px; color: var(--muted); }
.creds dl { display: grid; gap: 12px; margin: 20px 0; }
.creds dt { font: 500 .7rem var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.creds dd { margin: 0; }
.creds code { font-size: 1rem; padding: 6px 10px; }
.creds { display: grid; gap: 10px; }

/* ---------- sign-in ---------- */
.authpage { background: var(--bg); }
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth__brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(24px, 4vw, 48px); overflow: hidden; border-right: 1px solid var(--line);
  background:
    radial-gradient(circle at 80% 20%, rgba(227,27,35,.28), transparent 55%),
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 56px 56px,
    var(--bg-2); }
.auth__pitch { max-width: 520px; }
.auth__pitch h1 { font-size: clamp(2rem, 4vw, 3.2rem); margin-bottom: 26px; }
.auth__points { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.auth__points li { display: flex; gap: 12px; align-items: center; color: #c3c8d2; }
.auth__points svg { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: rgba(227,27,35,.14); color: var(--red-2); border: 1px solid rgba(227,27,35,.3); }
.auth__points strong { color: #fff; }
.auth__panel { display: grid; place-items: center; align-content: center; gap: 18px; padding: 32px 20px; }
.auth__form { width: min(420px, 100%); }
.auth__back { color: var(--muted); text-decoration: none; }
.auth__back:hover { color: #fff; }
.authpage > main > .flash { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 5; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .solo { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .appbar { gap: 10px; }
  .appbar__who { display: none; }
  .brand small { display: none; }
  .appbar__nav a { padding: 8px 10px; font-size: .86rem; }
  .grid, .grid[data-layout="9"] { grid-template-columns: 1fr; }
  .form__row { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth__brand { min-height: auto; gap: 28px; border-right: 0; border-bottom: 1px solid var(--line); }
  .auth__points { display: none; }
  .auth__pitch h1 { margin-bottom: 0; font-size: 1.7rem; }
  .auth__foot { display: none; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .tablewrap { overflow-x: auto; } /* panels are fixed-position on phones, so scrolling is safe here */
  .menu__panel { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; max-height: 80vh; overflow: auto; }
}
@media (max-width: 480px) {
  .appbar .brand span { display: none; }
  .appbar__nav { gap: 0; }
}
