:root {
  --primary: #004b87;
  --primary-hover: #003866;
  --accent: #00a8cc;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  background: linear-gradient(135deg, #003366 0%, #004b87 100%);
  color: #ffffff;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 51, 102, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-badge {
  background: #facc15;
  color: #003366;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: #bae6fd;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.12);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  transition: all 0.2s ease;
}

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

.status-connected {
  background: #dcfce7;
  color: #15803d;
}
.status-connected .dot {
  background: #16a34a;
}

.status-waiting {
  background: #fef3c7;
  color: #b45309;
}
.status-waiting .dot {
  background: #d97706;
}

.status-disconnected {
  background: #fee2e2;
  color: #b91c1c;
}
.status-disconnected .dot {
  background: #dc2626;
}


/* Page Navigation Switcher */
.nav-pages-container {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  background: #e2e8f0;
  padding: 6px;
  border-radius: 12px;
}

.nav-page-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  color: #475569;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-page-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  color: #1e293b;
}

.nav-page-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
/* Layout */
.container {
  max-width: 1360px;
  width: 100%;
  margin: 1.75rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Card */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-header {
  padding: 1.1rem 1.4rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title .icon {
  font-size: 1.15rem;
}

.card-body {
  padding: 1.4rem;
  flex: 1;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  background: #e2e8f0;
  color: #475569;
}

.badge-info {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-success {
  background: #dcfce7;
  color: #15803d;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem 1.25rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-large {
  width: 100%;
  padding: 0.95rem 1.5rem;
  font-size: 1rem;
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}
.btn-success:hover {
  background: #059669;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #f1f5f9;
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid #fca5a5;
  color: #dc2626;
}
.btn-danger-outline:hover {
  background: #fee2e2;
}

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

/* Steps Pipeline UI */
.steps-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.2rem 0;
  padding: 0.9rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.step-num {
  width: 26px;
  height: 26px;
  background: var(--primary);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.step-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
}

.step-arrow {
  color: #94a3b8;
  font-weight: bold;
}

/* QR Code Section */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.qr-instruction {
  font-size: 0.88rem;
  color: #334155;
  margin-bottom: 1rem;
}

.qr-box {
  padding: 10px;
  background: #ffffff;
  border: 2px dashed #0284c7;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.1);
  display: inline-block;
}

.qr-box img {
  width: 220px;
  height: 220px;
  display: block;
}

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

/* Connected State */
.connected-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  padding: 1rem 0;
}

.user-avatar {
  width: 60px;
  height: 60px;
  background: #dcfce7;
  color: #16a34a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: bold;
  border: 2px solid #86efac;
}

.user-meta h3 {
  font-size: 1.15rem;
  color: #1e293b;
}

.user-meta p {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.user-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 0;
  gap: 0.75rem;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.small-spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

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

.status-callout {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  margin-top: 1rem;
  font-size: 0.88rem;
  color: #1e40af;
  font-weight: 500;
}

/* Form controls */
.form-group {
  margin-bottom: 1.1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}

.form-input, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 75, 135, 0.15);
}

.form-textarea {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}

.grid-2-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.input-unit {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.input-unit input {
  flex: 1;
  border: none;
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.input-unit span {
  background: #f8fafc;
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
}

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

/* Switch Toggle */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: 0.25s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--success);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Tab Group */
.tab-group {
  display: flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 1.1rem;
}

.tab-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chip-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chip {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}
.chip:hover {
  background: #e2e8f0;
}

.checkbox-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #334155;
  cursor: pointer;
}

.next-run-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
}

.next-run-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #166534;
}

.next-run-time {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.9rem;
  color: #14532d;
}

.countdown-badge {
  background: #16a34a;
  color: #ffffff;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

/* Preview Section */
.preview-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.preview-tab {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.preview-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.preview-container img {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  object-position: top;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  cursor: zoom-in;
  display: block;
}

.preview-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
}

.rekap-text-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  max-height: 380px;
  overflow-y: auto;
}

.rekap-text-box pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #1e293b;
}

/* Console Box */
.console-box {
  background: #0f172a;
  color: #f8fafc;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  padding: 1rem;
  border-radius: 8px;
  height: 380px;
  overflow-y: auto;
  line-height: 1.6;
}

.log-line {
  margin-bottom: 0.25rem;
  word-break: break-word;
}

.text-muted {
  color: #94a3b8;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

@media (max-width: 860px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
