:root {
  color-scheme: dark;
  --bg: #0f1218;
  --panel: #181c24;
  --panel-soft: #202633;
  --text: #f7f8fb;
  --muted: #a9afbd;
  --line: #343b4d;
  --blue: #4f7cff;
  --green: #43d18b;
  --orange: #f4b348;
  --red: #ff5967;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body.admin-shell {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(79, 124, 255, 0.22), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-size: 0.94rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.35rem 0.75rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.6rem);
  letter-spacing: -0.05em;
}

h2 {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.eyebrow {
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-logo {
  display: block;
  width: clamp(13rem, 28vw, 18rem);
  height: auto;
  aspect-ratio: 721 / 110;
}

.topbar h1 {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.layout {
  display: grid;
  grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0 1.35rem 1.35rem;
}

.auth-gate {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 9rem);
  padding: 1rem 1.35rem 2rem;
}

.auth-panel {
  width: min(100%, 30rem);
  padding: 1.35rem;
}

.auth-panel h2 {
  margin-top: 0.35rem;
}

.admin-workspace[hidden],
.auth-gate[hidden],
.message[hidden],
[hidden] {
  display: none !important;
}

.shell-message {
  max-width: 58rem;
  margin: 0 auto 1rem;
}

.layout.sidebar-collapsed {
  grid-template-columns: minmax(6.5rem, 7rem) minmax(0, 1fr);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 1.3rem;
  background: rgba(24, 28, 36, 0.92);
  box-shadow: var(--shadow);
}

.settings-panel {
  position: sticky;
  top: 1rem;
  align-self: start;
  padding: 1rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.layout.sidebar-collapsed .settings-panel label,
.layout.sidebar-collapsed .settings-panel .auth-card,
.layout.sidebar-collapsed .settings-panel .hint,
.layout.sidebar-collapsed .settings-panel .primary,
.layout.sidebar-collapsed .settings-panel > .secondary,
.layout.sidebar-collapsed .settings-panel h2,
.layout.sidebar-collapsed .nav button {
  display: none;
}

.layout.sidebar-collapsed .settings-panel {
  width: 100%;
  max-width: 7rem;
  padding: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.layout.sidebar-collapsed .sidebar-header {
  justify-content: center;
}

.layout.sidebar-collapsed #toggleSidebarButton {
  width: 100%;
}

.layout.sidebar-collapsed .nav {
  display: none;
}

.content {
  min-width: 0;
}

.view {
  padding: 1rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.actions,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.table-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

label {
  display: grid;
  gap: 0.4rem;
  margin-top: 1rem;
  color: var(--muted);
  font-weight: 700;
}

.auth-card {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.9rem;
  padding: 0.8rem;
  border: 1px solid rgba(79, 124, 255, 0.35);
  border-radius: 1rem;
  background: rgba(32, 38, 51, 0.72);
}

.totp-panel {
  display: grid;
  gap: 0.55rem;
}

.totp-qr {
  width: min(12rem, 100%);
  border-radius: 0.85rem;
  background: #ffffff;
  padding: 0.5rem;
}

.recovery-codes {
  display: grid;
  gap: 0.45rem;
  padding: 0.65rem;
  border: 1px solid rgba(244, 179, 72, 0.45);
  border-radius: 0.8rem;
  color: var(--text);
  background: rgba(244, 179, 72, 0.08);
}

.recovery-codes ul {
  margin: 0;
  padding-left: 1.1rem;
}

input,
textarea,
select,
button {
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
}

input,
textarea,
select {
  min-height: 2.45rem;
  padding: 0.6rem 0.7rem;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.18);
}

button {
  min-height: 2.45rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  font-weight: 800;
}

.compact-button {
  min-height: 2.2rem;
  padding: 0.45rem 0.7rem;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary {
  width: 100%;
  margin-top: 1rem;
  border-color: transparent;
  background: var(--blue);
}

.secondary {
  border-color: var(--line);
  background: transparent;
}

.danger {
  border-color: var(--red);
  background: transparent;
  color: var(--red);
}

.hint {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 2.1rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.status-pill.ok,
.badge.ok {
  border-color: rgba(67, 209, 139, 0.45);
  color: var(--green);
}

.status-pill.error,
.badge.error {
  border-color: rgba(255, 89, 103, 0.55);
  color: var(--red);
}

.nav {
  display: grid;
  gap: 0.45rem;
  margin-top: 1.4rem;
}

.nav button {
  width: 100%;
  text-align: left;
}

.nav button.active {
  border-color: transparent;
  background: var(--blue);
}

.message {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel-soft);
  color: var(--muted);
}

.message.error {
  border-color: rgba(255, 89, 103, 0.55);
  color: var(--red);
}

.message.success {
  border-color: rgba(67, 209, 139, 0.45);
  color: var(--green);
}

.selected-user-context {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(32, 38, 51, 0.68);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.selected-user-context strong {
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.55rem;
}

.grid.compact {
  margin-bottom: 1rem;
}

.metric {
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel-soft);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 0.35rem;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.table-shell {
  display: grid;
  gap: 0.55rem;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
  scrollbar-gutter: stable;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.admin-shell th,
.admin-shell td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

th {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#customersTable table,
#deletedTable table {
  min-width: 0;
}

#customersTable th:nth-child(1),
#deletedTable th:nth-child(1) {
  width: 22%;
}

#customersTable th:nth-child(2),
#deletedTable th:nth-child(2) {
  width: 13%;
}

#customersTable th:nth-child(3),
#deletedTable th:nth-child(3) {
  width: 11%;
}

#customersTable th:nth-child(4),
#deletedTable th:nth-child(4),
#customersTable th:nth-child(5),
#deletedTable th:nth-child(5) {
  width: 12%;
}

#customersTable th:nth-child(6),
#deletedTable th:nth-child(6) {
  width: 14%;
}

tr[data-user-id] {
  cursor: pointer;
}

tr[data-user-id]:hover {
  background: rgba(79, 124, 255, 0.12);
}

.empty {
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 1rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 0 1rem 1rem;
  }

  .settings-panel {
    position: static;
  }

  .layout.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 1rem;
  }
}
