:root {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-2: #1f2430;
  --border: #2a3142;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --primary: #4f8cff;
  --primary-hover: #3d7aef;
  --success: #3ecf8e;
  --warning: #f5b942;
  --error: #f56565;
  --info: #63b3ed;
  --radius: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Consolas', monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  min-height: 100vh;
}

.header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

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

.brand-icon {
  font-size: 1.75rem;
  color: var(--primary);
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.mode-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  background: var(--surface-2);
  padding: 0.25rem;
  border-radius: 8px;
  width: fit-content;
}

.mode-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab.active {
  background: var(--primary);
  color: #fff;
}

.hidden {
  display: none !important;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.text-input,
.select-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.text-input:focus,
.select-input:focus {
  outline: none;
  border-color: var(--primary);
}

.text-input.narrow {
  width: 5rem;
}

.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sheet-actions {
  display: flex;
  gap: 0.35rem;
}

.sheet-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  max-height: 280px;
  background: var(--surface-2);
}

.url-sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.url-sheet th {
  text-align: left;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 1;
}

.url-sheet td {
  padding: 0.35rem 0.5rem;
  border-top: 1px solid var(--border);
}

.col-num {
  width: 3rem;
  text-align: center;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.col-actions {
  width: 2.5rem;
}

.url-sheet input {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.url-sheet input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

.row-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 1.1rem;
  line-height: 1;
}

.row-remove:hover {
  color: var(--error);
  background: rgba(245, 101, 101, 0.1);
}

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.options-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.option {
  flex: 0 0 auto;
}

.action-option {
  margin-left: auto;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.form-error {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(245, 101, 101, 0.12);
  border: 1px solid rgba(245, 101, 101, 0.35);
  border-radius: 8px;
  color: var(--error);
  font-size: 0.9rem;
}

.progress-panel {
  text-align: center;
}

.progress-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.progress-fill {
  height: 100%;
  width: 30%;
  background: var(--primary);
  border-radius: 2px;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); width: 30%; }
  50% { width: 60%; }
  100% { transform: translateX(350%); width: 30%; }
}

.progress-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.results-toolbar h2 {
  margin: 0;
  font-size: 1.15rem;
}

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

/* Report styles */
.report-root {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.report-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.report-header h2 {
  margin: 0 0 0.75rem;
  font-size: 1.4rem;
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.report-meta strong {
  color: var(--text);
}

.report-section {
  margin-bottom: 2rem;
}

.report-section > h3 {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  color: var(--text);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.data-table th,
.data-table td {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table tbody tr:hover {
  background: rgba(79, 140, 255, 0.04);
}

.data-table .url-cell {
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
}

.score-good { color: var(--success); font-weight: 600; }
.score-ok { color: var(--warning); font-weight: 600; }
.score-bad { color: var(--error); font-weight: 600; }

.comparison-block {
  margin-bottom: 1.5rem;
}

.comparison-block h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-family: var(--mono);
  word-break: break-all;
}

.url-result {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--border);
}

.url-result:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.url-result > h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-family: var(--mono);
  word-break: break-all;
}

.device-result {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.device-result h4 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.device-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.stat-pills {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-pill {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.stat-pill.passed { background: rgba(62, 207, 142, 0.15); color: var(--success); }
.stat-pill.warnings { background: rgba(245, 185, 66, 0.15); color: var(--warning); }
.stat-pill.errors { background: rgba(245, 101, 101, 0.15); color: var(--error); }

.issues-block {
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  background: rgba(245, 185, 66, 0.08);
  border: 1px solid rgba(245, 185, 66, 0.25);
  border-radius: 8px;
}

.issues-block h5 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--warning);
}

.issue-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.issue-list li {
  padding: 0.3rem 0;
  font-size: 0.9rem;
}

.check-section {
  margin-bottom: 1.25rem;
}

.check-section h5 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.check-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-item {
  padding: 0.4rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(42, 49, 66, 0.5);
}

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

.check-label {
  font-weight: 600;
}

.check-details {
  margin: 0.25rem 0 0 1.5rem;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.check-details li {
  padding: 0.15rem 0;
  word-break: break-all;
}

.status-pass { color: var(--success); }
.status-fail { color: var(--error); }
.status-warn { color: var(--warning); }
.status-info { color: var(--info); }

.page-data {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.page-data h5 {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.page-data dl {
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.page-data dt {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.page-data dd {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  word-break: break-word;
}

.page-data .nested-list {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.match-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.match-badge.match {
  background: rgba(62, 207, 142, 0.15);
  color: var(--success);
}

.match-badge.diff {
  background: rgba(245, 185, 66, 0.15);
  color: var(--warning);
}

@media (max-width: 640px) {
  .main { padding: 1rem; }
  .options-row { flex-direction: column; align-items: stretch; }
  .action-option { margin-left: 0; }
  .btn-primary { width: 100%; justify-content: center; }
}
