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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #d2d2d7;
}

h1 {
  font-size: 1.75rem;
  font-weight: 600;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #1d1d1f;
}

section {
  margin-bottom: 2rem;
}

.section-desc {
  font-size: 0.875rem;
  color: #6e6e73;
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #0071e3;
  color: white;
}

.btn-primary:hover {
  background: #0077ed;
}

.btn-secondary {
  background: #e8e8ed;
  color: #1d1d1f;
}

.btn-secondary:hover {
  background: #d2d2d7;
}

.btn-success {
  background: #34c759;
  color: white;
}

.btn-success:hover {
  background: #30b350;
}

.btn-danger {
  background: #ff3b30;
  color: white;
}

.btn-danger:hover {
  background: #e6352b;
}

.btn-warning {
  background: #ff9500;
  color: white;
}

.btn-warning:hover {
  background: #e68600;
}

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

/* Jobs Grid */
.jobs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1rem;
}

.job-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.job-card.disabled {
  opacity: 0.6;
}

.job-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.job-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.job-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.job-status.success {
  background: #d1f2d9;
  color: #1a7f37;
}

.job-status.failed {
  background: #ffd7d5;
  color: #cf222e;
}

.job-status.running {
  background: #ddf4ff;
  color: #0969da;
}

.job-status.never {
  background: #e8e8ed;
  color: #6e6e73;
}

.job-details {
  font-size: 0.875rem;
  color: #6e6e73;
  margin-bottom: 1rem;
}

.job-details p {
  margin-bottom: 0.35rem;
  word-break: break-all;
}

.job-details strong {
  color: #1d1d1f;
}

.job-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pending-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  background: #fff3cd;
  color: #856404;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}

.pending-badge:hover {
  background: #ffe69c;
}

/* History List */
.history-list {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid #e8e8ed;
}

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

.history-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.history-status.success {
  background: #34c759;
}

.history-status.failed {
  background: #ff3b30;
}

.history-status.running {
  background: #007aff;
  animation: pulse 1.5s infinite;
}

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

.history-info {
  flex: 1;
}

.history-job {
  font-weight: 500;
  color: #1d1d1f;
}

.history-time {
  font-size: 0.8rem;
  color: #6e6e73;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #6e6e73;
}

/* Pending List */
.pending-list {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.pending-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #e8e8ed;
}

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

.pending-icon {
  font-size: 1.25rem;
}

.pending-info {
  flex: 1;
  min-width: 0;
}

.pending-file {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.8rem;
  color: #1d1d1f;
  word-break: break-all;
}

.pending-meta {
  font-size: 0.75rem;
  color: #6e6e73;
}

.pending-countdown {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  background: #fff3cd;
  color: #856404;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.pending-countdown.urgent {
  background: #ffd7d5;
  color: #cf222e;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-large {
  max-width: 700px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e8e8ed;
}

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

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e8e8ed;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #6e6e73;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.close-btn:hover {
  color: #1d1d1f;
}

/* Form */
form {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: #1d1d1f;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: #0071e3;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
}

.help-text {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: #6e6e73;
}

.help-text code {
  background: #e8e8ed;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, monospace;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e8e8ed;
}

/* Runs Content */
.runs-content,
.pending-modal-content {
  padding: 1rem;
  max-height: 60vh;
  overflow-y: auto;
}

.run-item {
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: #f5f5f7;
  border-radius: 8px;
}

.run-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.run-time {
  font-weight: 500;
}

.run-output {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #1d1d1f;
  color: #f5f5f7;
  border-radius: 6px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 150px;
  overflow-y: auto;
}

.run-error {
  background: #3d1a1a;
  color: #ff8080;
}

/* Responsive */
@media (max-width: 640px) {
  .container {
    padding: 1rem;
  }

  header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

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

/* Progress Bar */
.progress-container {
  margin-bottom: 1rem;
}

.progress-bar {
  height: 8px;
  background: #e8e8ed;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.progress-bar-fill {
  height: 100%;
  background: #0071e3;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-bar-fill.indeterminate {
  width: 30% !important;
  animation: indeterminate 1.5s infinite ease-in-out;
}

.progress-bar-fill.complete {
  background: #34c759;
}

.progress-bar-fill.failed {
  background: #ff3b30;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.progress-text {
  font-size: 0.75rem;
  color: #6e6e73;
}

/* Textarea */
textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'SF Mono', Monaco, monospace;
  resize: vertical;
  transition: border-color 0.2s;
}

textarea:focus {
  outline: none;
  border-color: #0071e3;
}

/* Excludes Badge */
.excludes-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.4rem;
  background: #e8e8ed;
  color: #6e6e73;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-left: 0.5rem;
}

/* Schedule Picker */
.schedule-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.schedule-picker select {
  padding: 0.5rem;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  font-size: 0.875rem;
  background: white;
}

.schedule-picker span {
  color: #6e6e73;
  font-size: 0.875rem;
}

.time-picker {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.weekday-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.5rem;
}

