/* Super admin, My account and sign-in additions. Page content rules are scoped to body.admin-area so
   the market pages keep their existing look; the sidebar additions apply everywhere. */

/* ---------- sidebar ---------- */
.nav-section-label {
  margin: 18px 12px 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: #8a97ab;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -6px 10px;
  padding: 8px 6px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
.sidebar-user:hover,
.sidebar-user.active {
  background: #f2f6ff;
}
.sidebar-user b {
  display: block;
  max-width: 170px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #e9f1ff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

/* ---------- shared bits (also used by the sign-in and error pages) ---------- */
.notice {
  margin: 0 0 16px;
  padding: 11px 14px;
  border: 1px solid;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.notice ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
.notice p {
  margin: 0;
}
.notice-ok {
  border-color: #bfe8d6;
  background: #effaf5;
  color: #0f6b4e;
}
.notice-error {
  border-color: #ffd6dc;
  background: #fff2f4;
  color: #a62a3d;
}
.login-card .notice {
  margin: 0;
  font-size: 12px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover {
  border-color: #c8d3e4;
  background: #f7f9fd;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover {
  border-color: #1d4fd0;
  background: #1d4fd0;
}
.btn-danger {
  border-color: #f3c3ca;
  background: #fff;
  color: var(--red);
}
.btn-danger:hover {
  border-color: var(--red);
  background: #fff2f4;
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: #526278;
}
.btn-sm {
  min-height: 30px;
  padding: 5px 11px;
  font-size: 12px;
}
.empty-state {
  max-width: 560px;
  margin: 40px auto;
  text-align: center;
}
.empty-state h1 {
  margin: 0 0 8px;
  font-size: 22px;
}
.empty-state p {
  margin: 0 0 18px;
  color: var(--muted);
}

/* ---------- admin pages ---------- */
.admin-area .content > .panel,
.admin-area .content > .stat-row,
.admin-area .content > .subnav,
.admin-area .content > .notice {
  margin-bottom: 18px;
}
.admin-area .page-heading {
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
}
.admin-area .page-heading .subtitle {
  overflow-wrap: anywhere;
}
.heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.heading-actions form {
  margin: 0;
}
.back-link {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}
.back-link:hover {
  color: var(--blue);
}
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.stat-card {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.stat-card small {
  color: var(--muted);
  font-size: 12px;
}
.stat-card b {
  font-size: 22px;
  font-weight: 750;
}
.stat-card b.stat-text {
  font-size: 14px;
}
.stat-card b .badge {
  font-size: 12px;
  vertical-align: middle;
}
.text-green {
  color: var(--green);
}
.text-red {
  color: var(--red);
}
.text-amber {
  color: var(--amber);
}
.muted {
  color: var(--muted);
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.subnav a {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #526278;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}
.subnav a:hover,
.subnav a.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #eef4ff;
}
.admin-area .panel {
  scroll-margin-top: 80px;
}
.admin-area .panel-head {
  margin-bottom: 14px;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.toolbar input[type="search"],
.toolbar input[type="email"] {
  flex: 1 1 240px;
  min-width: 0;
}
.toolbar input,
.toolbar select,
.stack-form input,
.stack-form select,
.stack-form textarea {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid #d9e1ec;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.stack-form textarea {
  resize: vertical;
}
.toolbar input:focus,
.toolbar select:focus,
.stack-form input:focus,
.stack-form select:focus,
.stack-form textarea:focus {
  border-color: var(--blue);
  outline: 3px solid #dbe7ff;
}
.toolbar-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.toolbar-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: top;
}
.data-table tr:last-child td {
  border-bottom: 0;
}
.data-table a {
  color: inherit;
}
.data-table .empty-row {
  padding: 26px 10px;
  color: var(--muted);
  text-align: center;
}
.cell-actions {
  text-align: right;
  white-space: nowrap;
}
.cell-actions form {
  display: inline;
  margin: 0;
}
.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.user-cell b {
  display: block;
}
.user-cell small {
  color: var(--muted);
}
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #526278;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}
.badge-active,
.badge-online {
  background: #e3f7ee;
  color: #0f7a57;
}
.badge-expiring,
.badge-upcoming {
  background: #fff3df;
  color: #a7650b;
}
.badge-expired,
.badge-inactive,
.badge-none {
  background: #ffe9ec;
  color: #b22f42;
}
.badge-super {
  background: #e9f1ff;
  color: var(--blue);
}
.badge-cancelled {
  background: #eef0f3;
  color: #6b7686;
  text-decoration: line-through;
}
.stack-form {
  display: grid;
  gap: 14px;
}
.form-section {
  margin: 10px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.stack-form > .form-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.field {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}
.field > span:first-child {
  color: #3d4a5f;
  font-size: 12px;
  font-weight: 700;
}
.field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.field-wide {
  grid-column: 1 / -1;
}
.input-with-button {
  display: flex;
  gap: 6px;
}
.input-with-button input {
  flex: 1;
  min-width: 0;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.check input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  accent-color: var(--blue);
}
.check small {
  color: var(--muted);
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.perm-box {
  display: grid;
  gap: 12px;
}
.perm-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.perm-group {
  display: grid;
  gap: 8px;
  align-content: start;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.perm-group legend {
  padding: 0 4px;
  color: #6681b3;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.inline-form {
  margin-top: 16px;
}
.inline-form > summary {
  list-style: none;
}
.inline-form > summary::-webkit-details-marker {
  display: none;
}
.inline-form[open] > summary {
  margin-bottom: 16px;
}
.inline-actions {
  margin: 14px 0 6px;
}
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.kv-grid > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.kv-grid small {
  color: var(--muted);
  font-size: 12px;
}
.kv-grid b {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}
.subnav-tight {
  margin-bottom: 12px;
}
.failure-details {
  margin-top: 6px;
}
.failure-details summary {
  color: var(--blue);
  font-size: 12px;
  cursor: pointer;
}
.failure-details pre {
  max-height: 260px;
  margin: 8px 0 0;
  padding: 10px;
  overflow: auto;
  border-radius: 6px;
  background: #f5f7fb;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  font-size: 13px;
}

@media (max-width: 700px) {
  .admin-area .panel {
    padding: 16px;
  }
  .toolbar-count {
    width: 100%;
    margin-left: 0;
  }
  .data-table {
    font-size: 12px;
  }
  .data-table th,
  .data-table td {
    padding: 9px 7px;
  }
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-card b {
    font-size: 18px;
  }
}
