/* ==========================================================================
   NightVision — design tokens
   Dark theme by default (matches the original app's defaultTheme="dark").
   Primary: deep security-red. Cards on a near-black surface.
   ========================================================================== */

:root {
  --background: #0c0d10;
  --foreground: #f2f3f5;

  --card: #101114;
  --card-foreground: #f2f3f5;

  --primary: #b30000;
  --primary-glow: #e60000;
  --primary-foreground: #fafafa;

  --secondary: #1b1d22;
  --secondary-foreground: #f2f3f5;

  --muted: #1b1d22;
  --muted-foreground: #9a9ea6;

  --accent: #b30000;
  --accent-foreground: #fafafa;

  --destructive: #ef4444;
  --destructive-foreground: #fafafa;

  --success: #22c55e;
  --warning: #eab308;
  --info: #3b82f6;

  --border: #23252b;
  --input: #23252b;
  --ring: #b30000;

  --radius: 10px;
  --shadow-primary: 0 10px 30px -10px rgba(179, 0, 0, 0.35);
}

[data-theme="light"] {
  --background: #ffffff;
  --foreground: #14161a;

  --card: #ffffff;
  --card-foreground: #14161a;

  --primary: #6b0000;
  --primary-glow: #a10000;
  --primary-foreground: #fafafa;

  --secondary: #f2f3f5;
  --secondary-foreground: #14161a;

  --muted: #f2f3f5;
  --muted-foreground: #6b7280;

  --accent: #6b0000;
  --accent-foreground: #fafafa;

  --border: #e5e7eb;
  --input: #e5e7eb;
  --ring: #6b0000;

  --shadow-primary: 0 10px 30px -10px rgba(107, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- gradient text / brand mark ---------- */
.brand-gradient {
  background: linear-gradient(135deg, var(--primary), var(--primary-glow));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gradient-bg {
  background: linear-gradient(135deg, var(--background) 0%, var(--muted) 100%);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-glow));
  color: var(--primary-foreground);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-primary);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--foreground);
}

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

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--foreground);
  background: var(--secondary);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 0.9rem 2rem;
  font-size: 1rem;
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

/* ---------- form elements ---------- */
.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.input-wrap {
  position: relative;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  color: var(--foreground);
  font-size: 0.9rem;
}

input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(179, 0, 0, 0.15);
}

.field-error {
  color: var(--destructive);
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

.toggle-visibility {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 0.35rem;
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card-header {
  padding: 1.25rem 1.25rem 0.5rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.card-description {
  color: var(--muted-foreground);
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
}

.card-content {
  padding: 1.25rem;
}

/* ---------- auth pages ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.5);
}

.auth-theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.auth-header {
  text-align: center;
  padding: 2rem 1.5rem 0.5rem;
}

.auth-icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: rgba(179, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.auth-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--primary);
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.auth-subtitle {
  color: var(--muted-foreground);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.65rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-size: 0.9rem;
  cursor: pointer;
}

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

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 500;
}

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

.link {
  color: var(--primary);
  font-size: 0.85rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

/* ---------- app shell / sidebar ---------- */
.app-shell {
  min-height: 100vh;
  background: var(--background);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 264px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.sidebar.open,
.app-shell .sidebar {
  transform: translateX(0);
}

@media (max-width: 1023px) {
  .app-shell .sidebar {
    transform: translateX(-100%);
  }
  .app-shell .sidebar.open {
    transform: translateX(0);
  }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

.sidebar-overlay.open {
  display: block;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-logo svg {
  width: 26px;
  height: 26px;
  stroke: var(--primary);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted-foreground);
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

.nav-item:hover {
  color: var(--foreground);
  background: var(--secondary);
}

.nav-item.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.sidebar-footer .user-email {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-area {
  min-height: 100vh;
}

@media (min-width: 1024px) {
  .main-area {
    padding-left: 264px;
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--background) 90%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
}

.hamburger {
  display: none;
}

@media (max-width: 1023px) {
  .hamburger {
    display: inline-flex;
  }
}

.page-content {
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* ---------- dashboard grid ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1023px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 639px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  padding: 1.1rem 1.25rem;
}

.stat-card .stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin-bottom: 0.6rem;
}

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

.stat-card .stat-sub {
  font-size: 0.78rem;
  color: var(--muted-foreground);
  margin-top: 0.35rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 1023px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

.service-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  margin-bottom: 0.75rem;
}

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

.service-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.service-info svg {
  width: 20px;
  height: 20px;
  stroke: var(--primary);
}

.service-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.service-meta {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-active {
  background: var(--success);
  color: #06210f;
}

.badge-paused {
  background: var(--secondary);
  color: var(--muted-foreground);
}

.badge-outline {
  border: 1px solid var(--border);
  color: var(--muted-foreground);
}

.badge-destructive {
  background: var(--destructive);
  color: #2b0505;
}

.alert-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  margin-bottom: 0.75rem;
}

.alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-top: 0.4rem;
  flex-shrink: 0;
}

.dot-high { background: #ef4444; }
.dot-medium { background: #eab308; }
.dot-low { background: #3b82f6; }

.alert-msg {
  font-size: 0.85rem;
  font-weight: 500;
}

.alert-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.3rem;
}

.alert-time {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* ---------- monitoring setup ---------- */
.setup-shell {
  min-height: 100vh;
  padding: 2rem 1rem;
}

.setup-header {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 2rem;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  max-width: 960px;
  margin: 0 auto 2rem;
}

@media (max-width: 900px) {
  .setup-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }
}

.option-card {
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  padding: 1.1rem;
}

.option-card:hover {
  border-color: color-mix(in srgb, var(--primary) 50%, var(--border));
}

.option-card.selected {
  border-color: var(--primary);
  box-shadow: var(--shadow-primary);
}

.option-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.option-top-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.option-title {
  font-weight: 600;
  font-size: 1rem;
}

.option-desc {
  color: var(--muted-foreground);
  font-size: 0.85rem;
}

.summary-box {
  max-width: 640px;
  margin: 0 auto 1.5rem;
  text-align: center;
  padding: 1.25rem;
}

.chip {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  background: rgba(179, 0, 0, 0.12);
  color: var(--primary-glow);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  margin: 0.2rem;
}

.setup-actions {
  text-align: center;
}

/* ---------- consent page ---------- */
.consent-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.consent-card {
  max-width: 640px;
  width: 100%;
}

.consent-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--foreground);
}

.consent-body h3 {
  font-size: 0.95rem;
  margin: 1.25rem 0 0.4rem;
}

.consent-body ul {
  padding-left: 1.2rem;
  color: var(--muted-foreground);
}

.consent-checkline {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 1.5rem 0 1rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--secondary);
}

.consent-checkline input {
  margin-top: 0.2rem;
}

/* ---------- data tables (monitoring viewer pages) ---------- */
.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--muted-foreground);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.placeholder-note {
  display: flex;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--border);
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  background: var(--secondary);
}

/* ---------- utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.text-muted { color: var(--muted-foreground); }
.text-sm { font-size: 0.85rem; }
.page-title { font-size: 1.75rem; font-weight: 700; margin: 0 0 0.25rem; }
.page-sub { color: var(--muted-foreground); margin: 0; }
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.not-found-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-direction: column;
  gap: 1rem;
}
