.admin-page {
  position: relative;
  z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 4rem 1.75rem 5rem;
  min-height: 100vh;
}

/* --- login --- */

.login-screen {
  min-height: calc(100vh - 8rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.6rem;
  padding: 2.4rem 2rem 2.2rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: var(--shadow-hover);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 680;
  letter-spacing: -0.01em;
  margin: 0.1rem 0 0;
  color: var(--ink);
}

.login-sub {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0 0 0.6rem;
  line-height: 1.45;
}

.login-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.06);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
  text-align: center;
  letter-spacing: 0.1em;
}

.login-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.login-error {
  font-size: 0.82rem;
  color: #ff8a8a;
  margin: -0.2rem 0 0;
}

.back-link {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--ink-faint);
  text-decoration: none;
}

.back-link:hover { color: var(--accent); }

/* --- buttons --- */

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 0.7rem 1.3rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--spring), background 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  width: 100%;
  background: linear-gradient(160deg, var(--accent), #5b3fe0);
  color: white;
  box-shadow: 0 10px 24px -10px rgba(139,123,255,0.55);
}

.btn-ghost {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--ink);
}

.btn-ghost:hover { background: var(--glass-hover); }

/* --- admin screen --- */

.admin-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
  flex-wrap: wrap;
}

.admin-title {
  font-size: 1.9rem;
  font-weight: 680;
  letter-spacing: -0.01em;
  margin: 0.2rem 0 0;
  color: var(--ink);
}

.admin-header-actions {
  display: flex;
  gap: 0.6rem;
}

.save-status {
  font-size: 0.85rem;
  font-weight: 600;
  color: #7ee7a8;
  margin: -0.8rem 0 1.2rem;
}

.save-status.is-error {
  color: #ff8a8a;
}

/* --- quadrant boxes --- */

.quadrant-boxes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.quadrant-box {
  padding: 1.2rem 1.2rem 1.4rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}

.quadrant-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.quadrant-box-title-field {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.005em;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.2rem 0.4rem;
  font-family: inherit;
}

.quadrant-box-title-field:hover,
.quadrant-box-title-field:focus-visible {
  border-color: var(--glass-border);
  background: rgba(255,255,255,0.05);
  outline: none;
}

.quadrant-box-count {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--ink-faint);
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  flex-shrink: 0;
}

.quadrant-box-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.qb-icon-btn {
  appearance: none;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  color: var(--ink);
  border-radius: 8px;
  width: 26px;
  height: 26px;
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.qb-icon-btn:hover { background: var(--glass-hover); }
.qb-icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.qb-icon-btn.qb-delete:hover { background: rgba(255,90,90,0.18); border-color: rgba(255,90,90,0.4); }

.add-section-btn {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px dashed var(--glass-border);
  color: var(--ink);
  border-radius: 14px;
  padding: 0.7rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: background 0.15s ease;
}

.add-section-btn:hover { background: var(--glass-hover); }

.quadrant-box-link-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.9rem;
}

.quadrant-box-link-field input {
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.82rem;
}

.quadrant-box-link-field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.quadrant-box-image-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.quadrant-box-image-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.quadrant-box-image-row input[type="file"] {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.quadrant-box-image-preview {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.quadrant-box-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.quadrant-box-empty {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin: 0.3rem 0;
}

.site-row {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.site-row:hover,
.site-row:focus-visible {
  background: var(--glass-hover);
  border-color: var(--glass-border);
}

.site-row-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.site-row-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-row-fallback {
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
}

.site-row-name {
  font-size: 0.86rem;
  font-weight: 550;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-site-btn {
  width: 100%;
  background: linear-gradient(160deg, var(--accent), #5b3fe0);
  border: none;
  color: white;
  border-radius: 14px;
  padding: 0.85rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(139,123,255,0.55);
  transition: transform 0.15s var(--spring);
}

.add-site-btn:active {
  transform: scale(0.98);
}

/* --- modal --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(6,6,14,0.6);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay:not([hidden]) {
  display: flex;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.6rem;
  background: var(--ground-2);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  box-shadow: var(--shadow-hover);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 680;
  color: var(--ink);
  margin: 0;
}

.modal-close {
  appearance: none;
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--ink-faint);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
}

.modal-close:hover {
  background: rgba(255,90,90,0.18);
  color: #ff8a8a;
}

.modal-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 0.2rem;
}

.tool-edit-icon {
  width: 56px;
  height: 56px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(160deg, #8b7bff, #5b3fe0);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}

.tool-edit-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tool-edit-fallback {
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.field input[type="text"],
.field input[type="url"],
.modal-select {
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
}

.modal-select {
  width: 100%;
  cursor: pointer;
}

.field input:focus-visible,
.modal-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.field-color {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

.field-color .field-label {
  margin-right: 0.2rem;
}

.field-color input[type="color"] {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

.field-logo input[type="file"] {
  font-size: 0.78rem;
  color: var(--ink-soft);
  max-width: 180px;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.btn-danger {
  background: rgba(255,90,90,0.14);
  color: #ff8a8a;
  border: 1px solid rgba(255,90,90,0.3);
}

.btn-danger:hover {
  background: rgba(255,90,90,0.22);
}

@media (max-width: 560px) {
  .quadrant-boxes {
    grid-template-columns: 1fr;
  }
}
