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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  padding: 20px;
}

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

header {
  text-align: center;
  margin-bottom: 30px;
  position: relative;
}

/* Version Badge */
.version-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  margin-bottom: 15px;
  padding: 8px 15px;
  background: rgba(74, 144, 217, 0.1);
  border: 1px solid rgba(74, 144, 217, 0.3);
  border-radius: 20px;
  font-size: 0.75rem;
}

.version-label {
  background: #4a90d9;
  color: #fff;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.version-image {
  color: #888;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 0.7rem;
}

.version-uptime {
  color: #6b7280;
  font-size: 0.7rem;
}

header h1 {
  font-size: 1.8rem;
  color: #fff;
  margin-bottom: 5px;
}

header .subtitle {
  color: #888;
  font-size: 0.95rem;
  margin-bottom: 15px;
}

/* Quick Actions */
.quick-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
}

.btn-vnc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-vnc:hover {
  background: #15803d;
  transform: translateY(-1px);
}

.btn-vnc svg {
  flex-shrink: 0;
}

/* Presets Section */
.presets-section {
  margin-bottom: 30px;
}

.presets-section h2 {
  font-size: 1rem;
  color: #888;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.preset-card {
  background: #252540;
  border: 2px solid #333;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.preset-card:hover {
  border-color: #4a90d9;
  background: #2a2a4a;
}

.preset-card.active {
  border-color: #4a90d9;
  background: #2a3a5a;
}

.preset-name {
  display: block;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.preset-desc {
  display: block;
  font-size: 0.8rem;
  color: #888;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
  border-bottom: 2px solid #333;
  padding-bottom: 5px;
}

.tabs button {
  background: transparent;
  border: none;
  color: #888;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 0.95rem;
  border-radius: 6px 6px 0 0;
  transition: all 0.2s;
}

.tabs button:hover {
  color: #fff;
  background: #252540;
}

.tabs button.active {
  color: #4a90d9;
  background: #252540;
  font-weight: 600;
}

/* Tab Content */
.tab-content {
  background: #252540;
  border-radius: 8px;
  padding: 25px;
  margin-bottom: 20px;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Form Groups */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 500;
  color: #ccc;
}

.form-group input {
  background: #1a1a2e;
  border: 2px solid #333;
  border-radius: 6px;
  padding: 12px;
  color: #fff;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #4a90d9;
}

.form-group input:invalid {
  border-color: #d94a4a;
}

.form-group .hint {
  font-size: 0.8rem;
  color: #666;
}

.restart-badge {
  display: inline-block;
  background: #d9944a;
  color: #1a1a2e;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  margin-top: 5px;
  width: fit-content;
}

/* Actions */
.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-save, .btn-reset {
  padding: 12px 30px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-save {
  background: #4a90d9;
  color: #fff;
}

.btn-save:hover:not(:disabled) {
  background: #3a7bc8;
}

.btn-save:disabled {
  background: #333;
  color: #666;
  cursor: not-allowed;
}

.btn-reset {
  background: transparent;
  color: #888;
  border: 2px solid #444;
}

.btn-reset:hover {
  border-color: #666;
  color: #ccc;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  background: #2d8a4e;
}

.toast.error {
  background: #a83232;
}

/* Logs Panel */
.logs-panel {
  gap: 10px;
}

.logs-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #333;
}

.log-filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  color: #888;
  font-size: 0.85rem;
}

.filter-btn {
  background: #1a1a2e;
  border: 1px solid #333;
  color: #888;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

.filter-btn.active {
  background: #4a90d9;
  border-color: #4a90d9;
  color: #fff;
}

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

.btn-small {
  background: #333;
  border: none;
  color: #ccc;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-small:hover {
  background: #444;
  color: #fff;
}

.btn-tiny {
  background: #333;
  border: none;
  color: #ccc;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
}

.btn-tiny:hover {
  background: #444;
  color: #fff;
}

.btn-vnc-tuner {
  background: #1e3a5f;
  color: #93c5fd;
}

.btn-vnc-tuner:hover {
  background: #2563eb;
  color: #fff;
}

.btn-reset-tuner {
  background: #4a4a4a;
  color: #ccc;
  font-size: 14px;
  padding: 2px 6px;
}

.btn-reset-tuner:hover {
  background: #b91c1c;
  color: #fff;
}

.tuner-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.login-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}

