.admin-body { background: var(--bg); }
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 240px; flex-shrink: 0; background: var(--navy-900); color: #cbd5e1;
  padding: 20px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-brand { font-weight: 800; color: #fff; padding: 0 20px 16px; font-size: 1.05rem; }
.admin-brand span { color: var(--teal-500); font-weight: 600; }
.admin-brand-center { text-align: center; padding-bottom: 20px; display: flex; justify-content: center; }
/* No height/width cap on purpose — see the matching comment in style.css. */
.admin-brand-logo { display: block; max-width: 100%; }
.admin-nav { display: flex; flex-direction: column; }
.admin-nav a {
  color: #cbd5e1; padding: 10px 20px; font-size: 0.9rem; font-weight: 500;
}
.admin-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.admin-nav-heading {
  color: #64748b; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 16px 20px 6px; font-weight: 700;
}
.admin-logout-form { padding: 8px 20px 0; }
.admin-nav-logout {
  background: none; border: 1px solid rgba(255,255,255,0.2); color: #cbd5e1;
  padding: 8px 12px; border-radius: 6px; cursor: pointer; width: 100%; font-size: 0.85rem;
}
.admin-nav-logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 20px 32px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.admin-topbar h1 { margin: 0; font-size: 1.4rem; }
.admin-content { padding: 28px 32px 64px; max-width: 1180px; }

/* ============ Login ============ */
.admin-login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--navy-900); font-family: var(--font); margin: 0;
}
.admin-login-card { width: 100%; max-width: 360px; padding: 32px; }

/* ============ Alerts / stats ============ */
.admin-alert {
  background: #eef2ff; border: 1px solid #c7d2fe; color: var(--navy-800);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; font-size: 0.9rem;
}
.admin-alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.stat-row { display: flex; gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--navy-900); }
.stat-label { color: var(--text-muted); font-size: 0.85rem; }

.admin-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow-sm);
}
.admin-panel-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }

.quick-links { display: flex; flex-wrap: wrap; gap: 12px; }
.quick-link {
  background: #eef2f8; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 16px; font-weight: 600; font-size: 0.9rem;
}
.quick-link:hover { background: #e2e8f0; text-decoration: none; }

/* ============ Tables ============ */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.9rem; }
.admin-table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.admin-table tbody tr:hover { background: #f8fafc; }

.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.status-new { background: #eef2ff; color: #3730a3; }
.status-emailed { background: #ecfdf3; color: var(--success); }
.status-email_failed { background: #fef3f2; color: var(--danger); }

.pagination { display: flex; gap: 6px; margin-top: 16px; }
.pagination a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; }
.pagination a.active { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }

.order-detail-totals { text-align: right; padding-top: 12px; }

/* ============ Forms ============ */
.admin-form.card { margin-bottom: 24px; }
.admin-form h2 { margin-top: 0; }
.admin-form h2:not(:first-child) { margin-top: 1.4em; }
.markdown-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; }

.logo-preview {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; display: inline-flex; margin-bottom: 12px;
}
.logo-preview img { display: block; max-height: 80px; max-width: 320px; object-fit: contain; }

.field-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field-inline label { margin-bottom: 0; white-space: nowrap; }

.location-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.location-photo-card {
  border: 1px solid var(--border); border-radius: 8px; padding: 14px; background: #fafcff;
}
.location-photo-card h3 { margin: 0 0 10px; font-size: 0.95rem; }
.location-photo-preview {
  display: block; width: 100%; height: 140px; object-fit: cover; border-radius: 6px; margin-bottom: 10px;
}
.location-photo-placeholder {
  height: 140px; border-radius: 6px; margin-bottom: 10px; background: #eef2f8;
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.85rem;
}
.location-photo-form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.location-photo-form input[type="file"] { font-size: 0.8rem; }
.field-inline input { width: auto; min-width: 240px; flex: 1; }

/* ============ Editable grid (categories / terms / locations / options) ============ */
.editable-grid { display: grid; row-gap: 6px; column-gap: 10px; align-items: center; margin-bottom: 24px; }
.grid-categories { grid-template-columns: 1.2fr 1fr 1.6fr 70px 70px 70px 70px; }
.grid-terms { grid-template-columns: 1fr 100px 90px 80px 80px 80px; }
.grid-locations { grid-template-columns: 1fr 1fr 1.6fr 1fr 70px 70px 70px 70px; }
.grid-options { grid-template-columns: 1.1fr 1.1fr 1.1fr 100px 100px 80px 70px 70px 80px 80px; min-width: 980px; }
.editable-grid form { display: contents; }
.grid-head { font-weight: 700; font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.grid-row input, .grid-row select {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; font-family: inherit;
}
.grid-row .num-input { width: 100%; }
.checkbox-cell { display: flex; justify-content: center; }
.checkbox-cell input { width: auto; }
.grid-row-delete { justify-self: start; }

/* ============ Logs ============ */
.log-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.log-tabs { display: flex; gap: 4px; }
.log-tab { padding: 6px 14px; border-radius: 6px; font-size: 0.85rem; color: var(--text-muted); border: 1px solid transparent; }
.log-tab:hover { background: #eef2f8; text-decoration: none; }
.log-tab.active { background: var(--navy-800); color: #fff; }
.log-lines-form { display: flex; align-items: center; gap: 8px; }
.log-lines-form select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; }
.log-viewer {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre;
  overflow: auto;
  max-height: 70vh;
}
.log-error { color: var(--danger); }
.log-viewer-compact { max-height: 320px; font-size: 0.78rem; }

/* ============ Log Analyzer ============ */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.flag-heading { font-size: 0.9rem; margin: 20px 0 8px; }
.flag-heading:first-child { margin-top: 0; }
.analyzer-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.bar-chart { display: flex; flex-direction: column; gap: 4px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 60px; align-items: center; gap: 10px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: #eef2f8; border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { background: var(--navy-800); height: 100%; border-radius: 4px; }
.bar-count { text-align: right; }

/* ============ Blocked IPs ============ */
.inline-form { display: flex; gap: 10px; align-items: center; }
.inline-form input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; font-family: inherit;
}
.ip-input { width: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.reason-input { flex: 1; min-width: 200px; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-actions form { display: inline; }
.block-btn-cell form { display: inline; }

@media (max-width: 900px) {
  .admin-sidebar { display: none; }
  .admin-content { padding: 20px; }
  .analyzer-columns { grid-template-columns: 1fr; }
}
