/* Same palette as the identity host's pages and web/src/styles/index.css. */
:root {
  --brand-950: #081a2c;
  --brand-900: #0f2a44;
  --brand-800: #163a5c;
  --brand-700: #1e4a75;
  --brand-100: #e3ecf5;
  --brand-50: #f1f5fa;
  --accent-700: #0b6a73;
  --accent-600: #0e7c86;
  --accent-300: #5ec3c9;
  --accent-100: #d8f0f2;
  --accent-50: #ecf8f9;
  --ink-900: #14202b;
  --ink-800: #243240;
  --ink-700: #33414f;
  --ink-600: #47545f;
  --ink-500: #5b6874;
  --ink-400: #7b8794;
  --ink-300: #a9b3bd;
  --ink-200: #dfe4ea;
  --ink-100: #edf0f3;
  --ink-50: #f6f8fa;
  --danger-800: #991b1b;
  --danger-700: #b91c1c;
  --danger-200: #fecaca;
  --danger-50: #fef2f2;
  --warn-800: #92400e;
  --warn-700: #b45309;
  --warn-200: #fde68a;
  --warn-50: #fffbeb;
  --ok-800: #166534;
  --ok-700: #15803d;
  --ok-50: #f0fdf4;

  --mono: 'SFMono-Regular', 'Cascadia Mono', Consolas, 'Courier New', monospace;
  --shadow-card: 0 1px 2px rgb(16 24 40 / 0.04), 0 6px 20px -6px rgb(16 24 40 / 0.1);
  --radius-card: 1rem;
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must win over the display rules below (.who, .create, .page-head). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Heebo', 'Segoe UI', 'Arial Hebrew', system-ui, sans-serif;
  font-feature-settings: 'tnum';
  color: var(--ink-900);
  background: var(--ink-50);
}

:focus-visible {
  outline: 2px solid var(--accent-600);
  outline-offset: 2px;
  border-radius: 4px;
}

h1,
h2 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--brand-900);
  text-wrap: balance;
}

/* ---------- app bar ---------- */

.appbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  background: var(--brand-900);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.06), 0 8px 24px -18px var(--brand-950);
}

.appbar-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem 1rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

.appbar :focus-visible {
  outline-color: var(--accent-300);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

.mark {
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
}

.wordmark {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.who {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  flex: none;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent-300);
  background: var(--brand-800);
  border: 1px solid rgb(94 195 201 / 0.35);
  border-radius: 999px;
}

.who-text {
  display: grid;
  line-height: 1.25;
}

.who-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
}

.who .roles {
  font-size: 0.75rem;
  color: var(--ink-300);
}

/* ---------- page ---------- */

.page {
  max-width: 72rem;
  margin: 0 auto;
  padding-block: 2rem 4rem;
  padding-inline: 1rem;
  display: grid;
  gap: 1.5rem;
}

.page-head {
  display: grid;
  gap: 0.25rem;
}

.page-head h1 {
  font-size: 1.5rem;
}

.sub {
  margin: 0;
  font-size: 0.875rem;
  color: var(--ink-500);
}

.card {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 1.25rem 1.5rem;
  border-block-end: 1px solid var(--ink-200);
}

.head-text {
  display: grid;
  gap: 0.125rem;
}

.head h2 {
  font-size: 1.125rem;
}

/* ---------- gate cards (signed out / no permissions) ---------- */

.gate {
  max-width: 28rem;
  margin: 2.5rem auto 0;
  padding: 2rem 1.75rem;
  text-align: center;
}

.gate-mark {
  width: 2.5rem;
  height: 2.5rem;
  margin-block-end: 0.875rem;
  color: var(--accent-600);
}

.gate h1 {
  font-size: 1.25rem;
}

.lead {
  margin: 0.5rem 0 1.5rem;
  color: var(--ink-500);
  line-height: 1.6;
}

.fineprint {
  margin: 1.5rem 0 0;
  font-size: 0.75rem;
  color: var(--ink-400);
}

