:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-strong: #f0f4ff;
  --text: #222b38;
  --text-muted: #5f6b7a;
  --primary: #1f56ff;
  --accent: #f1c40f;
  --border: #dce4f2;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
}

body {
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 2rem;
  background: #0f1b3a;
  color: #fff;
  flex-wrap: wrap;
}

.brand {
  font-size: 1.3rem;
  font-weight: 700;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.nav-links a {
  color: #dbe6ff;
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.container {
  max-width: 1200px;
  width: min(1200px, calc(100% - 2rem));
  margin: 2rem auto;
}

.container-main {
  max-width: 1200px;
  width: min(1200px, calc(100% - 2rem));
  margin: 2rem auto;
}

.hero {
  background: linear-gradient(135deg, #2935a0 0%, #1f56ff 100%);
  color: white;
  padding: 2rem;
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(25, 64, 155, 0.15);
  margin-bottom: 2rem;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 3vw, 3.2rem);
}

.hero p {
  margin: 0;
  max-width: 720px;
  line-height: 1.75;
}

.grid,
.data-grid,
.chart-grid {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.grid,
.chart-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.widget-card,
.data-card,
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.25rem;
}

.widget-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 140px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.widget-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #1f56ff, #43c6ff);
  transition: height 0.3s ease;
}

.widget-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(31, 86, 255, 0.15);
}

.widget-card:hover::before {
  height: 4px;
}

.widget-icon {
  font-size: 1.8rem;
  height: 32px;
  display: flex;
  align-items: center;
}

.widget-title {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
}

.widget-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.widget-trend {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(31, 86, 255, 0.08);
  color: #1f56ff;
  align-self: fit-content;
  margin-top: auto;
}

.widget-card.up .widget-trend {
  background: rgba(16, 185, 129, 0.08);
  color: #10b981;
}

.widget-card.ok .widget-trend {
  background: rgba(34, 197, 94, 0.08);
  color: #22c55e;
}

.widget-card.warning .widget-trend {
  background: rgba(245, 158, 11, 0.08);
  color: #f59e0b;
}

.widget-card.down .widget-trend {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
}

.section-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  overflow: hidden;
}

.section-block h2,
.section-block h1 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.insights-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.input-group .form-control {
  flex: 1;
}

.input-group .button {
  white-space: nowrap;
}

.data-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.data-card {
  min-height: 180px;
}

.data-card div {
  margin-bottom: 0.75rem;
}

.data-card strong {
  display: inline-block;
  width: 110px;
  color: var(--text-muted);
}

.chart-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  justify-content: space-between;
  position: relative;
}

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.chart-canvas {
  width: 100%;
  height: 280px;
  flex-grow: 1;
  display: block;
  min-height: 200px;
  max-height: 350px;
}

@media (max-width: 1200px) {
  .chart-canvas {
    height: 260px;
    max-height: 300px;
  }
}

@media (max-width: 1024px) {
  .chart-canvas {
    height: 240px;
    max-height: 280px;
  }
}

@media (max-width: 768px) {
  .chart-canvas {
    height: 220px;
    max-height: 260px;
  }
}

@media (max-width: 580px) {
  .chart-canvas {
    height: 200px;
    max-height: 220px;
  }
}

@media (max-width: 480px) {
  .chart-canvas {
    height: 180px;
    max-height: 200px;
  }
}

@media (max-height: 700px) and (orientation: portrait) {
  .chart-canvas {
    height: 180px;
    max-height: 200px;
  }
}

.footer {
  text-align: center;
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.table-card,
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
}

.table-card th,
.table-card td {
  padding: 0.95rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table-card th {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.table-card tbody tr:hover {
  background: rgba(31, 86, 255, 0.05);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1.25rem;
  border-radius: 999px;
  border: none;
  background: var(--primary);
  color: white;
  text-decoration: none;
  font-weight: 600;
  transition:
    transform 0.12s ease,
    background 0.12s ease;
}

/* Toast styles (shared) */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.08);
  font-weight: 600;
  color: #071024;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.toast-success {
  background: #ecfdf5;
  border: 1px solid #86efac;
}
.toast-error {
  background: #fff1f2;
  border: 1px solid #fca5a5;
}
.toast-info {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
}

.toast-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #334155;
}

.button:hover {
  transform: translateY(-1px);
  background: #133bd9;
}

