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

html {
  font-size: clamp(12px, calc(9px + 0.8vw), 15px);
}

:root {
  --pill-btn-gap: 6px;
  --pill-btn-min-width: clamp(104px, calc(88px + 3vw), 140px);
  --pill-btn-padding-y: clamp(9px, calc(8px + 0.2vw), 11px);
  --pill-btn-padding-x: clamp(16px, calc(12px + 0.9vw), 24px);
  --pill-btn-font-size: clamp(0.8rem, calc(0.74rem + 0.25vw), 0.92rem);
  --pill-btn-min-height: clamp(34px, calc(32px + 0.3vw), 38px);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.tab-initializing .management-tab,
.tab-initializing .tab-button,
.tab-initializing .sub-tab-button {
  transition: none !important;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: #fff;
  border-radius: 15px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: #fff;
  padding: 20px 30px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
}

.header-title {
  font-size: clamp(1.1rem, calc(0.92rem + 0.8vw), 1.4rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.content {
  padding: 20px 30px;
}

.primary-button,
.run-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--pill-btn-gap);
  min-width: var(--pill-btn-min-width);
  padding: var(--pill-btn-padding-y) var(--pill-btn-padding-x);
  border-radius: 999px;
  font-size: var(--pill-btn-font-size);
  min-height: var(--pill-btn-min-height);
  line-height: 1.15;
  font-weight: 600;
  border: none;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #ff8282, #ff4d6d);
  box-shadow: 0 6px 18px rgba(255, 77, 109, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.primary-button:hover,
.run-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(255, 77, 109, 0.35);
}

.run-button:disabled {
  background: #ced4da;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  opacity: 0.7;
}

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

.home-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 8px 14px;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.05);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-logo:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.home-logo-image {
  height: 56px;
  width: auto;
  object-fit: contain;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-start;
  min-height: 48px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.header-nav.nav-ready {
  opacity: 1;
  transform: translateY(0);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: clamp(7px, calc(5px + 0.5vw), 10px) clamp(10px, calc(8px + 0.7vw), 16px);
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  font-size: clamp(0.8rem, calc(0.76rem + 0.25vw), 0.95rem);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.nav-link.active {
  background: #fff;
  color: #0b7285;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(11, 114, 133, 0.25);
  font-weight: 700;
  transform: translateY(-1px);
}

.nav-link.active:hover {
  background: #f1fbfd;
  color: #065268;
}

.nav-link span.icon {
  font-size: clamp(0.95rem, calc(0.9rem + 0.25vw), 1.05rem);
}

.header-brand h1 {
  margin: 0;
}

.logout-button {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: var(--pill-btn-padding-y) clamp(12px, calc(10px + 0.6vw), 16px);
  font-size: var(--pill-btn-font-size);
  border-radius: 8px;
  min-height: var(--pill-btn-min-height);
  line-height: 1.15;
  cursor: pointer;
  transition: all 0.3s ease;
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.status {
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 20px;
  display: none;
}

.status.info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.status.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.status.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.runs-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.runs-table th,
.runs-table td {
  padding: 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.runs-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #495057;
}

.runs-table tr:hover {
  background: #f8f9fa;
}

.status-badge {
  padding: 5px 10px;
  border-radius: 15px;
  font-size: clamp(0.7rem, calc(0.68rem + 0.25vw), 0.85rem);
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.running {
  background: #fff3cd;
  color: #856404;
}

.status-badge.completed {
  background: #d4edda;
  color: #155724;
}

.status-badge.failed {
  background: #f8d7da;
  color: #721c24;
}

.status-badge.cancelled {
  background: #e2e3e5;
  color: #383d41;
}

.status-badge.cancelling {
  background: #e9ecef;
  color: #495057;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--pill-btn-gap);
  min-width: var(--pill-btn-min-width);
  padding: var(--pill-btn-padding-y) var(--pill-btn-padding-x);
  border-radius: 999px;
  background: linear-gradient(135deg, #69db7c, #38d9a9);
  color: #fff;
  text-decoration: none;
  border: none;
  box-shadow: 0 6px 18px rgba(56, 217, 169, 0.25);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-height: var(--pill-btn-min-height);
  line-height: 1.15;
}

.download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(56, 217, 169, 0.35);
}

.download-options {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.details-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: clamp(86px, calc(70px + 3vw), 110px);
  padding: var(--pill-btn-padding-y) clamp(11px, calc(9px + 0.6vw), 15px);
  border-radius: 6px;
  background: #fd7e14;
  color: #fff;
  text-decoration: none;
  border: none;
  font-size: clamp(0.78rem, calc(0.74rem + 0.25vw), 0.9rem);
  min-height: var(--pill-btn-min-height);
  line-height: 1.15;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.details-btn:hover {
  background: #e8590c;
}

.cancel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--pill-btn-gap);
  min-width: var(--pill-btn-min-width);
  padding: var(--pill-btn-padding-y) var(--pill-btn-padding-x);
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #ffc078, #ffa94d);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(255, 169, 77, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-height: var(--pill-btn-min-height);
  line-height: 1.15;
}

.cancel-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(255, 169, 77, 0.35);
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar {
  width: 200px;
  height: 8px;
  background: #f1f3f5;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #4dabf7;
  transition: width 0.4s ease;
}

.progress-loading {
  animation: progressPulse 1.2s infinite ease-in-out;
}

.progress-text {
  font-size: clamp(0.72rem, calc(0.68rem + 0.25vw), 0.86rem);
  color: #495057;
}

.current-script {
  font-size: clamp(0.68rem, calc(0.64rem + 0.2vw), 0.8rem);
  color: #adb5bd;
}

.loading {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

@keyframes progressPulse {
  0% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.7;
  }
}

.panel {
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  border: 1px solid #dee2e6;
  margin-bottom: 20px;
}

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

.panel-title {
  font-size: clamp(1.05rem, calc(0.9rem + 0.75vw), 1.3rem);
  color: #28a745;
}

@media (max-width: 600px) {
  body {
    padding: 16px;
  }

  .header {
    padding: 18px 20px;
  }

  .content {
    padding: 18px 20px;
  }
}

@media (max-width: 480px) {
  .header-title {
    font-size: clamp(1.05rem, calc(0.9rem + 1.2vw), 1.25rem);
  }

  .header-nav {
    gap: 8px;
  }

  .nav-link {
    padding: 6px 12px;
  }

  .primary-button,
  .run-button,
  .download-btn,
  .cancel-btn {
    min-width: 92px;
  }

  .panel {
    padding: 16px;
  }
}
