:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #13202f;
  --muted: #5f6c7b;
  --border: #d7dee7;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --danger: #c62828;
  --shadow: 0 14px 36px rgba(19, 32, 47, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 180px),
    var(--bg);
}

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 32, 0.58);
  backdrop-filter: blur(4px);
}

.auth-modal--confirm {
  z-index: 70;
}

.auth-modal.is-hidden {
  display: none;
}

.auth-modal__card {
  width: min(500px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 14px;
}

.auth-modal__card--wide {
  width: min(640px, 100%);
}

.auth-modal__card details {
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(215, 222, 231, 0.8);
}

.topbar__subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--muted);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel--wide {
  grid-column: 1 / -1;
}

.panel__header,
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.users-hint {
  margin-bottom: 12px;
  font-size: 14px;
}

.tabs {
  display: flex;
  gap: 10px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--border);
}

.tab {
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 12px 12px 0 0;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.stack {
  display: grid;
  gap: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

label span {
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.checkbox {
  align-items: center;
  grid-template-columns: 16px 1fr;
  gap: 10px;
  min-height: 42px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:not(:disabled):hover {
  background: var(--accent-2);
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:not(:disabled):hover {
  border-color: #b9c3cf;
  background: #f9fbfd;
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #efb8b8;
}

.btn-danger:not(:disabled):hover {
  background: #fff5f5;
  border-color: #d96d6d;
}

/* Disabled buttons (e.g. delete/disable-access on your own row) read as
   inactive: dimmed, muted, and not clickable. */
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-small {
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
}

.btn-action {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text);
}

.btn-action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-action.btn-danger {
  color: var(--danger);
}

/* Trash-button delete-in-progress state: hide the icon, show a spinner in its
   place so the button keeps its size and the admin gets feedback the click
   registered (a full-cascade delete can take a moment). */
.btn-action.is-loading svg {
  visibility: hidden;
}

.btn-action.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-action-spin 0.6s linear infinite;
}

@keyframes btn-action-spin {
  to {
    transform: rotate(360deg);
  }
}

.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 74px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status {
  color: var(--muted);
  font-size: 13px;
}

.status--error {
  color: var(--danger);
}

/* Error and validation messages: orange. Success messages: dark green. */
.status[data-kind="error"] {
  color: #d9480f;
}

.status[data-kind="ok"] {
  color: #15803d;
}

.output {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: #111827;
  color: #e5eef8;
  overflow: auto;
  min-height: 92px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.sort-btn.is-active {
  color: var(--accent);
}

.sort-indicator {
  font-size: 12px;
  line-height: 1;
  color: inherit;
}

/* A just-created row (user or document) floated to the top of the list. Subtle
   highlight + accent bar so the admin can spot the row they just added. */
tr.is-pinned td {
  background: #eef6ff;
}

tr.is-pinned td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

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

.row--end {
  justify-content: flex-end;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdff;
}

.toolbar__group {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar__group label {
  min-width: 132px;
}

.toolbar__search {
  min-width: 220px;
  flex: 1 1 240px;
}

.toolbar__search input {
  width: 100%;
}

.toolbar__group--end {
  margin-left: auto;
}

.table-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.table-footer__pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.table-footer__refresh {
  justify-self: end;
}

.table-footer__spacer {
  min-width: 1px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

.tab-panel[hidden] {
  display: none;
}

.shell[aria-hidden="true"] {
  filter: blur(1px);
  pointer-events: none;
  user-select: none;
}

@media (max-width: 900px) {
  .grid,
  .field-grid,
  .field-grid--three {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .topbar,
  .panel__header,
  .row,
  .toolbar,
  .toolbar__group,
  .table-footer {
    align-items: start;
    flex-direction: column;
  }

  .auth-modal__card--wide {
    width: min(100%, 640px);
  }

  .toolbar__group--end {
    margin-left: 0;
  }

  .table-footer__refresh {
    justify-self: start;
  }

}

/* Nav tabs are now <a data-link> instead of <button>; keep the button look. */
a.tab {
  display: inline-block;
  text-decoration: none;
}
