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

:root {
  --bg: #f0f8fa;
  --surface: #ffffff;
  --card: #f7fbfc;
  --border: #e0eff3;
  --primary: #00bcd4;
  --primary-dark: #0097a7;
  --primary-dim: rgba(0, 188, 212, 0.1);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.08);
  --success: #10b981;
  --success-dim: rgba(16, 185, 129, 0.08);
  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.08);
  --text: #1a2b3c;
  --text-muted: #6b8299;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0, 188, 212, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ===== LOGIN ===== */
.login-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}

.login-logo {
  width: 200px;
  height: auto;
  margin-bottom: 32px;
}

.login-container h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text);
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 36px;
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

#login-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#login-form input {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 18px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  box-shadow: var(--shadow);
}

#login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

#login-form button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 15px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: transform 0.1s, background 0.2s;
  box-shadow: 0 4px 14px rgba(0, 188, 212, 0.3);
}

#login-form button:active {
  transform: scale(0.97);
  background: var(--primary-dark);
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

.biometric-btn {
  width: 100%;
  max-width: 320px;
  background: none;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  margin-top: 16px;
  transition: background 0.2s, color 0.2s;
}

.biometric-btn:active {
  background: var(--primary);
  color: white;
}

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
}

.header-logo {
  height: 36px;
  width: auto;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.icon-btn:active {
  background: var(--primary-dim);
  color: var(--primary);
}

/* ===== VIEWS ===== */
.view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px;
}

.view.active {
  display: flex;
}

.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.view-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
}

.view-header .view-title {
  margin-bottom: 0;
}

.back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
}

/* ===== HOME CARDS ===== */
.home-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}

.home-card:active {
  transform: scale(0.98);
  box-shadow: 0 4px 20px rgba(0, 188, 212, 0.15);
}

.home-card.alert-card-home {
  border-left: 4px solid var(--danger);
  background: linear-gradient(135deg, var(--surface), var(--danger-dim));
}

.home-card.nac-card-home {
  border-left: 4px solid var(--warning);
  background: linear-gradient(135deg, var(--surface), var(--warning-dim));
}

.home-card.info-card-home {
  border-left: 4px solid var(--primary);
  background: linear-gradient(135deg, var(--surface), var(--primary-dim));
}

.home-card-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 12px;
}

.home-card-content {
  flex: 1;
  min-width: 0;
}

.home-card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 3px;
  color: var(--text);
}

.home-card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-card-arrow {
  font-size: 22px;
  color: var(--text-muted);
  font-weight: 300;
}

/* ===== ALERT CARDS ===== */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

.alert-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1.5px solid var(--border);
  border-left-width: 4px;
  transition: transform 0.1s;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.alert-card:active {
  transform: scale(0.98);
}

.alert-card.high { border-left-color: var(--danger); }
.alert-card.medium { border-left-color: var(--warning); }
.alert-card.low { border-left-color: var(--success); }

.alert-card .alert-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
  color: var(--text);
}

.alert-card .alert-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alert-card .alert-details {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 12px;
  font-family: 'SF Mono', 'Courier New', monospace;
  color: var(--primary-dark);
  display: none;
  line-height: 1.7;
  border: 1px solid var(--border);
}

.alert-card.expanded .alert-details {
  display: block;
}

.alert-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.alert-badge.high { background: var(--danger-dim); color: var(--danger); }
.alert-badge.medium { background: var(--warning-dim); color: var(--warning); }
.alert-badge.low { background: var(--success-dim); color: var(--success); }

/* ===== NAC CARDS ===== */
.nac-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}

.nac-card .device-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nac-card .device-icon {
  font-size: 20px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 10px;
  flex-shrink: 0;
}

.nac-card .device-info {
  flex: 1;
  min-width: 0;
}

.nac-card .device-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.nac-card .device-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'SF Mono', 'Courier New', monospace;
}

.nac-card .device-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.action-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

.action-btn:active {
  transform: scale(0.93);
  opacity: 0.8;
}

.action-btn.allow {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 188, 212, 0.3);
}

.action-btn.block {
  background: var(--danger);
  color: white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.nac-card.blocked {
  opacity: 0.7;
  border-left: 4px solid var(--danger);
}

.nac-card.allowed {
  border-left: 4px solid var(--primary);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .emoji {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 15px;
  font-weight: 500;
}

.empty-state .empty-sub {
  font-size: 13px;
  margin-top: 6px;
  color: var(--text-muted);
}

/* ===== TOAST NOTIFICATIONS ===== */
#toast-container {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  border: 1.5px solid var(--border);
  overflow: hidden;
  pointer-events: auto;
  animation: slideIn 0.3s ease-out forwards;
  position: relative;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--primary); }

.toast-content {
  display: flex;
  align-items: flex-start;
  padding: 14px 16px;
  gap: 10px;
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast-text {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
}

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

.toast-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  flex-shrink: 0;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  animation: progressBar 4s linear forwards;
}