.login-dot.logged-in {
  background: #22c55e;
  box-shadow: 0 0 4px #22c55e;
}

.login-dot.needs-login {
  background: #ef4444;
  box-shadow: 0 0 4px #ef4444;
}

.btn-danger {
  background: #991b1b;
  color: #fca5a5;
  margin-top: 10px;
}

.btn-danger:hover {
  background: #b91c1c;
  color: #fff;
}

.btn-danger:disabled {
  background: #4b1c1c;
  color: #666;
  cursor: not-allowed;
}

.auto-scroll-label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
}

.auto-scroll-label input {
  cursor: pointer;
}

.logs-container {
  background: #0d0d1a;
  border-radius: 6px;
  padding: 10px;
  height: 400px;
  overflow-y: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
}

.logs-container::-webkit-scrollbar {
  width: 8px;
}

.logs-container::-webkit-scrollbar-track {
  background: #1a1a2e;
  border-radius: 4px;
}

.logs-container::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

.logs-container::-webkit-scrollbar-thumb:hover {
  background: #444;
}

.log-line {
  display: flex;
  gap: 10px;
  padding: 3px 5px;
  border-radius: 3px;
}

.log-line:hover {
  background: rgba(255, 255, 255, 0.05);
}

.log-time {
  color: #666;
  flex-shrink: 0;
  min-width: 80px;
}

.log-level {
  flex-shrink: 0;
  min-width: 50px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
}

.log-message {
  color: #ccc;
  word-break: break-all;
}

.log-info .log-level {
  background: #1e40af;
  color: #93c5fd;
}

.log-error .log-level {
  background: #991b1b;
  color: #fca5a5;
}

.log-error .log-message {
  color: #fca5a5;
}

.log-debug .log-level {
  background: #065f46;
  color: #6ee7b7;
}

.log-debug .log-message {
  color: #6ee7b7;
}

.log-warn .log-level {
  background: #92400e;
  color: #fcd34d;
}

.log-warn .log-message {
  color: #fcd34d;
}

.logs-empty {
  color: #666;
  text-align: center;
  padding: 50px 20px;
}

