:root {
  --bg: #050507;
  --bg-card: rgba(18, 18, 24, 0.7);
  --bg-input: #121218;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: #00ff88;
  --text: #ffffff;
  --text-muted: #94a3b8;
  --primary: #00ff88;
  --primary-glow: rgba(0, 255, 136, 0.3);
  --secondary: #00eaff;
  --danger: #ff4757;
  --danger-glow: rgba(255, 71, 87, 0.3);
  --accent-gradient: linear-gradient(135deg, #00ff88 0%, #00eaff 100%);
  --radius: 14px;
  --font: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --glass-blur: blur(12px);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(circle at 50% 0%, #1a1a2e 0%, #050507 70%);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

body::after {
  content: 'INOVAPRO';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-15deg);
  font-size: 15vw;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.015);
  pointer-events: none;
  z-index: -1;
}

.app {
  width: 95%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

.header {
  margin-bottom: 2rem;
  padding: 1.5rem 0 1.2rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.main {
  padding: 0.5rem 0 2rem 0;
}

.logo {
  font-size: 2.22rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px var(--primary-glow));
}

.tagline {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.2rem;
}

/* Forcing centered text on very small screens for header */
@media (max-width: 600px) {
  .header {
    justify-content: center;
    text-align: center;
  }
}

.license-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(0, 255, 136, 0.05);
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 255, 136, 0.1);
  font-size: 0.8rem;
  color: var(--primary);
}

.license-dot {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary);
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 2rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.tab {
  padding: 0.7rem 1.5rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab.active {
  background: var(--accent-gradient);
  color: #000;
  border: none;
  box-shadow: 0 4px 15px var(--primary-glow);
}

/* Panels & Cards - EXPANSIVE GRID */
.panel {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.5rem;
  align-items: start;
}

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

.panel.active {
  display: grid;
}

.card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.25rem;
}

.card h2 {
  font-size: 1.1rem;
  margin: 0 0 0.8rem 0;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.card h2::before {
  content: '';
  width: 3px;
  height: 18px;
  background: var(--accent-gradient);
  border-radius: 2px;
}

.card-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Forms */
.form-row {
  margin-bottom: 1.2rem;
}

.form-row label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #fff;
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  padding: 0.7rem 1.4rem;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent-gradient);
  color: #000;
}

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

.btn-danger {
  background: rgba(255, 71, 87, 0.1);
  color: var(--danger);
  border: 1px solid rgba(255, 71, 87, 0.2);
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
}

/* Dynamic Lists */
.item-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.block-section {
  background: rgba(255, 255, 255, 0.02);
  padding: 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 0.8rem;
}

/* QR and Status */
.qr-container {
  margin-top: 1rem;
  padding: 0.6rem;
  background: #fff;
  border-radius: 10px;
  display: inline-block;
  line-height: 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.qr-container p {
  margin: 0 0 0.5rem 0;
  color: #000;
  font-weight: 700;
  font-size: 0.75rem;
  line-height: normal;
}

.qr-image {
  width: 260px;
  height: 260px;
}

.qr-hint {
  display: block;
  margin-top: 0.5rem !important;
  color: #666 !important;
  font-size: 0.65rem !important;
}

.status {
  margin-top: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem;
  border-radius: 8px;
  text-align: center;
}

.status.success {
  background: rgba(0, 255, 136, 0.1);
  color: var(--primary);
}

.status.error {
  background: rgba(255, 71, 87, 0.1);
  color: var(--danger);
}

/* Instance Lists */
.instance-list,
.saved-list {
  list-style: none;
  padding: 0;
}

.instance-row,
.saved-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
}

.badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge.connected {
  background: var(--primary);
  color: #000;
}

.badge.qr {
  background: #ffe600;
  color: #000;
}

/* Auth Gate */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 50%, #1a1a2e 0%, #050507 100%);
}

.gate-card {
  width: 400px;
  text-align: center;
  padding: 2rem !important;
}

.gate-form {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hidden {
  display: none !important;
}

.dispatch-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

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

  .tabs {
    flex-wrap: wrap;
  }
}