:root {
  color-scheme: light;
  --brand: #0f766e;
  --brand-hover: #0b5c56;
  --brand-weak: #e6f3f1;
  --on-brand: #ffffff;
  --background: #eef2f6;
  --surface: #ffffff;
  --text: #1b2733;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --danger: #b91c1c;
  --radius: 12px;
  --radius-small: 8px;
  --ring: 0 0 0 3px rgba(15, 118, 110, .25);
  --shadow: 0 6px 20px rgba(15, 23, 42, .08);
  --topbar-height: 58px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(24px, 3vw, 32px); line-height: 1.15; }
h2 { margin-bottom: 0; font-size: 17px; }
small { color: var(--muted); }

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  min-height: var(--topbar-height);
  padding: 8px 14px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand { align-items: center; display: inline-flex; flex: 0 0 auto; margin-right: 4px; }
.brand img { display: block; }
.tabs { display: flex; flex: 1 1 auto; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-link {
  border-radius: var(--radius-small);
  color: var(--text);
  font-weight: 600;
  padding: 8px 12px;
  text-decoration: none;
  white-space: nowrap;
}
.tab-link:hover, .tab-link.is-active { background: var(--brand-weak); color: var(--brand-hover); }
.topbar-end { align-items: center; display: flex; flex: 0 0 auto; gap: 10px; margin-left: auto; }
.user-identity { align-items: flex-end; display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; }
.user-name { font-size: 14px; font-weight: 600; }
.user-role { color: var(--muted); font-size: 11px; margin-top: 3px; }
.topbar-logout { margin: 0; }

.page { margin: 0; max-width: none; min-height: calc(100vh - var(--topbar-height)); padding: 10px; }
.page-centered { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.page-header { align-items: flex-end; display: flex; justify-content: space-between; gap: 18px; padding: 8px 4px 14px; }
.page-header--actions { align-items: end; }
.page-lead { color: var(--muted); margin: 0; }
.eyebrow { color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .1em; margin: 0 0 3px; text-transform: uppercase; }
.section-heading { align-items: center; display: flex; justify-content: space-between; margin-bottom: 8px; padding: 0 2px; }
.section-heading > span { background: var(--border); border-radius: 999px; color: var(--muted); font-size: 11px; padding: 2px 8px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.account-summary { align-items: center; display: flex; gap: 12px; margin-bottom: 18px; padding: 12px; }
.account-avatar, .user-avatar, .app-tile-icon {
  align-items: center;
  background: var(--brand-weak);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--border));
  border-radius: 50%;
  color: var(--brand-hover);
  display: inline-flex;
  flex: 0 0 auto;
  font-weight: 800;
  justify-content: center;
}
.account-avatar { height: 46px; width: 46px; }
.account-identity { display: grid; min-width: 0; }
.account-identity > span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-summary > code { color: var(--muted); margin-left: auto; }
.app-section { margin-top: 4px; }
.app-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.app-tile { align-items: center; display: flex; gap: 12px; min-height: 78px; padding: 12px; text-decoration: none; transition: border-color 120ms ease, transform 120ms ease; }
.app-tile:hover { border-color: var(--brand); transform: translateY(-1px); }
.app-tile-icon { border-radius: var(--radius-small); font-size: 17px; height: 42px; width: 42px; }
.app-tile-copy { display: grid; min-width: 0; }
.app-tile-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-tile-arrow { color: var(--muted); font-size: 18px; margin-left: auto; }

input, select, button { font: inherit; }
input, select { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-small); color: var(--text); min-height: 38px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, button:focus-visible, .tab-link:focus-visible, .app-tile:focus-visible { border-color: var(--brand); box-shadow: var(--ring); outline: none; }
input[readonly] { background: var(--brand-weak); color: var(--muted); }
label { font-weight: 600; }

.btn-pill, .button {
  align-items: center;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  justify-content: center;
  line-height: 1;
  min-height: 32px;
  padding: 7px 12px;
  text-decoration: none;
  white-space: nowrap;
}
.btn-pill:hover, .button-secondary:hover { background: var(--brand-weak); border-color: var(--brand); color: var(--brand-hover); }
.btn-pill--accent, .button-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-pill--accent:hover, .button-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--on-brand); }
.btn-pill--danger { border-color: #fecaca; color: var(--danger); }
.btn-pill--danger:hover { background: #fef2f2; border-color: var(--danger); color: var(--danger); }
.button { border-radius: var(--radius-small); font-size: 14px; min-height: 40px; }

.toolbar-search { align-items: center; display: flex; gap: 6px; width: min(520px, 100%); }
.toolbar-search input { min-width: 180px; }
.notice, .error { border: 1px solid; border-radius: var(--radius-small); margin: 0 0 10px; padding: 9px 11px; }
.notice { background: #ecfdf5; border-color: #a7f3d0; color: #166534; }
.error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }

.create-panel { margin-bottom: 10px; overflow: hidden; }
.create-panel > summary { align-items: center; cursor: pointer; display: flex; justify-content: space-between; list-style: none; min-height: 58px; padding: 10px 14px; }
.create-panel > summary::-webkit-details-marker, .user-row > summary::-webkit-details-marker { display: none; }
.create-panel > summary > span:first-child { display: grid; }
.summary-action { align-items: center; background: var(--brand-weak); border-radius: 50%; color: var(--brand-hover); display: inline-flex; font-size: 18px; height: 30px; justify-content: center; transition: transform 120ms ease; width: 30px; }
.create-panel[open] .summary-action { transform: rotate(45deg); }

.user-form { align-items: end; border-top: 1px solid var(--border); display: grid; gap: 10px; grid-template-columns: 1.2fr 1.5fr .8fr .75fr auto; padding: 12px 14px 14px; }
.user-form label { display: grid; gap: 5px; }
.user-form label > span { color: var(--muted); font-size: 11px; }
.check { align-items: center; display: flex !important; gap: 7px; min-height: 38px; white-space: nowrap; }
.check input { min-height: auto; width: 17px; }
.check span { color: var(--text) !important; font-size: 13px !important; }

.user-collection { display: grid; gap: 5px; }
.collection-heading, .user-row > summary { align-items: center; display: grid; gap: 10px; grid-template-columns: minmax(240px, 1fr) 90px 130px 95px; }
.collection-heading { color: var(--muted); font-size: 11px; font-weight: 700; padding: 2px 14px; text-transform: uppercase; }
.user-row { border-radius: var(--radius-small); box-shadow: none; overflow: hidden; }
.user-row > summary { cursor: pointer; list-style: none; min-height: 58px; padding: 7px 14px; }
.user-row > summary:hover { background: color-mix(in srgb, var(--brand-weak) 55%, transparent); }
.user-row[open] > summary { background: var(--brand-weak); border-bottom: 1px solid var(--border); }
.user-primary { align-items: center; display: flex; gap: 10px; min-width: 0; }
.user-primary > span:last-child { display: grid; min-width: 0; }
.user-primary small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-avatar { font-size: 11px; height: 34px; width: 34px; }
.badge, .status { border-radius: 999px; font-size: 11px; justify-self: start; padding: 3px 8px; }
.badge { background: var(--border); color: var(--text); }
.status-active { background: #dcfce7; color: #166534; }
.status-inactive { background: #fee2e2; color: #991b1b; }
.empty-state { color: var(--muted); padding: 28px; text-align: center; }

.auth-panel { padding: 24px; text-align: center; width: min(420px, 100%); }
.auth-panel h1 { margin-bottom: 16px; }
.logo { display: block; margin: 0 auto 8px; }
.stack { display: grid; gap: 10px; text-align: left; }
.text-link { color: var(--brand); display: inline-block; margin-top: 14px; }
.reset-form { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.sr-only { clip: rect(0, 0, 0, 0); clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }

@media (max-width: 860px) {
  .user-form { grid-template-columns: 1fr 1fr; }
  .user-form .btn-pill { justify-self: start; }
  .collection-heading { display: none; }
  .user-row > summary { grid-template-columns: minmax(190px, 1fr) auto auto; }
  .user-row > summary .status { display: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 8px 10px; }
  .user-identity { display: none; }
  .page { padding: 6px; }
  .page-header, .page-header--actions { align-items: stretch; flex-direction: column; padding-inline: 4px; }
  .toolbar-search { flex-wrap: wrap; }
  .toolbar-search input { flex: 1 1 100%; }
  .account-summary { align-items: flex-start; }
  .account-summary > code { margin-left: 0; }
  .user-row > summary { grid-template-columns: minmax(0, 1fr) auto; }
  .user-row > summary .badge { display: none; }
  .user-form { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --brand: #2dd4bf;
    --brand-hover: #5eead4;
    --brand-weak: #123c3a;
    --on-brand: #042f2e;
    --background: #0b1118;
    --surface: #111827;
    --text: #e5edf5;
    --muted: #94a3b8;
    --border: #273449;
    --border-strong: #3b4b63;
    --danger: #fca5a5;
    --ring: 0 0 0 3px rgba(45, 212, 191, .28);
    --shadow: 0 10px 28px rgba(0, 0, 0, .38);
  }
  .topbar { box-shadow: 0 1px 2px rgba(0, 0, 0, .42); }
  .notice { background: #102f25; border-color: #166534; color: #86efac; }
  .error { background: #3b171b; border-color: #7f1d1d; }
  .status-active { background: #123c2b; color: #86efac; }
  .status-inactive { background: #451a1a; color: #fca5a5; }
}

/* Candidates-compatible user table */
.users-page { min-height: 0; }
.fullscreenContentTable {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height) - 20px);
  height: calc(100dvh - var(--topbar-height) - 20px);
  overflow: hidden;
}
.fullscreenContentTable__tools {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  min-height: 41px;
  padding: 4px 8px;
}
.fullscreenContentTable__activeFilters {
  align-items: center;
  display: flex;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.fullscreenContentTable__primaryAction {
  align-items: center;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 6px;
  color: var(--on-brand);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  gap: 4px;
  min-height: 29px;
  padding: 4px 10px;
  text-decoration: none;
}
.fullscreenContentTable__primaryAction:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.filter-chip {
  align-items: center;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: #2563eb;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 11px;
  gap: 4px;
  min-height: 24px;
  padding: 3px 8px;
  text-decoration: none;
  white-space: nowrap;
}
.filter-chip:hover { background: #dbeafe; border-color: #93c5fd; }
.filter-chip > span { font-size: 15px; line-height: 10px; }
.fullscreenContentTable__scroll { flex: 1 1 auto; min-height: 0; overflow: auto; position: relative; }
.fullscreenContentTable__table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1040px;
  table-layout: fixed;
  width: 100%;
}
.fullscreenContentTable__table th,
.fullscreenContentTable__table td {
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  height: 28px;
  line-height: 1.2;
  overflow: hidden;
  padding: 2px 6px;
  text-align: left;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}
.fullscreenContentTable__table th {
  background: #f1f5f9;
  border-bottom-color: var(--border-strong);
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  height: 30px;
  letter-spacing: .02em;
  overflow: visible;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 3;
}
.fullscreenContentTable__table tbody tr:hover td { background: #f0fdfa; }
.fullscreenContentTable__table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.fullscreenContentTable__table a { color: inherit; }
.user-table-link { text-decoration: none; }
.user-table-link:hover { color: var(--brand-hover); text-decoration: underline; text-underline-offset: 2px; }
.user-column-id { width: 10%; }
.user-column-name { width: 14%; }
.user-column-email { width: 18%; }
.user-column-phone { width: 13%; }
.user-column-position { width: 15%; }
.user-column-role { width: 11%; }
.user-column-status { width: 9%; }
.user-column-created { width: 10%; }
.table-heading { align-items: center; display: flex; gap: 5px; justify-content: space-between; min-width: 0; }
.table-heading > span { overflow: hidden; text-overflow: ellipsis; }
.table-filter { flex: 0 0 auto; position: relative; text-transform: none; }
.table-filter[open] { z-index: 12; }
.table-filter > summary {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  height: 20px;
  justify-content: center;
  list-style: none;
  width: 20px;
}
.table-filter > summary::-webkit-details-marker { display: none; }
.table-filter > summary:hover, .table-filter[open] > summary { background: var(--surface); border-color: var(--border-strong); color: var(--brand-hover); }
.table-filter.is-active > summary { background: var(--brand-weak); color: var(--brand-hover); }
.table-filter svg { fill: currentColor; height: 12px; width: 12px; }
.table-filter-menu {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  left: 0;
  min-width: 240px;
  padding: 12px;
  position: absolute;
  top: calc(100% + 7px);
}
.fullscreenContentTable__table th:nth-last-child(-n + 2) .table-filter-menu { left: auto; right: 0; }
.table-filter-menu > strong { border-bottom: 1px solid var(--border); color: var(--text); padding-bottom: 8px; text-transform: none; }
.table-filter-actions { align-items: center; display: flex; gap: 8px; justify-content: flex-end; }
.table-filter-actions a { color: var(--muted); font-size: 12px; text-decoration: none; }
.table-filter-actions button { background: var(--brand); border-color: var(--brand); color: var(--on-brand); min-height: 32px; padding: 4px 9px; }
.fullscreenContentTable__empty { color: var(--muted); padding: 28px !important; text-align: center !important; }
.fullscreenContentTable__pagination {
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  flex: 0 0 auto;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  min-height: 44px;
  padding: 5px 8px;
}
.fullscreenContentTable__paginationControls { align-items: center; display: flex; gap: 8px; grid-column: 2; justify-content: center; }
.fullscreenContentTable__paginationControls a {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  font-weight: 600;
  min-height: 32px;
  padding: 5px 11px;
  text-decoration: none;
}
.fullscreenContentTable__paginationControls a:hover { background: var(--brand-weak); border-color: var(--brand); color: var(--brand-hover); }
.fullscreenContentTable__paginationRange { color: var(--muted); font-size: 12px; grid-column: 3; justify-self: end; white-space: nowrap; }

.user-editor { margin: 0 auto; max-width: 980px; overflow: hidden; }
.user-editor-header { border-bottom: 1px solid var(--border); padding: 18px; }
.user-editor-header h1 { margin-bottom: 5px; }
.user-editor-header p:last-child { color: var(--muted); margin: 0; }
.user-editor-fields { display: grid; gap: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.user-editor-fields label { border-bottom: 1px solid var(--border); display: grid; gap: 6px; padding: 14px; }
.user-editor-fields label:nth-child(odd) { border-right: 1px solid var(--border); }
.user-editor-fields label > span { color: var(--muted); font-size: 11px; }
.user-editor-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 14px; }
.user-editor-section { border-top: 1px solid var(--border); }
.user-editor-section__header { align-items: flex-start; display: flex; gap: 16px; justify-content: space-between; padding: 16px; }
.user-editor-section__header h2 { font-size: 15px; margin: 0; }
.user-editor-section__header p { color: var(--muted); font-size: 12px; margin: 3px 0 0; }
.user-editor-section__header--actions form { flex: 0 0 auto; margin: 0; }
.user-app-access__note { color: var(--muted); margin: 0; padding: 0 16px 16px; }
.user-app-access__list { border-top: 1px solid var(--border); }
.user-app-access__row { align-items: center; display: flex; gap: 16px; justify-content: space-between; margin: 0; min-height: 58px; padding: 10px 16px; }
.user-app-access__row + .user-app-access__row { border-top: 1px solid var(--border); }
.user-app-access__choice { align-items: center; cursor: pointer; display: inline-flex; flex: 1 1 auto; gap: 10px; min-width: 0; }
.user-app-access__choice input[type="checkbox"] { accent-color: var(--brand); appearance: auto; background: transparent; border: 0; flex: 0 0 18px; height: 18px; margin: 0; min-height: 0; padding: 0; width: 18px; }
.user-app-access__choice span { font-size: 13px; font-weight: 650; }
.user-app-access__row .btn-pill { flex: 0 0 auto; }
.user-password-actions { display: grid; gap: 12px; padding: 0 16px 16px; }
.user-password-set { align-items: end; display: grid; gap: 8px; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto; }
.user-password-set label { display: grid; gap: 6px; }
.user-password-set label > span { color: var(--muted); font-size: 11px; }
.user-password-reset-form { border-top: 1px solid var(--border); display: flex; justify-content: flex-end; padding-top: 10px; }
.session-list { border-top: 1px solid var(--border); }
.session-row { align-items: center; display: grid; gap: 12px; grid-template-columns: 34px minmax(0, 1fr) auto; padding: 12px 16px; }
.session-row + .session-row { border-top: 1px solid var(--border); }
.session-row.is-current { background: color-mix(in srgb, var(--brand-weak) 38%, var(--surface)); }
.session-device-icon { align-items: center; background: var(--brand-weak); border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--border)); border-radius: 9px; color: var(--brand-hover); display: inline-flex; font-size: 16px; height: 34px; justify-content: center; width: 34px; }
.session-copy { min-width: 0; }
.session-title { align-items: center; display: flex; flex-wrap: wrap; gap: 7px; }
.session-title strong { font-size: 13px; }
.session-current { background: var(--brand-weak); border-radius: 999px; color: var(--brand-hover); font-size: 10px; font-weight: 700; padding: 2px 7px; text-transform: uppercase; }
.session-copy p { color: var(--muted); display: flex; flex-wrap: wrap; font-size: 11px; gap: 5px 14px; margin: 3px 0 0; }
.session-row form { margin: 0; }
.session-empty { border-top: 1px solid var(--border); color: var(--muted); margin: 0; padding: 18px 16px; }
.session-empty--warning { background: #fff7ed; color: #9a3412; }

@media (max-width: 640px) {
  .fullscreenContentTable { height: calc(100dvh - var(--topbar-height) - 12px); }
  .fullscreenContentTable__tools { min-height: 38px; }
  .fullscreenContentTable__primaryAction { font-size: 0; }
  .fullscreenContentTable__primaryAction > span { font-size: 18px; }
  .fullscreenContentTable__pagination { grid-template-columns: minmax(0, 1fr) auto; }
  .fullscreenContentTable__paginationControls { grid-column: 1; justify-self: start; }
  .fullscreenContentTable__paginationRange { grid-column: 2; }
  .user-editor-fields { grid-template-columns: 1fr; }
  .user-editor-fields label:nth-child(odd) { border-right: 0; }
  .user-password-set { grid-template-columns: 1fr; }
  .user-password-set .btn-pill { justify-self: start; }
  .user-password-reset-form { justify-content: flex-start; }
  .user-editor-section__header--actions { align-items: stretch; flex-direction: column; }
  .user-editor-section__header--actions form { align-self: flex-start; }
  .user-app-access__row { gap: 10px; }
  .session-row { align-items: start; grid-template-columns: 34px minmax(0, 1fr); }
  .session-row form { grid-column: 2; }
}

@media (prefers-color-scheme: dark) {
  .fullscreenContentTable__table th { background: #1b2638; color: #cbd5e1; }
  .fullscreenContentTable__table tbody tr:hover td { background: #0d2f2d; }
  .filter-chip { background: #172554; border-color: #1d4ed8; color: #93c5fd; }
}