.toast-success .toast-progress { background: var(--success); }
.toast-error .toast-progress { background: var(--danger); }
.toast-warning .toast-progress { background: var(--warning); }

@keyframes slideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-20px); opacity: 0; }
}

@keyframes progressBar {
  from { width: 100%; }
  to { width: 0%; }
}

/* ===== CONFIRM MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  border: 1.5px solid var(--border);
  animation: scaleIn 0.2s ease-out;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.modal-message {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}

.modal-btn:active {
  transform: scale(0.95);
}

.modal-cancel {
  background: var(--bg);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}

.modal-confirm {
  background: var(--danger);
  color: white;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===== QR SCANNER ===== */
.qr-scanner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.qr-instructions {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 0 20px;
}

#qr-video {
  width: 100%;
  max-width: 300px;
  border-radius: 12px;
  border: 2px solid var(--primary);
  background: #000;
}

.qr-result {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  min-height: 20px;
}

/* ===== DNS MANAGEMENT ===== */
.dns-section {
  margin-bottom: 24px;
}

.dns-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.dns-policy-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dns-policy-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.dns-policy-item.active {
  border-color: var(--primary);
  background: var(--primary-dim);
}

.dns-policy-name {
  font-size: 14px;
  font-weight: 600;
}

.dns-policy-desc {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}

.dns-active-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-dim);
  padding: 3px 8px;
  border-radius: 6px;
}

.dns-category-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.dns-category-name {
  font-size: 14px;
  font-weight: 600;
}

.dns-category-count {
  font-size: 11px;
  color: var(--text-muted);
}

.dns-toggle {
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.dns-toggle.on {
  background: var(--success);
  color: white;
}

.dns-toggle.off {
  background: var(--border);
  color: var(--text-muted);
}

.dns-add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.dns-input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  outline: none;
}

.dns-input:focus {
  border-color: var(--primary);
}

.dns-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 4px;
}

.dns-domain {
  font-size: 13px;
  font-family: 'SF Mono', 'Courier New', monospace;
  color: var(--text);
}

.dns-remove-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.dns-remove-btn:active {
  background: var(--danger-dim);
}

.dns-apply-btn {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  transition: opacity 0.2s;
}

.dns-apply-btn:active {
  opacity: 0.8;
}

.dns-category-info {
  flex: 1;
  cursor: pointer;
}

.dns-category-info:active {
  opacity: 0.7;
}

/* ===== License Badges ===== */
.license-badge-mobile {
  font-size: 14px;
  margin-left: 4px;
}

.grace-badge-mobile {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  background: var(--warning-dim);
  color: #92400e;
  border: 1px solid var(--warning);
}

.action-btn.license {
  background: #6366f1;
  color: white;
  font-size: 12px;
  padding: 6px 10px;
}

.action-btn.license:active {
  background: #4f46e5;
}

/* === NAC Group styles === */
.nac-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.nac-group-header:active {
  background: var(--primary-dim);
}

.nac-group-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.nac-group-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.nac-group-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

.nac-group-devices {
  padding-left: 8px;
  margin-bottom: 12px;
}

.action-btn.move {
  background: var(--primary-dim);
  color: var(--primary-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  padding: 6px 10px;
}

.action-btn.move:active {
  background: var(--primary);
  color: white;
}

.connected-badge-mobile {
  font-size: 11px;
  color: var(--success);
  font-weight: 500;
}

.offline-badge-mobile {
  font-size: 11px;
  color: var(--text-muted);
}

/* Modal field for group select */
.modal-field {
  margin: 12px 0;
}

.modal-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.modal-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: white;
}

/* Create group button */
.create-group-btn-mobile {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.create-group-btn-mobile:active {
  background: var(--primary-dark);
}

/* Constellation background */
#constellation-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

#app {
  position: relative;
  z-index: 1;
}

/* ===== PIN Screen ===== */
.pin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
}

.pin-logo {
  width: 180px;
  max-width: 50%;
  margin-bottom: 24px;
}

.pin-container h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 24px;
}

.pin-dots {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: transparent;
  transition: all 0.2s;
}

.pin-dot.filled {
  background: var(--primary);
  transform: scale(1.1);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 280px;
  width: 100%;
  margin-top: 20px;
}

.pin-key {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.pin-key:active {
  background: var(--primary);
  color: white;
  transform: scale(0.95);
}

.pin-key-empty {
  border: none;
  background: transparent;
  cursor: default;
}

.pin-key-delete {
  font-size: 20px;
  color: var(--text-muted);
  border-color: transparent;
  background: transparent;
}

.pin-key-delete:active {
  background: var(--danger-dim);
  color: var(--danger);
}

#pin-error {
  min-height: 20px;
  margin: 8px 0;
}