.button-secondary {
  background: var(--surface-strong);
  color: var(--text);
}

.button-secondary:hover {
  background: #e4ecfb;
}

.button-small {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border-radius: 999px;
}

.access-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
}

.access-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.row-actions a {
  margin-right: 1rem;
  color: var(--primary);
  text-decoration: none;
}

.row-actions a.danger {
  color: #d33b49;
}

.form-card label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form-card input,
.form-card select,
.form-card textarea {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  background: #fff;
  color: var(--text);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.alert {
  padding: 1rem 1.25rem;
  border-radius: 14px;
  margin-bottom: 1rem;
}

.alert-error {
  background: #ffe5e7;
  color: #9f2136;
  border: 1px solid #f3c1c8;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: linear-gradient(135deg, #eef4ff 0%, #f9fbff 100%);
}

.auth-card {
  width: min(980px, 100%);
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
  background: white;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 32px 120px rgba(30, 76, 162, 0.14);
}

.auth-hero {
  padding: 3rem 2.5rem;
  background: linear-gradient(180deg, #1636f8 0%, #1f56ff 100%);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.auth-hero h2 {
  font-size: clamp(2rem, 2.5vw, 2.75rem);
  margin: 0;
  line-height: 1.05;
}

.auth-hero p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 1rem;
  line-height: 1.75;
  margin: 1.5rem 0 2rem;
  max-width: 34rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.hero-stats div {
  background: rgba(255, 255, 255, 0.12);
  padding: 1rem 1.25rem;
  border-radius: 18px;
}

.hero-stats strong {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

.hero-stats span {
  display: block;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
}

.auth-form-panel {
  padding: 3rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-form-header h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
}

.auth-form-header p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.75;
}

.auth-form-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.logo-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(31, 86, 255, 0.12);
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: 700;
}

.auth-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.75rem;
}

.auth-form-checkbox {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(31, 86, 255, 0.12);
  background: #f8fbff;
  color: var(--text);
  font-weight: 500;
}

.auth-form-checkbox input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--primary);
}

/* Enhanced Chart Styles */
.chart-card {
  background: linear-gradient(180deg, var(--surface) 0%, #fafbff 100%);
}

.chart-card:hover {
  box-shadow: 0 12px 30px rgba(31, 86, 255, 0.15);
}

.chart-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}

/* Dashboard Filter Styles */
.dashboard-controls {
  margin-top: 1rem;
}

.filter-input,
.filter-select {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color 0.2s ease;
}

.filter-input:focus,
.filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 86, 255, 0.15);
  outline: none;
}

/* Dashboard Navigation */
.dashboard-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.dashboard-nav-item {
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 500;
  transition: all 0.2s ease;
}

.dashboard-nav-item:hover {
  background: var(--surface-strong);
  transform: translateY(-1px);
}

.dashboard-nav-item.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Export Button */
.export-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.export-btn:hover {
  background: var(--surface-strong);
  border-color: var(--primary);
}

/* Auto-refresh indicator */
.auto-refresh-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Enhanced Grid Spacing */
.grid {
  gap: 1.75rem;
}

.section-block {
  margin-bottom: 2.5rem;
}

/* Real-time indicator dot */
.realtime-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  margin-right: 0.5rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.auth-form label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.auth-form input {
  width: 100%;
  padding: 1rem 1.1rem;
  border-radius: 16px;
  border: 1px solid rgba(31, 86, 255, 0.12);
  box-shadow: inset 0 1px 2px rgba(15, 23, 57, 0.05);
  font-size: 1rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.auth-form input:focus {
  outline: none;
  border-color: rgba(31, 86, 255, 0.35);
  box-shadow: 0 0 0 4px rgba(31, 86, 255, 0.12);
}

.auth-form .button {
  padding: 1rem 1.25rem;
  font-size: 1rem;
  border-radius: 16px;
}

.auth-help {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

@media (max-width: 900px) {
  .auth-card {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    padding: 2.5rem 2rem;
  }

  .auth-form-panel {
    padding: 2.5rem 2rem;
  }
}

@media (max-width: 580px) {
  .auth-page {
    padding: 1.25rem;
  }

  .auth-hero,
  .auth-form-panel {
    padding: 1.75rem 1.5rem;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .auth-form-header h1 {
    font-size: 1.75rem;
  }
}
