:root {
  --bg: #0c0f14;
  --surface: #12161e;
  --surface2: #181e28;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaef;
  --muted: #8b93a3;
  --accent: #5b8cff;
  --accent-dim: #3d5fb8;
  --danger: #e85d5d;
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #1a2233 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.5;
}

code {
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.9em;
  background: var(--surface2);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.file-protocol-banner {
  background: #3d2525;
  color: #f5e8e8;
  padding: 0.85rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.45;
  border-bottom: 1px solid rgba(255, 80, 80, 0.35);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 15, 20, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.logo-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.link-quiet {
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.link-quiet:hover {
  color: var(--text);
  text-decoration: none;
}

.btn-link-reset {
  cursor: pointer;
}

.main-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.main-wrap.main-wrap--wide {
  max-width: 1040px;
}

.admin-dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: linear-gradient(145deg, var(--surface2) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.stat-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text);
}

.stat-card-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 0.35rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .admin-grid .admin-span-2 {
    grid-column: 1 / -1;
  }
}

.panel--accent {
  border-color: rgba(91, 140, 255, 0.22);
  box-shadow: var(--shadow), 0 0 0 1px rgba(91, 140, 255, 0.06) inset;
}

.panel-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.panel-head-row .panel-head {
  margin-bottom: 0;
}

.badge-soft {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: rgba(91, 140, 255, 0.12);
  border: 1px solid rgba(91, 140, 255, 0.25);
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
}

.tenant-card {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}

.tenant-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: #1a2130;
}

.tenant-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-dim), #2a5080);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
}

.tenant-body {
  flex: 1;
  min-width: 0;
}

.tenant-name {
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 0.2rem;
}

.tenant-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
  word-break: break-all;
}

.tenant-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
}

.modal-card--wide {
  max-width: 480px;
}

.modal-sub {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

#modal-edit-check:checked ~ #modal-edit-tenant {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.hero {
  margin-bottom: 2rem;
}

.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.hero h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  margin: 0 0 0.75rem;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.login-card {
  max-width: 400px;
  margin: 2rem auto 0;
}

.panel-head {
  margin-bottom: 1.25rem;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.panel-title-sm {
  font-size: 1.05rem;
}

.panel-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field span {
  font-size: 0.85rem;
  color: var(--muted);
}

.field input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
.field input:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border);
}
.btn:hover {
  background: #1e2633;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dim) 100%);
  border-color: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-block {
  width: 100%;
}

.btn-small {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.btn-danger {
  background: rgba(232, 93, 93, 0.15);
  border-color: rgba(232, 93, 93, 0.35);
  color: #ffb4b4;
}
.btn-danger:hover {
  background: rgba(232, 93, 93, 0.25);
}

.section-divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone-active,
.upload-zone:hover {
  border-color: var(--accent-dim);
  background: rgba(91, 140, 255, 0.06);
}

.upload-icon {
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.upload-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.status {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

.result-card {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.result-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.result-url {
  display: block;
  word-break: break-all;
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.result-preview img {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius-sm);
  display: block;
  margin: 0 auto;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.history-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.history-url {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  word-break: break-all;
  color: var(--accent);
}

.history-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.tenant-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tenant-item {
  padding: 0.85rem;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.tenant-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tenant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.muted {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#settings-check:checked ~ .modal {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  cursor: pointer;
}

.modal-card {
  position: relative;
  z-index: 1;
  max-width: 420px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.modal-lead {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.55;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.85rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
  pointer-events: auto;
}

.toast-ok {
  border-color: rgba(80, 180, 120, 0.4);
}

.toast-err {
  border-color: rgba(232, 93, 93, 0.4);
}

.toast-out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s, transform 0.25s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 520px) {
  .main-wrap {
    padding-top: 1.25rem;
  }

  .tenant-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
