
/* Admin surface owns its visual layer. Shared styles.css still loads for base
   primitives; every workspace rule is scoped under #adminShell so it outranks
   the shared button and panel rules without touching the main app. */
:root { --admin-ink: #10213b; --admin-muted: #6b7a90; --admin-line: #e1e8f1; --admin-blue: #1769e0; }
body:has(#adminShell) { min-height: 100vh; background: #f4f7fb; }

/* Login (unchanged) */
body:has(#adminShell) .auth-view { min-height: 100vh; display: grid; grid-template-columns: 1fr; padding: 24px; background: radial-gradient(circle at 18% 12%, rgba(74, 142, 234, .14), transparent 34%), #f4f7fb; }
body:has(#adminShell) .auth-card { width: min(420px, 100%); border-radius: 16px; }

/* Workspace */
#adminShell {
  --shell-top: 68px;
  --ink: var(--admin-ink);
  --muted: var(--admin-muted);
  --line: var(--admin-line);
  --soft: #f6f8fb;
  color: var(--ink);
}

/* Buttons: one consistent set inside the workspace. */
#adminShell button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #d3dce8;
  border-radius: 9px;
  background: #fff;
  color: #344054;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  transform: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
#adminShell button:hover:not(:disabled),
#adminShell button:focus-visible {
  border-color: #b8c8dd;
  background: #f5f8fc;
  color: #1d2939;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  transform: none;
}
#adminShell button:focus-visible { outline: 3px solid rgba(23, 105, 224, .25); outline-offset: 1px; }
#adminShell button.primary { border-color: var(--admin-blue); background: var(--admin-blue); color: #fff; }
#adminShell button.primary:hover:not(:disabled) { border-color: #0f57c2; background: #0f57c2; color: #fff; }
#adminShell button.danger { border-color: #f1c8c4; background: #fff6f5; color: #b42318; }
#adminShell button.danger:hover:not(:disabled) { border-color: #e59a93; background: #fdecea; color: #912018; }
#adminShell button.ghost { border-color: #b7e0cf; background: #f0faf5; color: #067647; }
#adminShell button.ghost:hover:not(:disabled) { border-color: #86cdb1; background: #e3f6ed; color: #05603a; }
#adminShell button:disabled { opacity: .5; cursor: not-allowed; }
#adminShell input {
  min-width: 0;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d3dce8;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  box-shadow: none;
}
#adminShell input:focus { border-color: #6aa3f2; outline: none; box-shadow: 0 0 0 3px rgba(23, 105, 224, .12); }
#adminShell .empty {
  min-height: 96px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 18px;
  border: 1px dashed #d6dfea;
  border-radius: 12px;
  background: #fafcfe;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* Top bar: brand · view tabs · session actions */
#adminShell .admin-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  gap: 32px;
  height: var(--shell-top);
  min-height: 0;
  padding: 0 28px;
  border: 0;
  background: #0b1c35;
  color: #fff;
  box-shadow: 0 6px 20px rgba(11, 28, 53, .18);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
#adminShell .admin-brand { display: flex; align-items: center; gap: 14px; }
#adminShell .admin-brand-logo { display: block; width: auto; height: 34px; }
#adminShell .admin-brand-divider { width: 1px; height: 26px; background: rgba(255, 255, 255, .18); }
#adminShell .admin-topbar .brand { display: block; color: #fff; font-size: 15px; font-weight: 750; line-height: 1.3; }
#adminShell .admin-topbar .brand::before { content: none; display: none; }
#adminShell .admin-topbar .sub { margin-top: 2px; color: #93a8c6; font-size: 11px; }
#adminShell .admin-topbar .account { display: flex; align-items: center; gap: 8px; }
#adminShell .admin-topbar .account button {
  min-height: 34px;
  border-color: rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .07);
  color: #e3edfb;
  box-shadow: none;
}
#adminShell .admin-topbar .account button:hover:not(:disabled) {
  border-color: rgba(132, 211, 255, .45);
  background: rgba(132, 211, 255, .14);
  color: #fff;
}
#adminShell .admin-tabs { display: flex; align-items: stretch; gap: 4px; }
#adminShell button.admin-tab {
  position: relative;
  height: 100%;
  min-height: 0;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #a9bdd8;
  font-size: 14px;
  box-shadow: none;
}
#adminShell button.admin-tab:hover:not(:disabled) { border: 0; background: rgba(255, 255, 255, .05); color: #fff; box-shadow: none; }
#adminShell button.admin-tab.active { color: #fff; }
#adminShell button.admin-tab.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: #5cb8ff;
}
#adminShell .admin-tab-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f79009;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
}
#adminShell .admin-tab-badge.hidden { display: none; }

