/* Admin panel (/admin/). Uses the tokens and login styles of styles.css. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

input,
select {
  font: inherit;
  color: inherit;
}

code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-muted);
  font-size: 0.9em;
}

/* ---------- Notices (phone, access refused) ---------- */

.admin-notice {
  align-items: center;
  text-align: center;
}

.admin-notice .welcome__mark {
  width: 56px;
  height: 56px;
}

.admin-notice .admin-button {
  align-self: stretch;
}

/* ---------- Buttons and fields ---------- */

.admin-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
}

.admin-button:hover:not(:disabled) {
  background: var(--brand-strong);
}

.admin-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.admin-button--ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text);
}

.admin-button--ghost:hover:not(:disabled) {
  background: var(--surface-muted);
}

.admin-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
}

.admin-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.admin-field input,
.admin-setting__input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 14px;
  font-weight: 400;
}

.admin-field input:focus,
.admin-setting__input:focus {
  border-color: var(--focus);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.admin-setting__input.is-invalid {
  border-color: var(--error-text);
}

.admin-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.admin-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.admin-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}

.admin-badge--brand {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.admin-badge--warn {
  background: #3a2f17;
  color: #f0c674;
}

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

.admin-status:empty {
  display: none;
}

.admin-status.is-error,
.admin-result.is-error {
  color: var(--error-text);
}

.admin-status.is-success,
.admin-result.is-success {
  color: var(--brand-strong);
}

/* ---------- Layout ---------- */

.admin-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
}

.admin-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.admin-header__brand img {
  width: 28px;
  height: 28px;
}

.admin-header__brand strong {
  color: var(--brand);
}

.admin-header__title {
  padding-left: 20px;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
}

.admin-header__user {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 13px;
}

.admin-tabs {
  display: flex;
  align-self: stretch;
  gap: 4px;
}

.admin-tabs__tab {
  padding: 18px 14px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font-weight: 600;
}

.admin-tabs__tab:hover {
  color: var(--text);
}

.admin-tabs__tab[aria-selected="true"] {
  border-bottom-color: var(--brand);
  color: var(--text);
}

.admin-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 28px 0;
}

.admin-panel__intro {
  margin-bottom: 20px;
}

.admin-panel__intro h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.admin-panel__intro p {
  margin: 0;
  color: var(--text-muted);
}

.admin-card {
  margin: 0 0 20px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.admin-card--flush {
  padding: 0;
  overflow: hidden;
}

.admin-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

/* ---------- Settings ---------- */

.admin-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 28px;
  min-width: 0;
}

.admin-group legend {
  float: left;
  grid-column: 1 / -1;
  width: 100%;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
}

.admin-setting {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.admin-setting__label {
  font-size: 13px;
  font-weight: 600;
}

.admin-setting__help,
.admin-setting__error {
  margin: 0;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.admin-setting__help:empty {
  display: none;
}

.admin-setting__error {
  color: var(--error-text);
}

.admin-savebar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: 0 -28px;
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.admin-savebar .admin-status {
  margin-right: auto;
}

/* ---------- Users ---------- */

.admin-adduser {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  align-items: end;
  gap: 12px 16px;
}

.admin-adduser h3,
.admin-adduser .admin-status {
  grid-column: 1 / -1;
}

.admin-adduser .admin-check {
  padding-bottom: 9px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table__name {
  font-weight: 600;
}

.admin-table__actions {
  text-align: right;
  white-space: nowrap;
}

.admin-action {
  margin-left: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  font-size: 12.5px;
}

.admin-action:hover:not(:disabled) {
  background: var(--surface-muted);
}

.admin-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.admin-action--danger {
  color: var(--error-text);
}

.admin-action--danger:hover:not(:disabled) {
  border-color: var(--error-border);
  background: var(--error-bg);
}

.admin-usage {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-usage__count {
  min-width: 56px;
  font-variant-numeric: tabular-nums;
}

.admin-usage__bar {
  width: 90px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.admin-usage__bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.admin-usage__bar.is-full > span {
  background: var(--error-text);
}

.admin-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 48px;
}

.admin-summary__item {
  display: grid;
  gap: 6px;
}

.admin-summary__label {
  color: var(--text-muted);
  font-size: 13px;
}

.admin-summary__value {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.admin-usage--large .admin-usage__count {
  font-size: 18px;
  font-weight: 600;
}

.admin-usage--large .admin-usage__bar {
  width: 220px;
  height: 8px;
}

.admin-adduser__full {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--error-text);
}

/* ---------- Tests ---------- */

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

.admin-test {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
}

.admin-test p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.admin-test .admin-result {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* ---------- Password dialog ---------- */

.admin-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.admin-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.admin-dialog form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-dialog h3 {
  margin: 0;
  font-size: 16px;
}

.admin-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