/* Status Panel */
.status-panel {
  padding: 20px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.status-card {
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 15px;
}

.status-card-wide {
  grid-column: 1 / -1;
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #333;
}

.status-header h3 {
  font-size: 0.95rem;
  color: #fff;
  margin: 0;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
}

.badge-ok {
  background: #166534;
  color: #4ade80;
}

.badge-warning {
  background: #92400e;
  color: #fcd34d;
}

.badge-off {
  background: #374151;
  color: #9ca3af;
}

.status-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-body p {
  color: #aaa;
  font-size: 0.85rem;
  margin: 0;
}

.status-progress {
  color: #60a5fa !important;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.btn-vnc-small {
  background: #16a34a;
  color: #fff;
  margin-top: 8px;
}

.btn-vnc-small:hover {
  background: #15803d;
}

.btn-warning {
  background: #b45309;
  color: #fef3c7;
}

.btn-warning:hover {
  background: #d97706;
  color: #fff;
}

.btn-warning:disabled {
  background: #78350f;
  color: #666;
  cursor: not-allowed;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.tuner-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #2a2a4a;
}

.tuner-item:last-child {
  border-bottom: none;
}

.tuner-id {
  color: #ccc;
  font-weight: 500;
}

.tuner-status {
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 4px;
}

.tuner-status.streaming {
  background: #1e40af;
  color: #93c5fd;
}

.tuner-status.idle {
  background: #374151;
  color: #9ca3af;
}

.tuner-status.error {
  background: #991b1b;
  color: #fca5a5;
  animation: pulse 1.5s infinite;
}

.tuner-channel {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.channel-num {
  background: #4a90d9;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.8rem;
}

.channel-name {
  color: #ccc;
  font-size: 0.85rem;
}

.automation-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.auto-name {
  color: #ccc;
}

.auto-status {
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 4px;
  font-weight: 500;
}

.auto-status.running {
  background: #166534;
  color: #4ade80;
}

.auto-status.stopped {
  background: #374151;
  color: #9ca3af;
}

.status-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* System Banner */
.system-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-weight: 500;
}

.system-banner.ready {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.system-banner.not-ready {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #fcd34d;
}

.status-icon {
  font-size: 1.2rem;
}

.status-text {
  font-size: 0.95rem;
}

/* URL Box */
.url-box {
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}

.url-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.url-item:last-child {
  margin-bottom: 0;
}

.url-item label {
  color: #888;
  font-size: 0.85rem;
  min-width: 100px;
}

.url-copy {
  display: flex;
  flex: 1;
  gap: 8px;
}

.url-copy input {
  flex: 1;
  background: #252540;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 8px 12px;
  color: #ccc;
  font-size: 0.85rem;
  font-family: 'Monaco', 'Menlo', monospace;
}

.btn-copy {
  background: #4a90d9;
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-copy:hover {
  background: #3a7bc8;
}

/* Responsive */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }

  .presets-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .tabs button {
    flex: 1;
    min-width: 70px;
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .actions {
    flex-direction: column;
  }

  .btn-save, .btn-reset {
    width: 100%;
  }

  .logs-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .logs-container {
    height: 300px;
  }
}

/* GPU Status Styles */
.gpu-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gpu-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #4ade80;
}

.gpu-icon {
  font-size: 1.3rem;
}

.gpu-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gpu-stat {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gpu-stat label {
  min-width: 70px;
  font-size: 0.85rem;
  color: #888;
}

.gpu-stat .stat-value {
  min-width: 60px;
  text-align: right;
  font-size: 0.85rem;
  color: #ccc;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #252540;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4ade80, #22c55e);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-fill.encoder {
  background: linear-gradient(90deg, #60a5fa, #3b82f6);
}

.progress-fill.memory {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.gpu-details {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  padding-top: 8px;
  border-top: 1px solid #333;
}

.gpu-detail {
  display: flex;
  gap: 5px;
  font-size: 0.85rem;
}

.detail-label {
  color: #888;
}

.detail-value {
  color: #ccc;
  font-weight: 500;
}

.detail-value.hot {
  color: #ef4444;
}

.gpu-encoder-info {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px;
  background: #1a1a2e;
  border-radius: 6px;
  font-size: 0.85rem;
}

.encoder-label {
  color: #60a5fa;
  font-weight: 600;
}

.encoder-setting {
  color: #888;
}

.encoder-setting strong {
  color: #ccc;
}

.gpu-cpu-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9ca3af;
  font-size: 0.95rem;
}

.cpu-icon {
  font-size: 1.2rem;
}

.gpu-hint {
  color: #6b7280;
  font-size: 0.85rem;
  margin-top: 5px;
}

.gpu-hint code {
  background: #252540;
  padding: 2px 6px;
  border-radius: 4px;
  color: #60a5fa;
}

/* Tuner Legend */
.tuner-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: #1a1a2e;
  border-radius: 6px;
  font-size: 0.75rem;
  color: #888;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-icon {
  font-size: 0.7rem;
  color: #666;
  font-weight: 600;
}

.btn-cache-tuner {
  background: #4a4a4a;
  color: #ccc;
  font-size: 0.7rem;
}

.btn-cache-tuner:hover {
  background: #f59e0b;
  color: #000;
}


/* Encoding Settings Tab */
.settings-info {
  background: rgba(74, 144, 217, 0.1);
  border: 1px solid rgba(74, 144, 217, 0.3);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

.settings-info p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.settings-info .info-note {
  margin-top: 10px;
  color: #fbbf24;
  font-size: 0.85rem;
}

.setting-help {
  margin-top: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid #4a90d9;
  border-radius: 0 6px 6px 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #aaa;
}

.setting-help strong {
  color: #ddd;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #4a90d9;
}

.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: #2a2a3e;
  border: 1px solid #444;
  border-radius: 6px;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

.form-group select:focus {
  outline: none;
  border-color: #4a90d9;
}

.form-group select option {
  background: #2a2a3e;
  color: #fff;
}



/* Encoding Actions */
.encoding-actions {
  margin-top: 30px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #333;
  border-radius: 8px;
}

.encoding-actions h3 {
  margin: 0 0 10px 0;
  font-size: 1rem;
  color: #fff;
}

.encoding-actions .action-note {
  margin: 0 0 15px 0;
  font-size: 0.85rem;
  color: #888;
}

.btn-restart-streams {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f59e0b;
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-restart-streams:hover:not(:disabled) {
  background: #d97706;
  transform: translateY(-1px);
}

.btn-restart-streams:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