.error {
  margin: 0 0 1rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--danger-800);
  background: var(--danger-50);
  border: 1px solid var(--danger-200);
  border-radius: 0.625rem;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: #fff;
  background: var(--brand-900);
  border: 1px solid var(--brand-900);
  border-radius: 0.625rem;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover {
  background: var(--brand-800);
  border-color: var(--brand-800);
}

.btn.small {
  padding: 0.4375rem 0.875rem;
  font-size: 0.875rem;
}

.btn.tiny {
  padding: 0.3125rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 0.5rem;
}

.btn.ghost {
  color: var(--brand-900);
  background: #fff;
  border-color: var(--ink-200);
}

.btn.ghost:hover {
  color: var(--brand-800);
  background: var(--ink-50);
  border-color: var(--ink-300);
}

.btn.on-dark {
  color: #fff;
  background: transparent;
  border-color: rgb(255 255 255 / 0.25);
}

.btn.on-dark:hover {
  color: #fff;
  background: rgb(255 255 255 / 0.1);
  border-color: rgb(255 255 255 / 0.45);
}

/* Row actions: quiet by default so the table stays scannable, coloured on hover. */
.act {
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink-600);
  background: none;
  border: 0;
  border-radius: 0.375rem;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.act:hover {
  color: var(--accent-700);
  background: var(--accent-50);
}

.act.danger:hover {
  color: var(--danger-700);
  background: var(--danger-50);
}

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  padding: 0.75rem 1rem;
  text-align: start;
  vertical-align: middle;
}

th {
  padding-block: 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-500);
  background: var(--ink-50);
  border-block-end: 1px solid var(--ink-200);
  white-space: nowrap;
}

tbody tr + tr td {
  border-block-start: 1px solid var(--ink-100);
}

tbody tr:hover td {
  background: var(--brand-50);
}

th:first-child,
td:first-child {
  padding-inline-start: 1.5rem;
}

th:last-child,
td:last-child {
  padding-inline-end: 1.5rem;
}

#staff-table {
  min-width: 48rem;
}

#audit-table {
  min-width: 40rem;
}

/* The account and roles columns absorb the slack; "last sign-in" takes only what it needs. */
#staff-table th:nth-child(4),
#staff-table td:nth-child(4) {
  width: 1%;
  white-space: nowrap;
}

#audit-table td:first-child {
  white-space: nowrap;
}

#staff-table .state-note {
  max-width: 11rem;
  white-space: normal;
}

.col-actions {
  text-align: end;
}

/* Inline-only: LTR text isolated inside an RTL cell, without flipping the cell's own alignment. */
.ltr {
  unicode-bidi: isolate;
  direction: ltr;
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--ink-400);
}

/* ---------- staff table cells ---------- */

.person {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.person .avatar {
  color: var(--brand-800);
  background: var(--brand-100);
  border-color: var(--brand-100);
}

.person-text {
  display: grid;
  line-height: 1.3;
}

.person-name {
  font-weight: 500;
  color: var(--ink-900);
  white-space: nowrap;
}

.person-user {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-500);
  white-space: nowrap;
}

.roles-text {
  display: block;
  color: var(--ink-800);
}

.perms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-block-start: 0.3125rem;
}

.tag {
  display: inline-block;
  padding: 0.0625rem 0.4375rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--ink-600);
  background: var(--ink-100);
  border-radius: 0.3125rem;
}

.tag.self {
  font-family: inherit;
  font-size: 0.6875rem;
  color: var(--accent-700);
  background: var(--accent-50);
}

/* One state per account: a dot plus a word, instead of a pile of chips. */
.state {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  white-space: nowrap;
}

.state::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
  border-radius: 999px;
  background: currentColor;
}

.state.ok {
  color: var(--ok-700);
}

.state.wait {
  color: var(--warn-700);
}

.state.bad {
  color: var(--danger-700);
}

.state.off {
  color: var(--ink-400);
}

.state-note {
  margin-block-start: 0.25rem;
  font-size: 0.75rem;
  color: var(--ink-400);
}

