/**
 * CONTROL panel — hi-tech dark theme
 * Accents: neon green #00FF88, purple #AA66FF
 * No blue / office-gray palette
 */

:root {
  --bg: #0B0B0F;
  --bg-elev: #12121A;
  --card: #1A1A24;
  --card-2: #22222E;
  --line: rgba(0, 255, 136, 0.12);
  --line-strong: rgba(0, 255, 136, 0.28);
  --line-muted: rgba(170, 102, 255, 0.15);
  --ink: #F0F0F5;
  --muted: #A0A0B8;
  --dim: #6A6A80;
  --brand: #00FF88;
  --brand-dim: #00CC6A;
  --brand-soft: rgba(0, 255, 136, 0.12);
  --purple: #AA66FF;
  --purple-soft: rgba(170, 102, 255, 0.14);
  --gold: #E8C547;
  --danger: #FF4466;
  --danger-soft: rgba(255, 68, 102, 0.14);
  --ok: #00FF88;
  --warn: #E8C547;
  --radius: 0.35rem;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 0 24px rgba(0, 255, 136, 0.15);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --transition: 0.2s var(--ease);
  --cut: 8px;
  --font-mono: "JetBrains Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

html { color-scheme: dark; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 15% 10%, rgba(0, 255, 136, 0.05), transparent 50%),
    radial-gradient(ellipse 60% 45% at 90% 90%, rgba(170, 102, 255, 0.05), transparent 50%),
    var(--bg);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.25;
  background-image:
    linear-gradient(rgba(0, 255, 136, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(170, 102, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 75% 70% at 50% 40%, black 15%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 40%, black 15%, transparent 75%);
}

.cut, .ga-card, .modal-panel, .stat-card {
  clip-path: polygon(
    var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)
  );
}

#sidebar.is-open {
  transform: translateX(0) !important;
  box-shadow: 0 0 40px rgba(0, 255, 136, 0.1), var(--shadow);
}
#sidebarBackdrop.is-open {
  opacity: 1 !important;
  pointer-events: auto !important;
}
#notifPanel.is-open, #notifPanel.show {
  display: block !important;
  animation: fadeScale 0.22s var(--ease) both;
}

/* ─── Modals (must work with app.js) ─── */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s var(--ease), visibility 0.22s;
}
.modal-root.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 8, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}
.modal-panel {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: min(90vh, 720px);
  overflow: auto;
  border-radius: 0;
  background: var(--card-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), 0 0 40px rgba(0, 255, 136, 0.08);
  transform: scale(0.96) translateY(6px);
  transition: transform 0.28s var(--ease);
  z-index: 1;
}
.modal-root.is-open .modal-panel {
  transform: scale(1) translateY(0);
}
.modal-panel.modal-lg { max-width: 640px; }
.modal-panel.modal-xl { max-width: 820px; }
.modal-panel.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.15rem 1.25rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-family: var(--font-mono);
}
.modal-title i { color: var(--brand); }
.modal-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 0.2rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.modal-close {
  width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(255, 68, 102, 0.3);
}
.modal-body { padding: 1.1rem 1.25rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.25rem 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
body.modal-open, body.is-locked { overflow: hidden; }

/* Buttons */
.btn, .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  color: #04140A;
  border: none;
  cursor: pointer;
  background: var(--brand);
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.25);
  transition: background var(--transition), box-shadow var(--transition), transform 0.15s;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}
.btn:hover, .btn-primary:hover {
  background: #33FFA0;
  box-shadow: 0 0 28px rgba(0, 255, 136, 0.45);
}
.btn:active, .btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-ghost:hover {
  background: var(--brand-soft);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  color: #fff;
  background: linear-gradient(180deg, #6B1528 0%, #3D0A15 100%);
  border: 1px solid rgba(255, 68, 102, 0.4);
  cursor: pointer;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}
.btn-danger:hover {
  background: linear-gradient(180deg, #8B1E35 0%, #6B1528 100%);
  box-shadow: 0 0 20px rgba(255, 68, 102, 0.25);
}
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.7rem; }

.btn-purple {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  color: #0B0B0F;
  background: var(--purple);
  border: none;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(170, 102, 255, 0.3);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

/* Alerts */
.page-alert, .alert {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.85rem 1.05rem;
  font-size: 0.8125rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  font-family: var(--font-mono);
}
.page-alert-ok, .alert-ok {
  background: var(--brand-soft);
  border-color: rgba(0, 255, 136, 0.3);
  color: #66FFB0;
}
.page-alert-err, .alert-err {
  background: var(--danger-soft);
  border-color: rgba(255, 68, 102, 0.35);
  color: #FF8AA0;
}
.page-alert-info, .alert-info {
  background: var(--purple-soft);
  border-color: rgba(170, 102, 255, 0.3);
  color: #C9A0FF;
}

/* Toasts */
.ga-toast-wrap {
  position: fixed;
  bottom: 1.35rem;
  right: 1.35rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 2rem));
}
.ga-toast {
  pointer-events: auto;
  padding: 0.8rem 1.1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--card-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: toastIn 0.35s var(--ease) both;
  color: var(--ink);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeScale {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}
.ga-toast-ok  { border-color: rgba(0, 255, 136, 0.4); color: #66FFB0; }
.ga-toast-err { border-color: rgba(255, 68, 102, 0.4); color: #FF8AA0; }
.ga-toast-info{ border-color: rgba(170, 102, 255, 0.4); color: #C9A0FF; }

.ga-tabs { display: flex; gap: 0.35rem; overflow-x: auto; margin-bottom: 1.25rem; scrollbar-width: none; }
.ga-tabs::-webkit-scrollbar { display: none; }
.ga-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.ga-tab:hover { background: var(--brand-soft); color: var(--ink); }
.ga-tab.is-active {
  color: #04140A;
  border-color: transparent;
  background: var(--brand);
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.25);
}

.ga-card, .stat-card {
  background: linear-gradient(165deg, rgba(34, 34, 46, 0.95), rgba(26, 26, 36, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0;
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.ga-card:hover, .stat-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow), var(--shadow-glow);
}

.ga-fade-up { animation: fadeUp 0.4s var(--ease) both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.console-log {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.55;
}
.console-log .log-info { color: var(--muted); }
.console-log .log-warn { color: var(--warn); }
.console-log .log-error { color: #FF8AA0; text-shadow: 0 0 8px rgba(255, 136, 160, 0.25); }
.console-log .log-ok { color: var(--brand); }

.font-mono-stat {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

input:not([type="checkbox"]):not([type="radio"]),
select, textarea {
  color-scheme: dark;
  background: var(--bg-elev) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 0.25rem !important;
  color: var(--ink) !important;
  font-family: var(--font-mono) !important;
  transition: border-color var(--transition), box-shadow var(--transition) !important;
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus, textarea:focus {
  border-color: rgba(0, 255, 136, 0.5) !important;
  box-shadow: 0 0 0 3px var(--brand-soft) !important;
  outline: none !important;
}
input::placeholder, textarea::placeholder { color: var(--dim) !important; }

* { scrollbar-width: thin; scrollbar-color: rgba(0, 255, 136, 0.25) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: rgba(0, 255, 136, 0.2); border-radius: 99px; }

::selection { background: rgba(0, 255, 136, 0.35); color: #fff; }

.page-hero { margin-bottom: 1.25rem; }
.page-hero h1 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}
.page-hero p { margin: 0.35rem 0 0; font-size: 0.75rem; color: var(--muted); }

@media (min-width: 768px) {
  #sidebar { transform: none !important; }
  #sidebarBackdrop { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

:root { --bg2: var(--card); --border: rgba(255,255,255,0.1); }
