/* ============================================================
   amoore Dev v2.1 — Liquid Glass + Dark Theme
   Cross-device / cross-browser hardened
   ============================================================ */

:root {
  --bg: #070b16;
  --bg-elevated: rgba(12, 18, 36, 0.85);
  --bg-card: rgba(16, 24, 48, 0.55);
  --border: rgba(212, 175, 55, 0.22);
  --border-strong: rgba(212, 175, 55, 0.45);
  --gold: #d4af37;
  --gold-soft: #e8c96a;
  --gold-dim: rgba(212, 175, 55, 0.15);
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --text-dim: #5a6478;
  --success: #34d399;
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.15);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --font: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(212, 175, 55, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(80, 100, 180, 0.07), transparent);
  background-attachment: fixed;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* Tap highlight / selection */
button, a, .toggle, .tab-btn, .radio-item {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

::selection {
  background: rgba(212, 175, 55, 0.35);
  color: #fff;
}

/* ---------- Shared glass ---------- */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: rgba(14, 20, 40, 0.95);
  }
}

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, var(--safe-top)) 16px max(16px, var(--safe-bottom));
  position: relative;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 28px;
  position: relative;
  z-index: 2;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--gold-dim), rgba(212, 175, 55, 0.05));
  border: 1px solid var(--border);
  font-size: 22px;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 14px;
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.role-select {
  width: 100%;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px; /* 16px = no iOS zoom on focus */
  line-height: 1.3;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-group select,
.role-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%8b95a8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-group input:focus,
.form-group select:focus,
.role-select:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.form-group input::placeholder {
  color: var(--text-dim);
  opacity: 1;
}

/* Autofill dark (Chrome/Safari) */
.form-group input:-webkit-autofill,
.form-group input:-webkit-autofill:hover,
.form-group input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px #0c1220 inset;
  transition: background-color 9999s ease-in-out 0s;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  min-height: 48px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), opacity var(--transition);
  user-select: none;
  -webkit-user-select: none;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--gold), #b8942a);
  color: #0a0e18;
  margin-top: 8px;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-sm {
  padding: 10px 14px;
  min-height: 40px;
  font-size: 12px;
}

.btn-danger {
  background: linear-gradient(135deg, #e05a5a, #c0392b);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #f07070, #d44);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-dim);
}

.login-error {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--danger-dim);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  display: none;
  word-break: break-word;
}

.login-error.visible {
  display: block;
}

/* ---------- App shell ---------- */
.app {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

.app.visible {
  display: flex;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: max(0px, var(--safe-top)) max(16px, var(--safe-right)) 0 max(16px, var(--safe-left));
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
  background: rgba(7, 11, 22, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  min-height: 56px;
  padding-top: calc(8px + var(--safe-top));
  padding-bottom: 8px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.topbar-brand .mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gold-dim);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--gold);
  flex-shrink: 0;
}

.topbar-brand strong {
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.topbar-brand span {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: -1px;
}

.topbar-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 auto;
  min-width: 0;
}

.tab-btn {
  padding: 10px 14px;
  min-height: 40px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: var(--gold);
  background: var(--gold-dim);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.admin-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--gold-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
}

.admin-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.admin-name {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  padding: 24px 20px calc(48px + var(--safe-bottom));
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ---------- Stats ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 16px 14px;
  text-align: center;
  min-width: 0;
}

.stat-card .stat-value {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--gold);
  line-height: 1.1;
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

.stat-card.danger .stat-value {
  color: var(--danger);
}

/* ---------- Sites grid ---------- */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

.site-card {
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
  min-width: 0;
}

.site-card:hover {
  border-color: var(--border-strong);
}

.site-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.site-info {
  min-width: 0;
  flex: 1;
}

.site-info h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  word-break: break-word;
}

.site-info a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  word-break: break-all;
  display: block;
}

.site-info a:hover {
  color: var(--gold);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.status-pill.online {
  background: rgba(52, 211, 153, 0.12);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.status-pill.offline {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.toggle-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 0;
}

.toggle {
  position: relative;
  width: 52px;
  height: 32px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.toggle.open {
  background: rgba(52, 211, 153, 0.2);
  border-color: rgba(52, 211, 153, 0.4);
}

.toggle.closed {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.35);
}

.toggle.disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

.toggle-knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--transition), background var(--transition);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.toggle.open .toggle-knob {
  transform: translateX(20px);
  background: var(--success);
}

.toggle.closed .toggle-knob {
  transform: translateX(0);
  background: var(--danger);
}

.overlay-meta {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.overlay-meta strong {
  color: var(--text-muted);
  font-weight: 600;
}

/* ---------- Team ---------- */
.team-form {
  padding: 20px;
  margin-bottom: 24px;
}

.team-form h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 14px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.token-row .form-group {
  flex: 1 1 180px;
  margin-bottom: 0;
  min-width: 0;
}

.token-row .btn {
  flex: 0 0 auto;
  margin-top: 0;
  height: 48px;
  padding: 0 16px;
  width: auto;
}

.team-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 16px 18px;
  gap: 14px;
}

.admin-card-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 180px;
}

