/* Admin: aligns with app tokens + light shell when used inside .company-shell */
h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
  color: var(--ink, #0f172a);
}
h2 {
  font-size: 1.1rem;
  margin: 12px 0 8px;
  color: var(--ink, #0f172a);
}
.card {
  border-radius: var(--radius-card, 8px);
  padding: var(--appCardPadding-lg, 22px);
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft, 0 1px 3px rgba(15, 23, 42, 0.06));
  border: 1px solid var(--line, #e2e8f0);
  background: var(--surface, #ffffff);
}

.admin-card {
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  background: var(--surface, #fff);
}

.btn {
  border-radius: var(--radius-input, 8px);
  padding: 0 var(--appButtonPadding-x, 14px);
  min-height: var(--appButtonHeight, 40px);
  gap: 6px;
}
.btn.small {
  padding: 4px 8px;
  font-size: 0.9rem;
}

/* Primary actions: clean flat style (less heavy than default CTA gradient) */
.company-shell .btn--admin-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  text-shadow: none;
  box-shadow: none;
}
.company-shell .btn--admin-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.company-shell .card .row input,
.company-shell .card .row select,
.company-shell .card input,
.company-shell .card select {
  max-width: none;
  flex: 1;
  min-width: 0;
}
input,
select {
  border-radius: var(--radius-input, 8px);
  padding: 8px 10px;
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--control-border, var(--line, #e2e8f0));
  background: var(--control-bg, #fff);
  color: var(--control-text, var(--ink));
}
label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: var(--muted, #64748b);
}
.row {
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

/* Toolbar: primary action + hint (no full-width space-between on short rows) */
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-bottom: 4px;
}
.admin-toolbarHint {
  flex: 1 1 200px;
  min-width: 0;
  line-height: 1.4;
}
/* Data tables: fixed layout keeps body cells aligned with headers */
.admin-tableWrap {
  margin-top: 12px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: var(--radius-card, 8px);
  overflow: hidden;
  background: var(--table-bg, #fff);
}
.admin-data-table {
  table-layout: fixed;
  width: 100%;
  max-width: none;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 0.92rem;
}
.admin-data-table th,
.admin-data-table td {
  border-top: none;
  padding: 11px 14px;
  text-align: left;
  vertical-align: middle;
  word-break: break-word;
}
.admin-data-table thead th {
  position: static;
  background: var(--table-header-bg, #f1f5f9);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #475569;
  border-bottom: 1px solid var(--line, #e2e8f0);
  white-space: nowrap;
}
.admin-data-table tbody td {
  border-bottom: 1px solid var(--border-subtle, #f1f5f9);
  color: var(--ink, #0f172a);
}
.admin-data-table tbody tr:last-child td {
  border-bottom: none;
}
.admin-data-table tbody tr:hover td {
  background: var(--table-row-hover-bg, #f8fafc);
}
.admin-data-table__col-actions {
  text-align: right;
  width: 120px;
  box-sizing: border-box;
}
.admin-data-table--companies tbody td:nth-child(4),
.admin-data-table--users tbody td:nth-child(6) {
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}
.admin-data-table--companies th:nth-child(1),
.admin-data-table--companies td:nth-child(1) {
  width: 64px;
}
.admin-data-table--companies th:nth-child(2),
.admin-data-table--companies td:nth-child(2) {
  width: 32%;
}
.admin-data-table--companies th:nth-child(3),
.admin-data-table--companies td:nth-child(3) {
  width: 36%;
}
.admin-data-table--users th:nth-child(1),
.admin-data-table--users td:nth-child(1) {
  width: 56px;
}
.admin-data-table--users th:nth-child(2),
.admin-data-table--users td:nth-child(2) {
  width: 26%;
}
.admin-data-table--users th:nth-child(3),
.admin-data-table--users td:nth-child(3) {
  width: 20%;
}
.admin-data-table--users th:nth-child(4),
.admin-data-table--users td:nth-child(4) {
  width: 72px;
  text-align: center;
}
.admin-data-table--users th:nth-child(5),
.admin-data-table--users td:nth-child(5) {
  width: 14%;
  font-variant-numeric: tabular-nums;
}

.company-shell .scroll-wrap {
  overflow-x: auto;
  margin-top: 12px;
  border-radius: var(--radius-card, 8px);
  border: 1px solid var(--line, #e2e8f0);
}
.err {
  color: #dc2626;
}
.hidden {
  display: none !important;
}

.adminRoleLabel {
  font-weight: 600;
  color: var(--ink, #0f172a);
}

.adminCheckboxRow {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--ink, #0f172a);
  margin: 12px 0 0;
}

.adminCheckboxRow input[type="checkbox"] {
  width: auto;
  max-width: none;
  flex: 0 0 auto;
  margin-top: 2px;
}

/* ---- Admin console layout (scoped to admin page) ---- */
.visuallyHidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Admin summary: four stat tiles (company workspace pattern lives in company.css) */
body[data-app-page="admin"] .company-stats--admin {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1024px) {
  body[data-app-page="admin"] .company-stats--admin {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body[data-app-page="admin"] .company-stats--admin {
    grid-template-columns: 1fr;
  }
}

.adminPrefsCard {
  margin-bottom: 16px;
}

.adminTabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line, #e2e8f0);
}

.adminTab {
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted, #64748b);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.adminTab:hover {
  color: var(--ink, #0f172a);
}

.adminTab.is-active {
  color: var(--ink, #0f172a);
  border-bottom-color: #0ea5e9;
}

.adminTabPanel {
  display: none;
  margin-top: 12px;
}

.adminTabShell > .adminTabPanel {
  margin-top: 0;
}

.adminTabPanel.is-visible {
  display: block;
}

/* Companies / Users: tabs + toolbar + table + pagination in one card */
.company-shell .adminTabShell {
  margin-bottom: 0;
  padding: clamp(14px, 2vw, 20px) clamp(16px, 2vw, 22px) clamp(14px, 2vw, 18px);
  box-shadow: var(--shadow-card, 0 8px 24px rgba(15, 23, 42, 0.07));
}

.adminToolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 10px;
}

.adminToolbar__search {
  flex: 1 1 220px;
  min-width: 0;
}

.adminToolbar__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.adminToolbar__primary {
  flex: 0 0 auto;
  margin-left: auto;
}

.adminToolbarInput {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding: 8px 10px;
  border-radius: var(--radius-input, 8px);
  border: 1px solid var(--control-border, var(--line, #e2e8f0));
  background: var(--control-bg, #fff);
  color: var(--control-text, var(--ink));
}

.adminToolbarInput::placeholder {
  color: var(--muted, #64748b);
  opacity: 1;
}

.adminToolbarInput--narrow {
  width: auto;
  min-width: 140px;
}

.admin-tableWrap--scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-data-table--compact th,
.admin-data-table--compact td {
  padding: 8px 10px;
  font-size: 0.88rem;
}

.admin-data-table__col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.adminPagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--muted, #64748b);
}

.adminPagination button {
  min-height: 36px;
}

.adminEmpty {
  margin-top: 12px;
}

.bpCompanyAccessList {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.bpCompanyAccessRow {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* Drawer */
.adminDrawerRoot {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
}

.adminDrawerRoot:not(.hidden) {
  pointer-events: auto;
}

.adminDrawerBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.adminDrawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(440px, 100%);
  background: var(--surface, #fff);
  border-left: 1px solid var(--line, #e2e8f0);
  box-shadow: -4px 0 24px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.adminDrawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line, #e2e8f0);
}

.adminDrawer__title {
  margin: 0;
  font-size: 1.1rem;
}

.adminDrawer__body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.adminDrawerSection {
  margin-bottom: 20px;
}

.adminDrawerSection h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #64748b);
  margin: 0 0 8px;
}

.adminDrawerNav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.adminDrawerNav button {
  font-size: 0.85rem;
}

.adminDrawerMeta {
  font-size: 0.92rem;
  line-height: 1.5;
}

.adminDrawerMeta dt {
  font-weight: 600;
  color: var(--muted, #64748b);
  margin-top: 8px;
}

.adminDrawerMeta dd {
  margin: 4px 0 0;
}

@media (max-width: 720px) {
  .adminToolbar__primary {
    width: 100%;
    margin-left: 0;
  }

  .adminDrawer {
    width: 100%;
  }
}

/* Dark shell only: admin uses .company-shell in light + dark; do not force dark chrome in light mode */
html[data-theme="dark"] .company-shell .adminDrawer,
html[data-theme="dark"] .company-shell .admin-data-table thead th {
  background: var(--surface-elevated, rgba(30, 41, 59, 0.92));
  border-color: var(--line, rgba(148, 163, 184, 0.35));
  color: var(--ink, #f8fafc);
}

html[data-theme="dark"] .company-shell .admin-data-table tbody td {
  color: var(--ink, #f8fafc);
}

html[data-theme="dark"] .company-shell .admin-data-table tbody tr:hover td {
  background: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"] .company-shell .adminTab:not(.is-active) {
  color: var(--muted, #94a3b8);
}

html[data-theme="dark"] .company-shell .adminToolbarInput {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.35);
  color: var(--ink, #f8fafc);
}

html[data-theme="dark"] .company-shell .adminToolbarInput::placeholder {
  color: #94a3b8;
  opacity: 1;
}

html[data-theme="dark"] .company-shell .adminDrawerBackdrop {
  background: rgba(2, 6, 23, 0.65);
}

.adminCellMuted {
  color: var(--muted, #64748b);
}