/* Views fill the viewport under the top bar; lists scroll inside their panels. */
#adminShell .admin-main {
  height: calc(100vh - var(--shell-top));
  min-height: 560px;
  padding: 20px 28px 24px;
  background: #f4f7fb;
}
#adminShell .admin-main.hidden { display: none; }
#adminShell .admin-users-view {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 20px;
}
#adminShell .admin-main > .panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .04);
}

/* User list column */
#adminShell .admin-users-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
}
#adminShell .admin-users-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); font-size: 16px; }
#adminShell .admin-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
#adminShell .admin-count:empty { display: none; }
#adminShell .admin-invite { position: relative; }
#adminShell .admin-invite > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid #c9dcf6;
  border-radius: 8px;
  background: #f1f7ff;
  color: #1554b0;
  font-size: 12px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}
#adminShell .admin-invite > summary::-webkit-details-marker { display: none; }
#adminShell .admin-invite > summary::before { content: "+"; font-size: 15px; line-height: 1; }
#adminShell .admin-invite[open] > summary { border-color: var(--admin-blue); background: #e7f0ff; }
#adminShell .admin-invite-body {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  display: grid;
  gap: 8px;
  width: 300px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(16, 24, 40, .14);
}
#adminShell .admin-invite-body .auth-message { margin: 0; min-height: 0; color: #475467; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
#adminShell .admin-invite-body .auth-message:empty { display: none; }
#adminShell .admin-search {
  display: flex;
  gap: 8px;
  padding: 0 18px 14px;
  border-bottom: 1px solid #edf1f6;
  background: transparent;
}
#adminShell .admin-search input { flex: 1; }
#adminShell .admin-list {
  display: grid;
  align-content: start;
  gap: 4px;
  flex: 1;
  min-height: 0;
  padding: 10px;
  overflow-y: auto;
}
#adminShell button.admin-user-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: center;
  width: 100%;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-weight: 400;
  text-align: left;
  white-space: normal;
  box-shadow: none;
}
#adminShell button.admin-user-card:hover:not(:disabled) { border-color: transparent; background: var(--soft); }
#adminShell button.admin-user-card.active { border-color: #cfe0f8; background: #eef5ff; box-shadow: inset 3px 0 var(--admin-blue); }
#adminShell .admin-user-card b { min-width: 0; margin: 0; overflow: hidden; color: var(--ink); font-size: 14px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
#adminShell .admin-user-card span,
#adminShell .admin-user-card em { grid-column: 1 / -1; display: block; min-width: 0; margin: 0; overflow: hidden; color: var(--muted); font-size: 12px; font-style: normal; line-height: 1.55; text-overflow: ellipsis; white-space: nowrap; }
#adminShell .admin-user-card em { color: #8a97a8; font-size: 11px; }
#adminShell .admin-user-card i {
  grid-column: 2;
  grid-row: 1;
  white-space: nowrap;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}
#adminShell .admin-user-card i.ok { background: #ecfdf3; color: #067647; }
#adminShell .admin-user-card i.off { background: #f2f4f7; color: #667085; }

/* Status pills shared by user detail and orders */
#adminShell .admin-status { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
#adminShell .admin-status.is-ok { background: #ecfdf3; color: #067647; }
#adminShell .admin-status.is-off { background: #fef3f2; color: #b42318; }
#adminShell .admin-status.is-warn { background: #fffaeb; color: #b54708; }
#adminShell .admin-status.is-muted { background: #f2f4f7; color: #667085; }

