:root {
  --primary: #00F0FF;
  --primary-hover: #00d2e0;
  --primary-glow: rgba(0, 240, 255, 0.35);
  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --indigo: #6366f1;
  
  --bg-deep: #060913;
  --bg-main: #0a0f1d;
  --bg-card: #10172a;
  --bg-card-hover: #162038;
  --bg-input: #090e1c;
  
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #8492a6;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(0, 240, 255, 0.5);
  
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.3);
  --yellow: #f59e0b;
  --yellow-glow: rgba(245, 158, 11, 0.3);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ================= LOGIN VIEW STYLES ================= */
.login-wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-deep);
  z-index: 9999;
  padding: 20px;
}

.login-background-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.15) 0%, rgba(99, 102, 241, 0.08) 40%, transparent 70%);
  filter: blur(60px);
  pointer-events: none;
}

.login-box {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: rgba(16, 23, 42, 0.85);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 16px;
  padding: 36px 32px;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 240, 255, 0.1);
  animation: fadeIn 0.4s ease-out;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.logo-shield-container {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
}

.login-logo-img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 12px rgba(0, 240, 255, 0.5));
}

.login-brand h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 18px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon {
  position: absolute;
  left: 14px;
  font-size: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-wrapper input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #fff;
  padding: 12px 14px 12px 42px;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15);
}

.password-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.login-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.secure-badge {
  color: var(--primary);
}

/* ================= NAVBAR STYLES ================= */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  background: rgba(16, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-frame {
  width: 38px;
  height: 38px;
}

.nav-logo {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 8px rgba(0, 240, 255, 0.4));
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title-row h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: #fff;
}

.version-tag {
  font-size: 10px;
  font-weight: 600;
  background: rgba(0, 240, 255, 0.12);
  color: var(--primary);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.clock-badge {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.admin-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px 10px 4px 5px;
  border-radius: 20px;
  border: 1px solid var(--border);
  margin-left: 6px;
}

.avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--blue));
  color: #000;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.logout-btn {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 2px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.logout-btn:hover {
  opacity: 1;
}

/* ================= CONTAINER & KPI CARDS ================= */
.container {
  max-width: 1440px;
  margin: 24px auto;
  padding: 0 24px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.kpi-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.kpi-icon {
  font-size: 16px;
}

.kpi-body {
  display: flex;
  flex-direction: column;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: #fff;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-bar-glow {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.bar-cyan { background: var(--primary); box-shadow: 0 0 10px var(--primary-glow); }
.bar-green { background: var(--green); box-shadow: 0 0 10px var(--green-glow); }
.bar-amber { background: var(--yellow); box-shadow: 0 0 10px var(--yellow-glow); }
.bar-indigo { background: var(--indigo); box-shadow: 0 0 10px rgba(99, 102, 241, 0.4); }

.branch-split {
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
  padding: 6px 0;
}

.branch-col {
  text-align: center;
}

.branch-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.branch-num {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.branch-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}

/* ================= FILTER & SEARCH BAR ================= */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 14px;
}

.search-box input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: #fff;
  padding: 10px 14px 10px 38px;
  border-radius: 8px;
  font-size: 13px;
  transition: all 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.15);
}

.branch-filter {
  display: flex;
  background: var(--bg-card);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  gap: 4px;
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  color: #fff;
}

.filter-btn.active {
  background: rgba(0, 240, 255, 0.12);
  color: var(--primary);
  border: 1px solid rgba(0, 240, 255, 0.3);
}

/* ================= TABLE STYLES ================= */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.devices-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.devices-table th {
  background: rgba(10, 15, 29, 0.8);
  padding: 14px 18px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.devices-table td {
  padding: 14px 18px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.devices-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-online {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-idle {
  background: rgba(245, 158, 11, 0.12);
  color: var(--yellow);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-offline {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot-online {
  background-color: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}

.dot-idle {
  background-color: var(--yellow);
}

.dot-offline {
  background-color: var(--text-muted);
}

.country-tag {
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.app-indicator {
  display: flex;
  flex-direction: column;
  max-width: 280px;
}

.app-name {
  font-weight: 600;
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-title {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.relay-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
}

.relay-ready {
  background: rgba(0, 240, 255, 0.1);
  color: var(--primary);
  border: 1px solid rgba(0, 240, 255, 0.3);
}

.relay-standby {
  color: var(--text-muted);
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--blue) 100%);
  color: #060913;
  font-weight: 700;
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 16px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: #fff;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fff;
}

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

/* ================= MODALS ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none !important;
}

.small-modal {
  width: 100%;
  max-width: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.close-btn:hover {
  color: #fff;
}

.code-box {
  background: #060913;
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 6px;
  margin-top: 6px;
  font-family: monospace;
  font-size: 12px;
  color: var(--primary);
  word-break: break-all;
}

/* ================= REMOTE DESKTOP WINDOW ================= */
.remote-window {
  width: 95vw;
  height: 90vh;
  max-width: 1560px;
  background: #000;
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 240, 255, 0.1);
}

.remote-toolbar {
  height: 52px;
  background: #0a0f1d;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}

.remote-brand-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(0, 240, 255, 0.08);
  padding: 4px 8px;
  border-radius: 4px;
}

.mini-logo {
  width: 16px;
  height: 16px;
}

.remote-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.remote-controls {
  display: flex;
  gap: 6px;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.canvas-viewport {
  position: relative;
  flex: 1;
  background: #020408;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#screenCanvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: default;
}

.consent-waiting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 8, 0.92);
  z-index: 10;
  text-align: center;
  padding: 20px;
}

.consent-waiting h3 {
  font-size: 18px;
  margin: 16px 0 8px;
  color: #fff;
}

.consent-waiting p {
  color: var(--text-secondary);
  font-size: 14px;
}

.consent-waiting .hint-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(0, 240, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.inline-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

/* ================= ANALYTICS WINDOW ================= */
.analytics-window {
  width: 90vw;
  max-width: 1100px;
  height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.7);
}

.analytics-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.analytics-header-info {
  display: flex;
  flex-direction: column;
}

.analytics-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.analytics-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.mini-kpi {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.mini-kpi .label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 4px;
}

.mini-kpi .val {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.analytics-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.chart-box, .timeline-box {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.chart-box h3, .timeline-box h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.app-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-row-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.app-progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.app-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--blue));
  border-radius: 3px;
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.timeline-time {
  font-family: monospace;
  color: var(--text-muted);
  white-space: nowrap;
}

.timeline-content {
  flex: 1;
}

.timeline-app {
  font-weight: 600;
  color: #fff;
}

.timeline-title {
  color: var(--text-muted);
  font-size: 11px;
}

/* Animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.9); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.hidden {
  display: none !important;
}
