/* RSN Master Ops Hub - Luxury Obsidian Styling */
:root {
  --bg-main: #060913;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-glass: rgba(30, 41, 59, 0.5);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(220, 38, 38, 0.25);
  
  --color-ruby: #dc2626;
  --color-ruby-dark: #8b1016;
  --color-gold: #f59e0b;
  --color-emerald: #10b981;
  --color-sky: #38bdf8;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 12px 35px -5px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Cairo', 'Outfit', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Ambient glow background */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(139, 16, 22, 0.25) 0%, transparent 70%);
  top: -100px;
  right: -100px;
}
.glow-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.12) 0%, transparent 70%);
  bottom: -50px;
  left: -50px;
}

/* Auth Container */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 10;
}
.auth-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
}
.auth-header {
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo-badge {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--color-ruby-dark), var(--color-ruby));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 14px;
  box-shadow: 0 8px 25px rgba(220, 38, 38, 0.4);
}
.auth-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}
.auth-header p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* TOTP Setup Box */
.totp-setup-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
}
.setup-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-gold);
  margin-bottom: 8px;
}
.setup-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.qr-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px 0;
}
.qr-container img,
.qr-container svg {
  width: 160px;
  height: 160px;
  background: #ffffff;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  display: block;
}
.secret-text-box {
  margin-top: 10px;
}
.secret-text-box small {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.secret-text-box code {
  font-family: 'Outfit', monospace;
  color: var(--color-gold);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 2px;
  user-select: all;
}

/* Form controls */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 8px;
}
input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-family: inherit;
  transition: all 0.2s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--color-ruby);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--color-ruby-dark), var(--color-ruby));
  color: #fff;
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.45);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}
.btn-gold {
  background: linear-gradient(135deg, #b45309, var(--color-gold));
  color: #fff;
}
.btn-gold:hover {
  filter: brightness(1.1);
}
.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}
.btn-outline:hover {
  color: #fff;
  border-color: #cbd5e1;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}
.btn-block {
  width: 100%;
  justify-content: center;
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

/* Master Dashboard Layout */
#dashboard-scene {
  position: relative;
  z-index: 10;
  padding: 24px 36px;
  max-width: 1440px;
  margin: 0 auto;
}

.master-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-ruby-dark), var(--color-ruby));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
}
.header-brand h1 {
  font-size: 1.3rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-brand .subhead {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.header-actions {
  display: flex;
  gap: 12px;
}

/* Telemetry Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.metric-icon {
  font-size: 2rem;
}
.metric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}
.metric-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  font-family: 'Outfit', sans-serif;
}

/* Main Table Panel */
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}
.panel-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.panel-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.table-responsive {
  overflow-x: auto;
}
.master-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}
.master-table th {
  padding: 12px 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}
.master-table td {
  padding: 14px;
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}
.master-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-ruby {
  background: rgba(220, 38, 38, 0.15);
  color: #f87171;
  border: 1px solid rgba(220, 38, 38, 0.3);
}
.badge-emerald {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-gold {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  padding: 28px;
  box-shadow: var(--shadow-card);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Responsive Table Container */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 14px;
}

.master-table {
  min-width: 750px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: #1e293b;
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  box-shadow: var(--shadow-card);
  z-index: 200;
  display: none;
}

/* ============================================================ */
/* MOBILE & TABLET RESPONSIVE ENGINE (Touch-First & 60 FPS)    */
/* ============================================================ */
@media (max-width: 992px) {
  body {
    background-color: #060913 !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Strip GPU-heavy blur filters on mobile */
  .ambient-glow {
    display: none !important;
  }

  .auth-card,
  .master-header,
  .metric-card,
  .panel-card,
  .modal-backdrop {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  #dashboard-scene {
    padding: 16px 12px 40px 12px;
  }

  .master-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 16px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .header-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    font-size: 0.82rem;
    padding: 10px 8px;
  }

  .telemetry-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .metric-card {
    padding: 14px 16px;
    gap: 12px;
  }

  .metric-value {
    font-size: 1.2rem;
  }

  .panel-card {
    padding: 16px 12px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

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

  .telemetry-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .auth-card {
    padding: 24px 16px;
    margin: 10px 0;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  input[type="text"], 
  input[type="password"], 
  input[type="number"], 
  select {
    font-size: 16px !important;
    min-height: 46px;
  }

  /* Modals as Bottom Sheets */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    padding: 24px 16px;
  }
}