/* User detail */
#adminShell .admin-detail { overflow-y: auto; }
#adminShell .admin-detail-inner { min-height: 100%; padding: 26px 30px 32px; }
#adminShell .admin-detail-inner > .empty { min-height: 320px; }
#adminShell .admin-detail-head { display: flex; align-items: center; gap: 16px; margin: 0; padding: 0 0 22px; border-bottom: 1px solid #edf1f6; }
#adminShell .admin-detail-head > div { flex: 1; min-width: 0; }
#adminShell .admin-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1769e0, #5b6ee8);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
}
#adminShell .admin-detail-head h1 { margin: 0; color: var(--ink); font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
#adminShell .admin-detail-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
#adminShell .admin-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 22px 0 0; }
#adminShell .admin-metrics div { padding: 16px 18px; border: 1px solid #e7edf4; border-radius: 12px; background: var(--soft); }
#adminShell .admin-metrics b { display: block; color: var(--ink); font-size: 26px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
#adminShell .admin-metrics span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
#adminShell .admin-actions-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 16px 0 0;
  padding: 16px 18px;
  border: 1px solid #e7edf4;
  border-radius: 12px;
  background: #fff;
}
#adminShell .admin-action { display: grid; gap: 7px; min-width: 0; }
#adminShell .admin-action > label,
#adminShell .admin-action-label { color: #475467; font-size: 12px; font-weight: 700; }
#adminShell .admin-action > div { display: flex; gap: 8px; }
#adminShell .admin-action input { flex: 1; }
#adminShell .admin-action input[type="number"] { font-variant-numeric: tabular-nums; }
#adminShell .admin-detail .admin-section { margin: 26px 0 0; padding: 0; border: 0; }
#adminShell .admin-detail .admin-section h2 { margin: 0 0 12px; color: var(--ink); font-size: 15px; font-weight: 750; }
#adminShell .admin-record-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; max-height: none; padding: 0; overflow: visible; }
#adminShell .admin-record-list > .empty { grid-column: 1 / -1; }
#adminShell .admin-record-list .history-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid #e7edf4;
  border-radius: 12px;
  background: #fff;
  box-shadow: none;
}
#adminShell .admin-record-list .history-item:hover { border-color: #cbd9ec; box-shadow: 0 4px 14px rgba(16, 24, 40, .06); }
#adminShell .history-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
#adminShell .history-meta .tag { padding: 1px 8px; border: 0; border-radius: 999px; background: #eef4ff; color: #1554b0; font-size: 11px; }
#adminShell .history-item h3 { margin: 0; color: var(--ink); font-size: 14px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#adminShell .history-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#adminShell button.record-open { align-self: flex-start; min-height: 30px; margin-top: auto; padding: 0 11px; font-size: 12px; }
#adminShell .admin-log-table { width: 100%; border: 1px solid #e7edf4; border-radius: 12px; border-collapse: separate; border-spacing: 0; overflow: hidden; font-size: 12px; }
#adminShell .admin-log-table th,
#adminShell .admin-log-table td { padding: 10px 14px; border: 0; border-bottom: 1px solid #eef2f6; text-align: left; }
#adminShell .admin-log-table th { background: var(--soft); color: #475467; font-weight: 700; }
#adminShell .admin-log-table td { color: #344054; font-variant-numeric: tabular-nums; }
#adminShell .admin-log-table tbody tr:last-child td { border-bottom: 0; }
#adminShell .admin-log-table tbody tr:hover td { background: #fafcff; }

/* Membership orders */
#adminShell .admin-orders-view { display: flex; flex-direction: column; }
#adminShell .admin-membership { flex: 1; }
#adminShell .admin-orders-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 26px 18px;
  border-bottom: 1px solid #edf1f6;
}
#adminShell .admin-orders-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--ink); font-size: 18px; font-weight: 800; }
#adminShell .admin-orders-head h2 small { padding: 2px 8px; border-radius: 999px; background: #fffaeb; color: #b54708; font-size: 11px; font-weight: 700; }
#adminShell .admin-orders-head p { max-width: 760px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
#adminShell .admin-orders-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 18px 26px 0; }
#adminShell .admin-orders-summary > div { padding: 14px 16px; border: 1px solid #e7edf4; border-radius: 12px; background: var(--soft); }
#adminShell .admin-orders-summary b { display: block; color: var(--ink); font-size: 24px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
#adminShell .admin-orders-summary span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
#adminShell .admin-orders-summary .is-warn b { color: #b54708; }
#adminShell .admin-orders-summary .is-ok b { color: #067647; }
#adminShell .admin-orders-summary .is-off b { color: #b42318; }
#adminShell .admin-orders-list { display: grid; align-content: start; gap: 10px; flex: 1; min-height: 0; padding: 18px 26px 26px; overflow-y: auto; }
#adminShell .admin-order {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 20px;
  padding: 16px 18px;
  border: 1px solid #e7edf4;
  border-left: 3px solid #d0d5dd;
  border-radius: 12px;
  background: #fff;
}
#adminShell .admin-order.is-warn { border-left-color: #f79009; background: #fffdf7; }
#adminShell .admin-order.is-ok { border-left-color: #12b76a; }
#adminShell .admin-order.is-off { border-left-color: #f04438; }
#adminShell .admin-order-title { display: flex; align-items: center; gap: 10px; }
#adminShell .admin-order-title b { color: var(--ink); font-size: 15px; }
#adminShell .admin-order-main > p { margin: 3px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
#adminShell .admin-order dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 18px; margin: 14px 0 0; }
#adminShell .admin-order dl div { min-width: 0; }
#adminShell .admin-order dt { color: #8a97a8; font-size: 11px; }
#adminShell .admin-order dd { margin: 2px 0 0; color: #344054; font-size: 12px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#adminShell .admin-order-side { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding-left: 18px; border-left: 1px solid #eef2f6; }
#adminShell .admin-order-side strong { color: var(--ink); font-size: 22px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