.weekday-picker label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: normal;
  cursor: pointer;
}

.weekday-picker input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

.hourly-picker {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Header Actions */
.header-actions {
  display: flex;
  gap: 0.5rem;
}

/* Password input */
input[type="password"],
input[type="email"] {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

input[type="password"]:focus,
input[type="email"]:focus {
  outline: none;
  border-color: #0071e3;
}

/* Run Stats */
.run-stats {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Run Stats Line in History */
.run-stats-line {
  padding: 0.5rem 0;
  color: #2e7d32;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Smaller modal form */
.modal-content {
  font-size: 0.85rem;
}

.modal-content label {
  font-size: 0.8rem;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
  font-size: 0.8rem;
  padding: 0.5rem 0.65rem;
}

.modal-content .help-text {
  font-size: 0.7rem;
}

.modal-content h3 {
  font-size: 1.1rem;
}

.modal-content .btn {
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
}

.modal-content .form-group {
  margin-bottom: 0.75rem;
}

.schedule-picker select {
  font-size: 0.8rem;
  padding: 0.4rem;
}

.schedule-picker span {
  font-size: 0.8rem;
}

.weekday-picker label {
  font-size: 0.75rem;
}

.time-picker select {
  font-size: 0.8rem;
}

/* Warning/Stop Button */
.btn-warning {
  background: #ff9500;
  color: white;
}

.btn-warning:hover {
  background: #e88600;
}

.btn-warning:disabled {
  background: #ccc;
}

/* Stopped progress bar */
.progress-bar-fill.stopped {
  background: #ff9500;
}

/* Stopped status badge */
.job-status.stopped {
  background: #fff3e0;
  color: #e65100;
}

/* Dashboard */
.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.dashboard-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  padding: 1.25rem;
  color: white;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.dashboard-card.success {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  box-shadow: 0 4px 15px rgba(17, 153, 142, 0.3);
}

.dashboard-card.success:hover {
  box-shadow: 0 6px 20px rgba(17, 153, 142, 0.4);
}

.dashboard-icon {
  font-size: 1.75rem;
  opacity: 0.9;
}

.dashboard-content {
  flex: 1;
}

.dashboard-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.dashboard-label {
  font-size: 0.75rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

.running-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* Responsive dashboard */
@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .dashboard-card {
    padding: 1rem;
  }
  
  .dashboard-value {
    font-size: 1.25rem;
  }
  
  .dashboard-icon {
    font-size: 1.5rem;
  }
}

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

/* Circular Dial Cards */
.dial-card {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.dial-container {
  position: relative;
  width: 80px;
  height: 80px;
}

.dial {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.dial-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 8;
}

.dial-fill {
  fill: none;
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.running-fill {
  stroke: #4ade80;
}

.running-card .dial-fill.active {
  animation: dial-pulse 1.5s ease-in-out infinite;
}

@keyframes dial-pulse {
  0%, 100% { stroke: rgba(255, 255, 255, 0.9); }
  50% { stroke: #4ade80; }
}

.dial-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: 700;
}

.dial-label {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  opacity: 0.85;
  text-align: center;
}

/* Scheduler Toggle */
.scheduler-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.toggle-label {
  font-size: 0.8rem;
  color: #6e6e73;
  font-weight: 500;
}

.toggle-label.paused {
  color: #ff9500;
}

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

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

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

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #34c759;
}

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

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Help Modal */
.help-content {
  padding: 1rem 1.5rem;
}

.help-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #e5e5ea;
}

.help-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.help-section h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  color: #1d1d1f;
}

.help-commands {
  background: #1d1d1f;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
}

.help-commands code {
  display: block;
  color: #4ade80;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: nowrap;
}

.help-commands code:before {
  content: '$ ';
  color: #6e6e73;
}

.help-note {
  margin: 0.5rem 0 0 0;
  font-size: 0.8rem;
  color: #6e6e73;
}

/* Toggle output button */
.toggle-output {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  margin-left: auto;
}

.run-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f5f5f7;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: white;
  padding: 3rem;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  text-align: center;
  max-width: 350px;
  width: 90%;
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.login-box h2 {
  margin-bottom: 1.5rem;
  color: #1d1d1f;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-box input {
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border: 2px solid #e5e5ea;
  border-radius: 8px;
  text-align: center;
}

.login-box input:focus {
  outline: none;
  border-color: #007aff;
}

.login-box button {
  padding: 0.875rem;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.login-box button:hover {
  opacity: 0.9;
}

.login-box .error-message {
  color: #ff3b30;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Client Codes Section */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.client-codes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.client-code-card {
  background: white;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.client-code-info {
  flex: 1;
}

.client-code-name {
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 0.25rem;
}

.client-code-details {
  font-size: 0.85rem;
  color: #6e6e73;
}

.client-code-value {
  font-family: monospace;
  background: #f0f0f0;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.5rem;
}

.client-code-actions {
  display: flex;
  gap: 0.5rem;
}

.empty-codes {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  color: #6e6e73;
}