.admin-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--gold-dim);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--gold);
  flex-shrink: 0;
}

.admin-meta {
  min-width: 0;
}

.admin-meta h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-meta p {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.role-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-badge.super_admin {
  background: var(--gold-dim);
  color: var(--gold);
}

.role-badge.admin {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.role-badge.moderator {
  background: rgba(100, 140, 255, 0.12);
  color: #8ab4ff;
}

.admin-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.role-select {
  min-width: 120px;
  width: auto;
  padding: 10px 32px 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.role-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Logs ---------- */
.logs-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}

.logs-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.logs-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.logs-table tr:last-child td {
  border-bottom: none;
}

.logs-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.action-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.action-pill.open {
  background: rgba(52, 211, 153, 0.12);
  color: var(--success);
}

.action-pill.close {
  background: var(--danger-dim);
  color: var(--danger);
}

.logs-cards {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.log-card {
  padding: 16px 18px;
}

.log-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.log-card-row:last-child {
  margin-bottom: 0;
}

.log-card .meta {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-word;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, var(--safe-top)) 16px max(16px, var(--safe-bottom));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 420px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px;
  margin: auto;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.visible .modal {
  transform: scale(1) translateY(0);
}

.modal h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal > p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  word-break: break-word;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  min-height: 52px;
}

.radio-item:hover {
  border-color: var(--border-strong);
}

.radio-item.selected {
  border-color: var(--gold);
  background: var(--gold-dim);
}

.radio-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-custom {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--transition);
}

.radio-item.selected .radio-custom {
  border-color: var(--gold);
}

.radio-item.selected .radio-custom::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.radio-label {
  font-size: 14px;
  font-weight: 500;
}

.radio-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-actions .btn {
  flex: 1 1 120px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 12px 18px;
  max-width: min(90vw, 420px);
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  z-index: 2000;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
  text-align: center;
  word-break: break-word;
  box-shadow: var(--shadow);
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: rgba(52, 211, 153, 0.35);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.35);
}

/* ---------- Spinner / loading ---------- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   1200 / 900 / 768 / 600 / 400 / landscape
   ============================================================ */

@media (min-width: 900px) {
  .topbar {
    padding-left: 28px;
    padding-right: 28px;
    flex-wrap: nowrap;
  }
  .main {
    padding-left: 28px;
    padding-right: 28px;
  }
}

/* Tablet and below */
@media (max-width: 768px) {
  .topbar-tabs {
    order: 3;
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
  }

  .tab-btn {
    flex: 1 1 auto;
    text-align: center;
    font-size: 12px;
    padding: 10px 8px;
  }

  .logs-table {
    display: none;
  }

  .logs-cards {
    display: flex;
  }

  .admin-name {
    display: none;
  }

  .admin-badge span:not(.dot) {
    display: none;
  }

  .admin-badge {
    padding: 8px;
  }

  .token-row .btn {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .topbar-brand span {
    display: none;
  }

  .login-card {
    padding: 28px 20px;
  }

  .stats-row {
    gap: 8px;
  }

  .stat-card {
    padding: 14px 8px;
  }

  .stat-card .stat-label {
    font-size: 10px;
  }
}

/* Phones 320–400 */
@media (max-width: 400px) {
  .stats-row {
    grid-template-columns: 1fr;
  }

  .site-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .admin-card-actions {
    width: 100%;
  }

  .role-select {
    flex: 1;
    min-width: 0;
  }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
  .login-screen {
    align-items: flex-start;
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .login-card {
    margin: 12px 0;
  }

  .login-logo {
    margin-bottom: 16px;
  }

  .login-logo .mark {
    width: 40px;
    height: 40px;
    font-size: 16px;
    margin-bottom: 8px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print (hide panel chrome) */
@media print {
  .topbar, .toast, .modal-overlay { display: none !important; }
  body { background: #fff; color: #000; }
}

/* ============================================================
   v4.0 Mission Control extras
   ============================================================ */

.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.burger span {
  display: block;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.widgets-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.widget {
  padding: 18px 20px;
  min-width: 0;
}
.widget-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.widget-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  word-break: break-word;
}
.bot-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}
.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.4);
}
.mini-audit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
.mini-audit-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.mini-audit-row .meta {
  color: var(--text-dim);
  font-size: 11px;
}

.dropzone {
  padding: 36px 20px;
  text-align: center;
  border-style: dashed;
  margin-bottom: 20px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.dropzone.drag {
  border-color: var(--gold);
  background: var(--gold-dim);
}
.dropzone .linkish {
  color: var(--gold);
  cursor: pointer;
  text-decoration: underline;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 14px;
}
.media-item {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.media-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  background: rgba(0,0,0,0.3);
}

textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

@media (max-width: 900px) {
  .burger { display: inline-flex; }
  .topbar-tabs {
    display: none;
    order: 3;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 8px;
  }
  .topbar-tabs.open {
    display: flex;
  }
  .topbar-tabs .tab-btn {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
  }
}
