:root {
  --blue: #3d5bb0;
  --blue-dark: #2f4690;
  --blue-tint: #dce7f7;
  --ink: #1c2434;
  --muted: #5d6b82;
  --line: #d9e0ea;
  --page: #f4f6fa;
  --card: #ffffff;
  --red: #b03a3a;
  --green: #2a7050;
  --amber-bg: #f8f1d4;
  --amber: #776208;
  font-family: system-ui, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--page);
  font-size: 15px;
  line-height: 1.45;
}
h1 {
  font-size: 22px;
  margin: 0;
}
h2 {
  font-size: 18px;
  margin: 0 0 12px;
}
.muted {
  color: var(--muted);
}
.spacer {
  flex: 1;
}
.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
}

button {
  font: inherit;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
button:hover {
  border-color: var(--blue);
}
button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
}
button.primary:hover {
  background: var(--blue-dark);
}
button.link {
  border: none;
  background: none;
  padding: 4px 6px;
  color: var(--blue);
}
button.link.danger {
  color: var(--red);
}
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

input,
textarea {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
textarea {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  resize: vertical;
}
label {
  display: block;
  font-weight: 600;
  margin-bottom: 14px;
}
label input,
label textarea {
  margin-top: 4px;
  font-weight: 400;
}
label small {
  display: block;
  font-weight: 400;
  margin-top: 4px;
}
.error {
  color: var(--red);
  margin: 0 0 12px;
}
.warning {
  background: var(--amber-bg);
  color: var(--amber);
  padding: 8px 12px;
  border-radius: 8px;
}

/* Login */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: min(360px, 100%);
  text-align: center;
}
.card label {
  text-align: left;
}
.card p.muted {
  margin: 2px 0 20px;
}
.card button {
  width: 100%;
}

/* App */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar .title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.topbar .title span {
  font-size: 13px;
}
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar input[type='search'] {
  width: 260px;
}

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  background: #fafbfd;
}
tbody tr:last-child td {
  border-bottom: none;
}
td.username {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
td.actions {
  text-align: right;
}
tr.disabled td:not(.actions) {
  color: var(--muted);
}
.empty {
  text-align: center;
  padding: 32px;
  margin: 0;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: #e9edf1;
  color: var(--muted);
}
.badge.online {
  background: #e4f4ec;
  color: var(--green);
}
.badge.disabled {
  background: #fbe9e9;
  color: var(--red);
}

/* Dialogs */
dialog {
  border: none;
  border-radius: 14px;
  padding: 24px;
  width: min(460px, calc(100vw - 32px));
  color: var(--ink);
  box-shadow: 0 16px 48px rgb(28 36 52 / 25%);
}
dialog::backdrop {
  background: rgb(28 36 52 / 45%);
}
dialog .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.secret {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--blue-tint);
  border-radius: 8px;
  padding: 10px 12px;
}
.secret code {
  flex: 1;
  font-size: 20px;
  letter-spacing: 1px;
  user-select: all;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  max-width: calc(100vw - 32px);
}

@media (max-width: 640px) {
  .topbar #admin-name {
    display: none;
  }
  .toolbar input[type='search'] {
    width: 100%;
    order: 3;
  }
}

/* Clients, spaces */
select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
label select {
  display: block;
  width: 100%;
  margin-top: 4px;
  font-weight: 400;
}
.client-picker {
  margin: 0 0 0 12px;
}
.client-picker select {
  font-weight: 600;
  min-width: 200px;
}
.rule {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
}
.rule > div {
  flex: 1;
}
.rule p {
  margin: 2px 0 0;
  font-size: 14px;
}
.tabs {
  display: flex;
  gap: 4px;
  background: #e6ebf3;
  border-radius: 10px;
  padding: 4px;
}
.tabs button {
  border: none;
  background: none;
  font-weight: 600;
  color: var(--muted);
}
.tabs button[aria-selected='true'] {
  background: var(--card);
  color: var(--ink);
}
tr.group td {
  background: #fafbfd;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding-top: 8px;
  padding-bottom: 8px;
}
td.people {
  white-space: normal;
}
.person {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 14px 2px 0;
}
.order {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-tint);
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #b9c2cf;
  flex: none;
}
.dot.online {
  background: #2f9e6b;
}
.dot.disabled {
  background: var(--red);
}
code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
}

dialog.wide {
  width: min(640px, calc(100vw - 32px));
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px 12px;
  margin: 0 0 14px;
}
legend {
  font-weight: 600;
  padding: 0 6px;
}
label.choice {
  font-weight: 400;
  margin: 6px 0;
}
label.choice input {
  width: auto;
  margin: 0 6px 0 0;
}
label.choice small {
  margin-left: 24px;
}
.prefixed {
  display: flex;
  align-items: center;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 400;
}
.prefixed > span {
  padding: 0 2px 0 10px;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
}
.prefixed input {
  border: none;
  margin: 0;
  padding-left: 0;
  font-family: ui-monospace, Consolas, monospace;
}
.members {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  counter-reset: member;
}
.members li {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.members .name {
  flex: 1;
}
.members.ordered li::before {
  counter-increment: member;
  content: counter(member);
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-tint);
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
  margin-right: 6px;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
.add-member {
  display: flex;
  gap: 8px;
}
.add-member select {
  flex: 1;
}
table.plain th,
table.plain td {
  padding: 6px 10px;
}
.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.inline-form label {
  margin: 0;
  flex: 1;
}
.inline-form label:nth-child(2) {
  flex: 0 0 110px;
}

@media (max-width: 640px) {
  .row {
    grid-template-columns: 1fr;
  }
  .rule,
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }
  .client-picker select {
    min-width: 0;
  }
}

/* The people table has many columns: keep it within the page on a laptop screen */
#people-table {
  font-size: 14px;
}
#people-table th,
#people-table td {
  padding: 9px 10px;
}
#people-table td.actions button {
  padding: 4px 4px;
}
