/* Server dashboard layout */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100%; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px; border-right: 1px solid var(--border); background: rgba(10, 11, 16, .6); backdrop-filter: blur(10px);
}
.sidebar .logo { padding: 0 8px 18px; }
.nav a {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 550; transition: background .15s, color .15s;
}
.nav a svg { width: 17px; height: 17px; }
.nav a:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: #d4caff; }
.nav a .count { margin-left: auto; font-size: 11.5px; font-weight: 650; padding: 1px 8px; border-radius: 99px; background: rgba(255,255,255,.07); color: var(--muted); }
.nav a.active .count { background: rgba(124, 92, 255, .3); color: #fff; }
.side-section { font-size: 11px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; }
.side-foot { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); }
.side-foot .who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 13px; text-transform: uppercase; }
.side-foot .ver { font-size: 11.5px; color: var(--dim); margin-top: 10px; display: flex; justify-content: space-between; }

.main { min-width: 0; padding: 28px 34px 60px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.stat-icon svg { width: 19px; height: 19px; }
.stat-icon.violet { background: var(--accent-soft); color: #b4a3ff; }
.stat-icon.green { background: var(--green-soft); color: #4ade80; }
.stat-icon.cyan { background: rgba(34, 211, 238, .12); color: #67e8f9; }
.stat-icon.amber { background: var(--amber-soft); color: #fbbf24; }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--muted); }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .seg { flex: none; }
.toolbar .seg button { flex: none; }
.search { position: relative; width: 260px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--dim); }
.search .input { padding-left: 34px; height: 42px; }

/* stream tiles */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.grid.large { grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); }
.tile { overflow: hidden; transition: border-color .2s, transform .2s, box-shadow .2s; }
.tile:hover { border-color: var(--border-2); box-shadow: var(--shadow); }
.tile-media { position: relative; aspect-ratio: 16 / 9; background: #050608; cursor: pointer; overflow: hidden; }
.tile-media canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tile-media .data-view { position: absolute; inset: 0; margin: 0; padding: 12px 14px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font: 11.5px/1.5 var(--mono); color: #a5f3c4; white-space: pre-wrap; word-break: break-all; background: radial-gradient(400px 200px at 50% 0, rgba(34, 197, 94, .06), transparent), #050608; }
.tile-media .data-view::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, #050608 0%, transparent 30%); pointer-events: none; }
.tile-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; align-items: center; z-index: 2; pointer-events: none; }
.tile-top .tag { background: rgba(0, 0, 0, .55); border-color: rgba(255,255,255,.1); color: #d6d9e4; backdrop-filter: blur(6px); }
.tile-top .pill { backdrop-filter: blur(6px); }
.tile-top .pill.live { background: rgba(5, 46, 22, .75); }
.tile-stats { position: absolute; bottom: 10px; right: 10px; z-index: 2; font: 11.5px var(--mono); color: #d6d9e4; background: rgba(0,0,0,.55); padding: 3px 8px; border-radius: 6px; backdrop-filter: blur(6px); pointer-events: none; }
.tile-stats:empty { display: none; }
.tile-media .expand { position: absolute; top: 8px; right: 8px; z-index: 3; opacity: 0; transition: opacity .15s; background: rgba(0,0,0,.6); border-color: rgba(255,255,255,.12); }
.tile-media:hover .expand { opacity: 1; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; z-index: 1; color: var(--muted); font-size: 13px; background: rgba(5, 6, 8, .55); }
.overlay .ov-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 320px; }
.overlay .ov-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.06); color: var(--muted); }
.overlay .ov-icon svg { width: 20px; height: 20px; }
.overlay.err .ov-icon { background: var(--red-soft); color: #fb7185; }
.overlay .spinner { width: 22px; height: 22px; }
.tile-foot { display: flex; align-items: center; gap: 12px; padding: 13px 16px; }
.tile-name { font-weight: 650; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub svg { width: 13px; height: 13px; flex: none; }
.tile-foot .viewers { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tile-foot .viewers svg { width: 14px; height: 14px; }
.tile.offline .tile-media canvas { filter: grayscale(1) brightness(.5); }

/* theater */
.theater { position: fixed; inset: 0; z-index: 60; background: rgba(3, 4, 6, .92); backdrop-filter: blur(10px); display: grid; grid-template-columns: 1fr 320px; animation: fade .15s; }
.theater-stage { position: relative; display: flex; flex-direction: column; min-width: 0; }
.theater-bar { display: flex; align-items: center; gap: 10px 12px; padding: 14px 20px; flex-wrap: wrap; }
.theater-bar h2 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.theater-bar #th-dev { white-space: nowrap; }
.theater-media { position: relative; flex: 1; margin: 0 20px 20px; border-radius: 16px; overflow: hidden; background: #000; border: 1px solid var(--border); }
.theater-media canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.theater-media .data-view { position: absolute; inset: 0; margin: 0; padding: 16px 18px; overflow: auto; font: 12.5px/1.55 var(--mono); color: #a5f3c4; white-space: pre-wrap; word-break: break-all; }
.theater-media.hexmode .data-view { white-space: pre; color: #c4d4ff; }
.theater-side { border-left: 1px solid var(--border); background: var(--bg-2); padding: 20px; overflow: auto; }
.theater-side h4 { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; margin: 18px 0 10px; }
.theater-side h4:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; font-variant-numeric: tabular-nums; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }

/* devices */
.devices { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 18px; }
.device-head { display: flex; gap: 14px; align-items: center; padding: 18px 20px; }
.os-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--panel-3); border: 1px solid var(--border); flex: none; }
.os-icon svg { width: 22px; height: 22px; }
.device-head .name { font-weight: 650; font-size: 15.5px; }
.device-head .sub { color: var(--muted); font-size: 12.5px; }
.device-meta { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.device-meta > div { padding: 12px 20px; border-right: 1px solid var(--border); min-width: 0; }
.device-meta > div:last-child { border-right: 0; }
.device-meta .l { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.device-meta .v { font-size: 13.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-streams { padding: 8px 10px; }
.device-stream { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.device-stream:hover { background: rgba(255,255,255,.035); }
.device-stream .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: rgba(255,255,255,.05); color: var(--muted); flex: none; }
.device-stream .ic svg { width: 15px; height: 15px; }
.device-stream .n { font-weight: 550; }
.device-stream .t { font-size: 12px; color: var(--dim); font-family: var(--mono); }
.device-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* guest page */
body.guest { display: flex; flex-direction: column; height: 100vh; }
.guest-bar { display: flex; align-items: center; gap: 14px; padding: 14px 22px; flex-wrap: wrap; }
.guest-title { min-width: 0; }
.guest-title h1 { font-size: 18px; }
.guest-title .muted { font-size: 12.5px; }
.guest-stage { flex: 1; min-height: 0; display: flex; padding: 0 22px; }
.guest-stage .theater-media { margin: 0; flex: 1; }
.guest-foot { display: flex; gap: 10px; padding: 12px 22px; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }

/* share / guest links */
.expiry-seg button { flex: 1 1 auto; }
.link-result { margin-top: 4px; padding: 14px; border-radius: 12px; background: var(--green-soft); border: 1px solid rgba(34,197,94,.3); }
.link-result .l { font-size: 12.5px; color: #86efac; font-weight: 600; margin-bottom: 8px; }
.links-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.links-table th { text-align: left; font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.links-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.links-table tr:last-child td { border-bottom: 0; }
.links-table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.links-table .sname { font-weight: 600; }
.links-table .sub { font-size: 12px; color: var(--dim); }
.mini-links { display: grid; gap: 8px; margin-top: 8px; }
.mini-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); font-size: 13px; }
.mini-link .grow { flex: 1; min-width: 0; }
.mini-link .sub { font-size: 12px; color: var(--dim); }
@media (max-width: 860px) {
  .links-table .hide-sm { display: none; }
  .guest-bar, .guest-stage, .guest-foot { padding-left: 16px; padding-right: 16px; }
}

/* download picker */
.side-download { margin: 14px 4px 0; height: 40px; }
.os-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.os-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px 16px 16px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--border-2); text-align: center; }
.os-card.mine { border-color: rgba(124, 92, 255, .6); background: linear-gradient(180deg, rgba(124,92,255,.14), rgba(34,211,238,.04) 60%), var(--panel-2); }
.os-badge { position: absolute; top: 10px; right: 10px; }
.os-card-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--panel-3); border: 1px solid var(--border); margin-bottom: 2px; }
.os-card-icon svg { width: 28px; height: 28px; }
.os-card-name { font-size: 17px; font-weight: 700; }
.os-card-sub { font-size: 12.5px; color: var(--muted); margin-top: -8px; }
.os-card select.input { height: 36px; font-size: 13px; }
.os-card-variant { height: 36px; display: grid; place-items: center; font-size: 13px; color: var(--muted); }
.os-card .btn.block { width: 100%; }
.os-card-hint { margin: 2px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--dim); }
.dl-next { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.dl-next h4 { font-size: 14px; margin-bottom: 2px; }
.dl-next p { margin: 0 0 12px; font-size: 13px; }

/* connect page */
.steps { display: grid; gap: 18px; max-width: 920px; }
.step { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 18px; padding: 22px; }
.step-num { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--accent-soft); color: #c4b8ff; border: 1px solid rgba(124, 92, 255, .3); }
.step h3 { font-size: 16px; margin-bottom: 4px; }
.step p { margin: 0 0 14px; color: var(--muted); }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.dl { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border-2); background: var(--panel-2); text-decoration: none; transition: border-color .15s, background .15s; }
.dl:hover { border-color: rgba(124, 92, 255, .5); background: var(--panel-3); }
.dl.recommended { border-color: rgba(124, 92, 255, .6); background: linear-gradient(135deg, rgba(124,92,255,.14), rgba(34,211,238,.06)); }
.dl svg { width: 22px; height: 22px; flex: none; }
.dl .n { font-weight: 600; font-size: 13.5px; }
.dl .s { font-size: 12px; color: var(--muted); }
.code-tabs { margin-bottom: 10px; }
.terminal { position: relative; padding: 14px 52px 14px 16px; border-radius: 12px; background: #050608; border: 1px solid var(--border-2); font: 12.5px/1.6 var(--mono); color: #c9f7dc; white-space: pre-wrap; word-break: break-all; }
.terminal .btn { position: absolute; top: 8px; right: 8px; }
.secret-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }

@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, 1fr); } .theater { grid-template-columns: 1fr 280px; } }
@media (max-width: 900px) {
  .theater { grid-template-columns: 1fr; }
  .theater-side { display: none; }
  .theater-bar { padding: 12px 16px; }
  .theater-bar h2 { flex: 1; }
  .theater-bar #th-dev { display: none; }
  .theater-bar .controls { order: 3; width: 100%; }
  .theater-media { margin: 0 16px 16px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .sidebar .logo { padding: 0 10px 0 0; }
  .sidebar .logo span:last-child, .side-section, .side-foot .ver, .side-foot .who div { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav a { height: 34px; }
  .side-foot { margin: 0 0 0 auto; padding: 4px; border: 0; background: transparent; }
  .side-download { margin: 0 0 0 6px; height: 34px; width: 34px; padding: 0; flex: none; }
  .side-download span:last-child { display: none; }
  .main { padding: 20px 16px 50px; }
  .search { width: 100%; }
  .grid, .grid.large, .devices { grid-template-columns: 1fr; }
  .secret-grid { grid-template-columns: 1fr; }
  .step { grid-template-columns: minmax(0, 1fr); }
}
