:root {
  --bg-dark: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-glow: rgba(56, 189, 248, 0.3);
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.06) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  padding: 24px;
  line-height: 1.5;
}

.app-container {
  max-width: 1240px;
  margin: 0 auto;
}

/* HEADER STYLING */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
  gap: 16px;
}

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

.brand-logo {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
  flex-shrink: 0;
}

.brand-title h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* STATUS PILL */
.status-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.status-dot.offline {
  background: var(--danger);
}

/* DASHBOARD GRID */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* CARD STYLING */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* FORMS & INPUTS */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-group {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-input,
.simple-input,
.custom-select {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  width: 100%;
  transition: all 0.2s ease;
}

.form-input:focus,
.simple-input:focus,
.custom-select:focus {
  border-color: var(--primary);
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

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

.input-wrapper .form-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-suffix {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: none;
  padding: 10px 14px;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.manual-probe-box {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px;
  margin-top: 14px;
  margin-bottom: 14px;
}

.manual-header {
  margin-bottom: 10px;
}

.manual-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.manual-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.field-hint code {
  color: var(--primary);
  background: rgba(56, 189, 248, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
}

/* CUSTOM CHECKBOX TOGGLE */
.custom-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  color: var(--text-main);
  margin-top: 4px;
}

.custom-checkbox-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.4);
}

.btn-secondary {
  background: rgba(51, 65, 85, 0.6);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(71, 85, 105, 0.8);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
  background: linear-gradient(135deg, #047857, #059669);
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
}

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

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.4);
}

.btn-block {
  width: 100%;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
}

.btn-large {
  padding: 12px 20px;
  font-size: 0.92rem;
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
  padding: 0;
  font-size: 0.75rem;
}

.btn-text:hover {
  color: var(--text-main);
}

/* BADGES */
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.1);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 3px 10px;
  border-radius: 20px;
}

.badge-default {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-secondary {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
}

/* PRINTERS TABLE */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.printers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 440px;
}

.printers-table th,
.printers-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.printers-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  background: rgba(15, 23, 42, 0.6);
}

.action-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* DISCOVERY RESULTS */
.scan-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.2);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.88rem;
  color: #22d3ee;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(6, 182, 212, 0.3);
  border-top-color: #22d3ee;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.results-container {
  border-top: 1px solid var(--card-border);
  padding-top: 16px;
}

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

.count-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  opacity: 0.6;
}

.trouble-list {
  text-align: left;
  margin-top: 12px;
  padding-left: 20px;
  font-size: 0.85rem;
  line-height: 1.6;
}

.printers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.printer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  padding: 12px 16px;
  border-radius: 8px;
  flex-wrap: wrap;
  gap: 10px;
}

.printer-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.printer-ip {
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
}

.printer-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.printer-actions {
  display: flex;
  gap: 8px;
}

/* ACTIVE PRINTER DISPLAY */
.active-printer-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  flex-wrap: wrap;
  gap: 4px;
}

.info-label {
  color: var(--text-muted);
}

.info-value {
  font-weight: 600;
}

.test-buttons-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

/* LOG CONTAINER */
.log-container {
  background: #090d16;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--card-border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.log-output {
  padding: 12px;
  max-height: 180px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-entry {
  padding: 4px 8px;
  border-radius: 4px;
}

.system-entry {
  color: var(--text-muted);
}

.success-entry {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border-left: 3px solid var(--success);
}

.error-entry {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-left: 3px solid var(--danger);
}

/* MODALS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 12, 22, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: modalSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card-danger {
  border-color: rgba(239, 68, 68, 0.3);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-group h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body-form,
.modal-body-content {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 16px;
  flex-wrap: wrap;
}

.text-highlight {
  color: var(--primary);
}

.text-warning-sm {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.text-danger {
  color: #f87171;
}

.hidden {
  display: none !important;
}

.margin-top-md {
  margin-top: 14px;
}

.app-footer {
  margin-top: 36px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES
   ========================================================================== */
@media (max-width: 992px) {
  body {
    padding: 16px;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-controls {
    width: 100%;
    justify-content: space-between;
  }
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .btn-large {
    width: 100%;
  }
  .modal-card {
    max-width: 95%;
  }
}
