:root {
  color-scheme: dark;
  --bg: #050913;
  --bg-soft: #0b1120;
  --panel: #101b33;
  --panel-soft: rgba(16, 27, 51, 0.75);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f8fafc;
  --text-muted: #98a2c7;
  --text-soft: #9ca3c7;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-bg: rgba(96, 165, 250, 0.16);
  --danger: #f87171;
  --success: #34d399;
  --warning: #facc15;
  --shadow: 0 20px 45px rgba(8, 15, 35, 0.45);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, rgba(96, 165, 250, 0.08), transparent 55%), var(--bg);
  min-height: 100vh;
  color: var(--text);
  font-family: inherit;
  line-height: 1.6;
}

main {
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.app-root {
  width: min(1180px, 90vw);
  margin: 0 auto;
  padding: 4rem 0 6rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.status-banner {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--danger);
  padding: 0.85rem 1.1rem;
  border-radius: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-banner .spinner {
  border-color: rgba(248, 113, 113, 0.4);
  border-top-color: transparent;
}

.toast-root {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
}

.toast {
  min-width: 240px;
  max-width: 320px;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  animation: toast-in 0.3s ease forwards;
}

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

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

.toast-dismiss {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-shell {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}

.sidebar {
  width: 240px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.75rem 1.5rem;
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  box-shadow: var(--shadow);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  color: var(--text-soft);
  transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.sidebar-link:hover {
  background: rgba(96, 165, 250, 0.12);
  color: var(--text);
  transform: translateX(3px);
}

.sidebar-link.active {
  background: var(--accent-bg);
  color: var(--text);
  font-weight: 600;
}

.main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.app-header {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.app-header .title-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.app-header small {
  color: var(--text-soft);
  font-size: 0.85rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.75rem;
  color: var(--text-soft);
}

.view-container {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2rem;
  min-height: 400px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.view {
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.view-container h1 {
  margin-top: 0;
  margin-bottom: 1.6rem;
  font-size: 2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}

.card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card h2 {
  margin: 0;
  font-size: 1.1rem;
}

.card p {
  margin: 0;
  color: var(--text-soft);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-size: 0.95rem;
  color: var(--text);
  background: rgba(96, 165, 250, 0.2);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(96, 165, 250, 0.2);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.85), rgba(59, 130, 246, 0.92));
  border-color: rgba(96, 165, 250, 0.4);
}

.btn-ghost {
  background: rgba(148, 163, 184, 0.15);
  border-color: rgba(148, 163, 184, 0.2);
}

.btn-outline {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.3);
  color: var(--text);
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
}

.btn-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  box-shadow: none;
  transform: none;
}

.input, .select, .textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.65);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.data-table thead {
  background: rgba(15, 23, 42, 0.9);
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 0.9rem;
}

.data-table tbody tr:hover {
  background: rgba(96, 165, 250, 0.05);
}

.data-table tbody tr.error {
  background: rgba(248, 113, 113, 0.12);
}

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

.empty-state {
  padding: 1.5rem;
  text-align: center;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px dashed rgba(148, 163, 184, 0.35);
  color: var(--text-soft);
}

.hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 8vw, 4rem);
  margin: 0;
}

.hero p {
  margin: 0;
  color: var(--text-soft);
  font-size: 1.1rem;
}

.feature-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.feature-card {
  padding: 1.4rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
  text-align: left;
}

.feature-card h3 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
}

.banner-info {
  background: rgba(96, 165, 250, 0.14);
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: var(--accent-strong);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
}

.loading-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 3rem 1rem;
  color: var(--text-soft);
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(148, 163, 184, 0.35);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.error-block {
  padding: 2rem;
  border-radius: 14px;
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
}

.faq {
  margin-top: 2.5rem;
  padding: 1.8rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.45);
}

.faq h2 {
  margin-top: 0;
  margin-bottom: 0.8rem;
}

.site-footer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-soft);
  padding-bottom: 3rem;
}

.site-footer nav {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.auth-card {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0;
  font-size: 1.6rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.toast-root:empty {
  display: none;
}

.banner-subtle {
  font-size: 0.85rem;
  color: var(--text-soft);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-soft);
}

@media (max-width: 1080px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: auto;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .app-root {
    width: min(96vw, 640px);
    padding: 2.5rem 0 4rem;
  }

  .app-header,
  .view-container,
  .sidebar,
  .card,
  .auth-card {
    padding: 1.25rem;
  }

  .view-container h1 {
    font-size: 1.6rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}

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