.muted {
  color: var(--ink-400);
}

/* ---------- system status ---------- */

/* Every group draws its own start and top rules; the grid is pulled one pixel past the card's start and
   top edges, where the card clips them, so only the rules BETWEEN groups show — and a short last row
   leaves white, not a grey hole. */
.lights {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  margin-inline-start: -1px;
  margin-block-start: -1px;
}

.light-group {
  display: grid;
  align-content: start;
  gap: 0.875rem;
  padding: 1.125rem 1.5rem 1.375rem;
  border-inline-start: 1px solid var(--ink-200);
  border-block-start: 1px solid var(--ink-200);
}

.light-group h3 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-500);
}

.light {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.625rem;
  row-gap: 0.125rem;
  margin: 0;
}

.light::before {
  content: '';
  grid-row: 1 / span 2;
  width: 0.625rem;
  height: 0.625rem;
  margin-block-start: 0.375rem;
  border-radius: 999px;
  background: var(--ink-300);
}

.light.ok::before {
  background: var(--ok-700);
}

.light.warn::before {
  background: var(--warn-700);
  box-shadow: 0 0 0 3px var(--warn-200);
}

.light.fail::before {
  background: var(--danger-700);
  box-shadow: 0 0 0 3px var(--danger-200);
}

.light-title {
  font-weight: 500;
  color: var(--ink-900);
}

.light-detail {
  font-size: 0.8125rem;
  color: var(--ink-500);
}

.light.fail .light-detail {
  color: var(--danger-800);
}

.light.warn .light-detail {
  color: var(--warn-800);
}

#status-meta.fail {
  color: var(--danger-700);
  font-weight: 500;
}

#status-meta.warn {
  color: var(--warn-700);
  font-weight: 500;
}

#status-meta.ok {
  color: var(--ok-700);
}

/* The flex container is an inner div: display:flex on the <td> itself drops it out of table
   layout, so the row's separator and hover background stop short of it. */
td.actions {
  text-align: end;
}

.action-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 0.125rem;
}

/* ---------- role dialog ---------- */

/* A native <dialog>: centred by the UA's own margin:auto, so nothing here positions it. */
.modal {
  width: min(32rem, calc(100vw - 2rem));
  padding: 0;
  color: inherit;
  background: #fff;
  border: 0;
  border-radius: var(--radius-card);
  box-shadow: 0 24px 64px -24px rgb(8 26 44 / 0.5);
}

.modal::backdrop {
  background: rgb(8 26 44 / 0.45);
}

.modal[open] {
  animation: modal-in 0.14s ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

.modal-head {
  padding: 1.25rem 1.5rem;
  border-block-end: 1px solid var(--ink-200);
}

.modal-title {
  font-size: 1.0625rem;
}

.modal-body {
  padding: 1.25rem 1.5rem;
}

.modal-body .hint {
  margin-block-start: 0.875rem;
}

.modal-body .error {
  margin: 0.875rem 0 0;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  background: var(--ink-50);
  border-block-start: 1px solid var(--ink-200);
}

/* ---------- audit table ---------- */

/* The dot carries the category a compliance reader scans for: routine sign-in,
   administrative change, or a failed/refused attempt. */
.event {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}

.event::before {
  content: '';
  width: 0.4375rem;
  height: 0.4375rem;
  flex: none;
  align-self: center;
  border-radius: 999px;
  background: var(--ink-300);
}

.event.admin::before {
  background: var(--accent-600);
}

.event.bad::before {
  background: var(--danger-700);
}

.event.bad {
  color: var(--danger-800);
  font-weight: 500;
}

.detail {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-500);
  max-width: 18rem;
  overflow-wrap: anywhere;
}

/* ---------- create form ---------- */

