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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

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

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

header h1 {
  font-size: 2rem;
  color: #1a1a2e;
  margin-bottom: 5px;
}

.subtitle {
  color: #666;
  font-size: 1rem;
}

/* Measure Control */
.measure-control {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.measure-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.measure-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.measure-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.measure-btn.running {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.measure-btn.running .btn-icon {
  animation: pulse 1s infinite;
}

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

.btn-icon {
  font-size: 0.9rem;
}

.measure-options {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.measure-option {
  display: flex;
  align-items: center;
  gap: 12px;
}

.measure-hint {
  font-size: 0.85rem;
  color: #888;
}

.measure-divider {
  color: #999;
  font-size: 0.9rem;
}

.custom-url-section {
  flex: 1;
  min-width: 300px;
}

.url-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.url-input-row input {
  flex: 1;
  padding: 12px 15px;
  font-size: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  transition: border-color 0.2s;
}

.url-input-row input:focus {
  outline: none;
  border-color: #667eea;
}

.url-input-row input::placeholder {
  color: #aaa;
}

.add-url-btn {
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  color: #667eea;
  background: #fff;
  border: 2px solid #667eea;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.add-url-btn:hover {
  background: #667eea;
  color: #fff;
}

.url-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.url-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f0f4ff;
  border: 1px solid #667eea;
  border-radius: 20px;
  font-size: 0.9rem;
  color: #333;
  max-width: 100%;
}

.url-tag-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 250px;
}

.url-tag-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #667eea;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.2s;
}

.url-tag-remove:hover {
  background: #ff4e42;
}

.url-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.url-count {
  font-size: 0.9rem;
  color: #666;
}

.clear-urls-btn {
  padding: 8px 16px;
  font-size: 0.9rem;
  color: #888;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-urls-btn:hover {
  background: #ff4e42;
  color: #fff;
  border-color: #ff4e42;
}

.measure-btn.custom-btn {
  white-space: nowrap;
}

.measure-status {
  margin-top: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 4px solid #667eea;
}

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

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ccc;
}

.status-indicator.running {
  background: #ffa400;
  animation: blink 1s infinite;
}

.status-indicator.completed {
  background: #0cce6b;
}

.status-indicator.error {
  background: #ff4e42;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-text {
  font-weight: 600;
  color: #333;
}

.status-output {
  max-height: 200px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.85rem;
  color: #555;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Loading & Error */
.loading {
  text-align: center;
  padding: 40px;
  font-size: 1.2rem;
  color: #666;
}

.error {
  background: #fee;
  border: 1px solid #fcc;
  color: #c33;
  padding: 20px;
  border-radius: 8px;
  margin: 20px 0;
}

/* Meta Info */
.meta-info {
  display: flex;
  gap: 30px;
  justify-content: center;
  flex-wrap: wrap;
  background: #fff;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.meta-item {
  display: flex;
  gap: 8px;
  align-items: center;
}

.meta-label {
  color: #666;
  font-size: 0.9rem;
}

.meta-value {
  font-weight: 600;
  color: #333;
}

/* URL Selector */
.url-selector {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.url-selector label {
  font-weight: 600;
  color: #333;
}

.url-selector select {
  flex: 1;
  min-width: 300px;
  padding: 10px 15px;
  font-size: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.url-selector select:focus {
  outline: none;
  border-color: #4a90d9;
}

.sort-options {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.sort-options label {
  font-size: 0.9rem;
  color: #666;
}

.sort-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.sort-btn:hover {
  background: #f0f0f0;
}

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

/* KPI Cards */
.kpi-section {
  margin-bottom: 20px;
}

.kpi-section h2 {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 15px;
}

.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.kpi-card {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  text-align: center;
}

.kpi-card.score-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.kpi-card.score-card .kpi-label {
  color: rgba(255,255,255,0.9);
}

.kpi-card.score-card .kpi-range {
  color: rgba(255,255,255,0.8);
}

.kpi-label {
  font-size: 0.85rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: #333;
}

.kpi-card.score-card .kpi-value {
  color: #fff;
}

.kpi-range,
.kpi-sub {
  font-size: 0.85rem;
  color: #888;
  margin-top: 5px;
}

/* Score colors */
.score-good { color: #0cce6b; }
.score-moderate { color: #ffa400; }
.score-poor { color: #ff4e42; }

/* Chart Section */
.chart-section {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.chart-section h2 {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 15px;
}

.chart-container {
  width: 100%;
  overflow-x: auto;
}

.chart-container canvas {
  max-width: 100%;
  height: auto;
}

/* Table Section */
.table-section,
.overview-section {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.table-section h2,
.overview-section h2 {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 15px;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

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

th {
  background: #f8f9fa;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

tr:hover {
  background: #f8f9fa;
}

td a {
  color: #4a90d9;
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}

.failed {
  color: #c33;
  font-style: italic;
}

/* Overview table URL column */
.overview-section td:first-child {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Footer */
footer {
  text-align: center;
  padding: 20px;
  color: #666;
  font-size: 0.9rem;
}

footer code {
  background: #e8e8e8;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

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

/* Responsive */
@media (max-width: 768px) {
  .url-selector {
    flex-direction: column;
    align-items: stretch;
  }

  .url-selector select {
    min-width: 100%;
  }

  .sort-options {
    margin-left: 0;
    justify-content: flex-start;
  }

  .meta-info {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .kpi-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}
