:root {
  --bg-dark:       #0d0d0d;
  --bg-surface:    rgba(20, 20, 28, 0.85);
  --bg-surface-2:  rgba(30, 30, 42, 0.75);
  --bg-hover:      rgba(55, 55, 80, 0.6);

  --border-base:   rgba(80, 80, 120, 0.3);
  --border-accent:  hsl(200, 80%, 50%);

  --text-primary:  #e4e4ed;
  --text-secondary: #8888a0;
  --text-muted:    #555568;

  --accent:        hsl(200, 80%, 50%);
  --accent-hover:  hsl(200, 80%, 40%);
  --accent-glow:   hsla(200, 90%, 55%, 0.25);

  --danger:        #e05555;
  --danger-hover:  #c04040;
  --success:       #4ec89f;
  --warning:       #e8a838;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;

  --font: 'Madimi', sans-serif;
}

/* --- Reset & Base --- */
@font-face {
  font-family: 'Madimi';
  src: url('/fonts/MadimiOne-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-dark);
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* --- Background iframe --- */
#backgroundFrame {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  border: none;
}

/* --- Hamburger menu --- */
.menu-toggle {
  position: fixed;
  top: 14px; left: 14px;
  cursor: pointer;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.menu-toggle span {
  display: block;
  width: 26px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 200px;
  height: 100%;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-base);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  padding: 60px 12px 20px;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar a {
  display: block;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13px;
  letter-spacing: 0.5px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.sidebar a:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.menu-toggle.active ~ .sidebar { transform: translateX(0); }
.menu-toggle.active ~ .content { margin-left: 212px; }

/* --- Content area --- */
.content {
  margin-left: 40px;
  padding: 24px;
  position: relative;
  z-index: 1;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* --- Animated title --- */
.animated-text {
  font-size: 24px;
  font-weight: bold;
  color: var(--accent);
  animation: titleGlow 4s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  0%   { color: hsl(180, 70%, 55%); text-shadow: 0 0 8px hsla(180, 80%, 50%, 0.3); }
  50%  { color: hsl(210, 70%, 55%); text-shadow: 0 0 8px hsla(210, 80%, 50%, 0.3); }
  100% { color: hsl(240, 60%, 60%); text-shadow: 0 0 8px hsla(240, 70%, 55%, 0.3); }
}

/* --- Border glow animation (shared) --- */
@keyframes borderGlow {
  0%   { border-color: hsl(180, 60%, 40%); }
  50%  { border-color: hsl(210, 60%, 45%); }
  100% { border-color: hsl(240, 50%, 45%); }
}

/* --- Cards & panels --- */
.panel {
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
}

.panel-glow {
  animation: borderGlow 4s ease-in-out infinite alternate;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text-primary);
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  background: #141420;
  position: sticky;
  top: 0;
  z-index: 2;
}

tr:hover td {
  background: var(--bg-hover);
}

/* --- Buttons --- */
.btn {
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  color: #fff;
}

.btn-primary {
  background: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 12px var(--accent-glow);
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* --- Inputs --- */
input[type="text"],
input[type="password"],
select {
  font-family: var(--font);
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  background: rgba(15, 15, 25, 0.7);
  color: var(--text-primary);
  transition: border-color 0.2s ease;
  outline: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* --- Links --- */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--text-primary);
}

/* --- Notification toast --- */
#notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 2000;
}

/* --- Popup / Modal --- */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1200;
}

.popup {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 1300;
  max-height: 70vh;
  overflow-y: auto;
  width: min(90vw, 700px);
  color: var(--text-primary);
}

.popup h2 { margin-top: 0; }

/* --- Error --- */
.error {
  color: var(--danger);
  text-align: center;
  margin-top: 8px;
  font-size: 14px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .content { margin-left: 16px; padding: 16px; }
  .menu-toggle.active ~ .content { margin-left: 16px; }
  .sidebar { width: 100%; }
  .popup { width: 95vw; }
}
