:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: #f7f3ed;
  background: #100e0d;
  --canvas: #100e0d;
  --surface: #211e1a;
  --line: #484038;
  --soft-line: #3a342e;
  --muted: #b6afa5;
  --accent: #ff9b4b;
  --focus: #ffb25d;
  --danger: #ffaaa2;
  --radius: 13px;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 85% 2%, #21180f 0%, transparent 42rem), var(--canvas);
  color: #f7f3ed;
  line-height: 1.5;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: #ffc486; }
button, input, select, textarea { font: inherit; }
button, .button, .row-actions > summary {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: .5em;
  padding: .48rem .88rem;
  border: 1px solid #5e5349;
  border-radius: 7px;
  background: linear-gradient(#37312b, #25211d);
  color: #f9f5f0;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover, .row-actions > summary:hover { border-color: #897969; background: #3b332c; }
button:disabled { opacity: .48; cursor: default; }
.primary, button.primary, .button.primary {
  color: #211104;
  border-color: #fb9347;
  background: linear-gradient(180deg, #ffa54f, #f17a23);
  box-shadow: inset 0 1px 0 #ffc78470, 0 3px 12px #0003;
}
.primary:hover, button.primary:hover, .button.primary:hover { color: #211104; background: #ffab5c; }
.danger, button.danger { color: #ffe1dd; border-color: #985951; background: #542925; }
.danger:hover, button.danger:hover { background: #71332e; border-color: #ba7067; }
.text-danger, button.text-danger { color: var(--danger); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .6rem .78rem;
  color: #fcf9f5;
  border: 1px solid #63594f;
  border-radius: 7px;
  background: #151311;
  line-height: 1.35;
}
input::placeholder, textarea::placeholder { color: #a29a91; }
input[type="checkbox"], input[type="radio"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  min-height: auto;
  margin: 0;
  accent-color: #ff8d3d;
}
label { display: grid; gap: .38rem; font-weight: 600; }
fieldset { min-inline-size: 0; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.13; letter-spacing: -.025em; }
h1 { font-size: clamp(2rem, 3.2vw, 3rem); }
h2 { font-size: clamp(1.25rem, 2vw, 1.6rem); }
h3 { font-size: 1.1rem; }
.muted, .empty-inline, small { color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Portal navigation and the approved projector artwork. */
.app-shell { display: grid; grid-template-columns: clamp(180px, 16vw, 240px) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100vh;
  height: 100dvh;
  padding: 20px 14px;
  border-right: 1px solid var(--soft-line);
  background: linear-gradient(155deg, #241d18, #151310 55%, #13110f);
  z-index: 2;
}
.brand { display: inline-flex; align-items: center; max-width: 100%; color: #fff; text-decoration: none; }
.brand img, img.brand { display: block; width: clamp(135px, 13vw, 190px); height: auto; object-fit: contain; }
.sidebar nav { display: grid; align-content: start; gap: .35rem; }
nav a, .sidebar nav button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  gap: .65rem;
  padding: .55rem .85rem;
  color: #dbd4cb;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  font-weight: 550;
  text-decoration: none;
}
.sidebar nav button { justify-content: flex-start; }
nav a:hover, .sidebar nav button:hover { color: white; background: #29231d; }
nav a[aria-current="page"], nav .active, .sidebar nav button[aria-current="page"] {
  color: #ffe0b6;
  border-color: #79502d;
  background: linear-gradient(100deg, #734019, #432b1a);
}
.sidebar footer, .sidebar .account { margin-top: auto; }
.app-shell > main, .app-shell > .main { width: 100%; min-width: 0; padding: 0 clamp(16px, 3vw, 48px) 48px; }
.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  min-height: clamp(108px, 12vw, 174px);
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1.3rem clamp(.8rem, 1.8vw, 1.7rem);
  background: linear-gradient(90deg, #100e0d 0%, #100e0dbd 26%, transparent 68%),
    url("/assets/projector-header.jpg") right center / auto 100% no-repeat, #100e0d;
}
.masthead h1 { text-shadow: 0 2px 12px #0008; }
.masthead p { margin-top: .25rem; color: #dbd3c8; }
.masthead .invite-action::before { content: "+"; font-size: 1.22em; line-height: .9; }

/* These panels are shared by setup, viewer devices, and owner pages. */
.panel, dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: radial-gradient(ellipse at 0 0, #5d49341a, transparent 52%), linear-gradient(155deg, #28241f, #191715 84%);
  box-shadow: inset 0 1px 0 #ffffff0c, 0 6px 22px #0003;
}
.panel { min-width: 0; padding: clamp(16px, 2vw, 25px); }
.grid, .cards { display: grid; gap: 1rem; }
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
.dashboard-content { display: grid; gap: 1rem; }
.stat-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card { display: flex; flex-direction: column; gap: .55rem; }
.stat-card h2, .capacity-card h2 { font-size: .99rem; letter-spacing: .01em; font-weight: 600; }
.stat-card strong, .capacity-card strong {
  display: block;
  font-size: clamp(1.82rem, 3.1vw, 2.85rem);
  line-height: 1.05;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
}
.stat-card p, .capacity-card p { margin-top: auto; font-size: .89rem; color: var(--muted); }
.capacity-card { display: grid; gap: .65rem; }
.capacity-card strong { font-size: clamp(1.45rem, 2.45vw, 2.2rem); }
progress { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 10px; border: 0; border-radius: 20px; background: #484039; overflow: hidden; }
progress::-webkit-progress-bar { border-radius: 20px; background: #484039; }
progress::-webkit-progress-value { border-radius: 20px; background: linear-gradient(90deg, #e66b15, #ffab56); }
progress::-moz-progress-bar { border-radius: 20px; background: #f98b36; }
.recent-card h2 { margin-bottom: .75rem; }
.empty-inline { padding: .6rem 0; }

/* The user table keeps actions in the row and opens details on demand. */
.directory-panel { position: relative; padding: 0; }
.directory-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .85rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.directory-search { flex: 1 1 220px; max-width: 25rem; }
.directory-search input { height: 41px; min-height: 41px; }
.status-filters { display: flex; flex-wrap: wrap; gap: .22rem; }
.status-filters button {
  color: var(--muted);
  border: 1px solid transparent;
  background: none;
  border-radius: 5px;
  padding: .4rem .62rem;
  min-height: 37px;
  font-size: .88rem;
}
.status-filters button[aria-pressed="true"] { color: #ffbd79; background: #503322; border-color: #80532f; }
table { width: 100%; border-collapse: collapse; text-align: left; }
.table-scroll { min-width: 0; max-width: 100%; }
.table-scroll td.empty-state { text-align: center; padding: 2rem .8rem; }
.device-tools input { flex: 1 1 220px; max-width: 26rem; }
.device-tools select { width: auto; }
.account-email { display: block; overflow-wrap: anywhere; }
.account-link { padding: .2rem 0; min-height: 32px; background: none; border: 0; color: var(--accent); text-align: left; }
.account-link:hover { background: none; text-decoration: underline; }
.status.disabled::before { background: #bf8f73; }
@media(max-width:720px) {
  .device-tools input { flex: initial; }
  .device-tools select { width: 100%; }
}
th, td { padding: .68rem .8rem; overflow-wrap: anywhere; }
thead th { color: var(--muted); font-size: .8rem; font-weight: 600; border-bottom: 1px solid var(--line); }
tbody td, tbody th { border-bottom: 1px solid var(--soft-line); font-size: .94rem; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: none; }
.user-table :is(th,td):first-child { padding-left: 1.1rem; }
.user-table :is(th,td):last-child { padding-right: 1.1rem; text-align: right; }
.user-table tbody tr:hover { background: #ffffff04; }
.user-table .name-action, .device-item .text-danger {
  justify-content: flex-start;
  min-height: 35px;
  padding: .12rem 0;
  border: 0;
  background: none;
  text-align: left;
  text-decoration: none;
}
.name-action:hover, .device-item .text-danger:hover { text-decoration: underline; text-underline-offset: .2em; }
.email-cell { color: #d0c9bf; }
.slots-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: .45em; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status.active::before { background: #78c694; }
.status.invited::before { background: #edac58; }
.status.suspended::before { background: #dc827a; }
.row-actions { position: relative; display: inline-block; text-align: left; }
.row-actions[open] { z-index: 4; }
.row-actions > summary {
  width: 38px;
  min-height: 33px;
  padding: .2rem;
  color: #dfd7cd;
  font-size: .72rem;
  letter-spacing: .08em;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
.action-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  display: grid;
  min-width: 168px;
  padding: 5px;
  border: 1px solid #62564b;
  border-radius: 8px;
  background: #29241f;
  box-shadow: 0 8px 22px #0009;
}
.action-menu button { border: 0; justify-content: flex-start; font-size: .9rem; font-weight: 550; background: none; }
.action-menu button:hover { background: #42372e; }
.user-table tr:nth-last-child(-n+2) .action-menu { top: auto; bottom: calc(100% + 4px); }
.empty-state { text-align: center; color: var(--muted); padding: 3rem .8rem; }
.directory-results > .form-error { margin: 1rem; }
.directory-results > button { margin: 0 1rem 1rem; }
.pagination, .page-controls { display: flex; align-items: center; gap: .7rem; }
.pagination { justify-content: space-between; border-top: 1px solid var(--line); padding: .85rem 1.1rem; color: var(--muted); font-size: .88rem; }
.page-controls button { min-height: 34px; padding: .35rem .65rem; }
.page-controls span { white-space: nowrap; font-variant-numeric: tabular-nums; }

dialog {
  position: fixed;
  width: min(460px, calc(100% - 32px));
  max-height: min(90vh, 840px);
  max-height: min(90dvh, 840px);
  overflow-y: auto;
  padding: clamp(18px, 2.3vw, 30px);
  color: #f8f5ef;
  box-shadow: inset 0 1px 0 #ffffff0f, 0 24px 90px #000b;
}
dialog::backdrop { background: #080706c9; }
dialog h2 { margin-bottom: 1rem; }
dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.form-stack { display: grid; gap: 1rem; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; padding-top: .3rem; }
.form-error { color: #ffb5aa; font-size: .94rem; }
.form-error:empty { display: none; }
.account-summary { display: grid; gap: .15rem; overflow-wrap: anywhere; }
.account-summary strong { font-size: 1.15rem; }
.paired-fieldset { border: 0; margin: .25rem 0 0; padding: 0; }
.paired-fieldset legend { margin-bottom: .25rem; padding: 0; font-weight: 650; }
.device-instruction { color: var(--muted); font-size: .9rem; }
.device-list { margin-top: .5rem; }
.device-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .32rem 0; border-bottom: 1px solid var(--soft-line); }
.device-choice { display: flex; align-items: center; gap: .55rem; min-width: 0; overflow-wrap: anywhere; }
.device-item .text-danger { flex: 0 0 auto; font-size: .87rem; }

.download-page {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  align-content: center;
  justify-items: start;
  padding: clamp(24px, 6vw, 100px);
  background: linear-gradient(90deg, #0a0908 0%, #0a0908dc 38%, transparent 76%),
    url("/assets/projector-download.jpg") right center / auto 100% no-repeat, #090807;
}
.download-page > .panel { width: min(95%, 680px); padding: clamp(22px, 3.3vw, 54px); }
.download-page .brand img, .download-page img.brand { width: min(320px, 75%); }
.download-page input, input.code { font-size: clamp(1.65rem, 3vw, 2.6rem); font-weight: 700; letter-spacing: .16em; text-align: center; font-variant-numeric: tabular-nums; }
.download-page button.primary { width: 100%; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 168px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .directory-tools { align-items: stretch; }
  .directory-search { max-width: 100%; }
  .stat-card { padding: .9rem; }
  th, td { padding-inline: .55rem; }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar {
    position: relative;
    height: auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .36rem .8rem;
    padding: 8px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
  }
  .sidebar .brand img, .sidebar img.brand { width: 132px; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: .25rem; }
  .sidebar nav :is(a,button) { min-height: 38px; padding: .4rem .65rem; }
  .sidebar footer, .sidebar .account { margin-top: 0; }
  .app-shell > main, .app-shell > .main { padding: 0 12px 30px; }
  .masthead { min-height: 102px; padding-inline: .3rem; background-image: linear-gradient(90deg, #100e0df2 8%, #100e0db5 50%, #100e0d22 90%), url("/assets/projector-header.jpg"); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .stat-cards { gap: .6rem; }
  .stat-card { padding: .8rem .7rem; }
  .stat-card h2 { font-size: .85rem; }
  .stat-card p { font-size: .75rem; }
  .directory-tools { flex-direction: column; gap: .5rem; padding: .8rem; }
  .directory-search { flex: initial; }
  .recent-table { font-size: .85rem; }
  .recent-table :is(th,td) { padding: .5rem .3rem; }
}
@media (max-width: 540px) {
  .table-scroll { overflow-x: auto; }
  .table-scroll table { table-layout: fixed; }
  .table-scroll th, .table-scroll td { padding: .5rem .28rem; font-size: .75rem; }
  .table-scroll thead th { font-size: .71rem; }
  .table-scroll .user-table :is(th,td):first-child { padding-left: .4rem; }
  .table-scroll .user-table :is(th,td):last-child { padding-right: .4rem; }
  .table-scroll .user-table .name-action, .account-link { font-size: inherit; }
  .table-scroll .status { white-space: normal; overflow-wrap: anywhere; }
  .table-scroll .row-actions > summary { min-width: 32px; min-height: 34px; }
  .table-scroll:has(.row-actions[open]) { overflow: visible; }
  .table-scroll .user-table tr .action-menu { top: 100%; bottom: auto; }
  .table-scroll .empty-state { padding: 2rem .6rem; }
  .pagination { padding-inline: .8rem; gap: .4rem; }
  .page-controls { gap: .4rem; }
  .download-page { justify-items: center; padding: 16px; }
  .download-page > .panel { width: 100%; }
}
@media (max-width: 430px) {
  .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card:last-child { grid-column: 1 / -1; }
  .stat-card:last-child { display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .stat-card:last-child strong { grid-column: 2; grid-row: 1 / 3; }
  .recent-table :is(th,td) { font-size: .8rem; }
  .masthead .invite-action { padding-inline: .63rem; }
}