.create {
  display: grid;
  gap: 1rem;
  max-width: 46rem;
  margin: 1.25rem 1.5rem 0;
  padding: 1.25rem;
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: 0.75rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.create-head {
  display: grid;
  gap: 0.25rem;
}

.create-title {
  margin: 0;
  font-weight: 600;
  color: var(--brand-900);
}

.create-head .hint {
  margin: 0;
}

.row label {
  display: grid;
  gap: 0.3125rem;
  flex: 1 1 14rem;
  max-width: 22rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-700);
}

.row input {
  height: 2.5rem;
  padding: 0 0.75rem;
  font: inherit;
  color: var(--ink-900);
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: 0.5rem;
}

.row input:focus {
  outline: none;
  border-color: var(--accent-600);
  box-shadow: 0 0 0 3px var(--accent-100);
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

legend {
  padding: 0;
  margin-block-end: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-700);
}

/* A role reads as a pickable chip, and shows which permissions it bundles. */
.role {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.4375rem 0.75rem;
  color: var(--ink-700);
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}

.role:hover {
  border-color: var(--ink-300);
}

.role:has(:checked) {
  color: var(--accent-700);
  background: var(--accent-50);
  border-color: var(--accent-300);
}

.role input {
  accent-color: var(--accent-600);
  margin: 0;
}

.role .perm-list {
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--ink-400);
}

.role:has(:checked) .perm-list {
  color: var(--accent-600);
}

.create .actions {
  gap: 0.5rem;
}

/* ---------- notice / one-time secret ---------- */

.notice {
  margin: 1.25rem 1.5rem 0;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  color: var(--ok-800);
  background: var(--ok-50);
  border: 1px solid #bbf7d0;
}

.notice.bad {
  color: var(--danger-800);
  background: var(--danger-50);
  border-color: var(--danger-200);
}

.notice.secret-box {
  color: var(--ink-900);
  background: var(--warn-50);
  border-color: var(--warn-200);
}

.secret-title {
  margin: 0 0 0.625rem;
  font-weight: 600;
  color: var(--warn-800);
}

.secret-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.secret-value {
  flex: 1 1 14rem;
  padding: 0.5rem 0.75rem;
  font-family: var(--mono);
  font-size: 1.0625rem;
  letter-spacing: 0.08em;
  background: #fff;
  border: 1px dashed var(--warn-700);
  border-radius: 0.5rem;
  user-select: all;
}

.hint {
  margin: 0.625rem 0 0;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--ink-500);
}

/* ---------- tooltips ---------- */

/* A row button says what it is in a word ("איפוס אפליקציה"); the tooltip says what pressing it
   actually does. Fixed at the viewport, positioned by console.js — inset comes from
   getBoundingClientRect, which is physical by nature, so the offsets are set inline, not here. */
.tip {
  position: fixed;
  z-index: 100;
  max-width: 22rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  text-align: start;
  text-wrap: pretty;
  color: #fff;
  background: var(--brand-950);
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px -8px rgb(8 26 44 / 0.45);
  pointer-events: none;
  animation: tip-in 0.12s ease-out;
}

@keyframes tip-in {
  from {
    opacity: 0;
  }
}

/* The dotted underline says "this one has an explanation" — but only on the row being worked on,
   so five rows of quiet actions don't all shout at once. */
tbody tr:hover .act[data-tip] {
  text-decoration: underline dotted var(--ink-300);
  text-underline-offset: 0.25em;
}

.act[data-tip]:hover,
.act[data-tip]:focus-visible {
  text-decoration: underline dotted currentColor;
  text-underline-offset: 0.25em;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- phone ---------- */

@media (max-width: 32rem) {
  .appbar-inner {
    padding-inline: 1rem;
  }

  .page {
    padding-inline: 1rem;
    padding-block: 1.5rem 3rem;
  }

  .who {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .head,
  .create,
  .notice,
  .light-group {
    padding-inline: 1rem;
  }

  .create,
  .notice {
    margin-inline: 1rem;
  }

  th:first-child,
  td:first-child {
    padding-inline-start: 1rem;
  }

  th:last-child,
  td:last-child {
    padding-inline-end: 1rem;
  }

  .gate {
    padding: 1.75rem 1.25rem;
  }
}
