:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --sidebar-bg: rgba(246, 246, 248, 0.8);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --border: rgba(0, 0, 0, 0.08);
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --danger: #ff3b30;
  --warning: #ff9500;
  --success: #34c759;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e20;
    --bg-elevated: #2c2c2e;
    --sidebar-bg: rgba(30, 30, 32, 0.8);
    --text: #f5f5f7;
    --text-secondary: #9a9a9e;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Titlebar tipo ventana de macOS --- */
.titlebar {
  height: 44px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.traffic-lights { display: flex; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.red { background: #ff5f57; } .dot.yellow { background: #febc2e; } .dot.green { background: #28c840; }
.titlebar-title { font-weight: 600; font-size: 13px; color: var(--text-secondary); }
.titlebar-status { margin-left: auto; font-size: 12px; color: var(--text-secondary); }
.titlebar-status.ready { color: var(--success); }
.titlebar-status.blocked { color: var(--danger); }

/* --- Layout --- */
.app-shell { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 240px;
  flex: 0 0 auto;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  overflow-y: auto;
}
.sidebar-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-item:hover { background: rgba(0,0,0,0.05); }
.sidebar-item.active { background: var(--accent); color: white; }
.sidebar-item .icon { font-size: 14px; }
.sidebar-heading { margin: 18px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
.past-runs-list { display: flex; flex-direction: column; gap: 2px; }
.past-run-item {
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px; color: var(--text);
  display: flex; flex-direction: column; gap: 2px;
}
.past-run-item:hover { background: rgba(0,0,0,0.05); }
.past-run-item .prl-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.past-run-item .prl-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.past-run-item .prl-meta { color: var(--text-secondary); font-size: 11px; }
.prl-delete {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.past-run-item:hover .prl-delete { opacity: 1; }
.prl-delete:hover { background: rgba(255, 59, 48, 0.15); color: var(--danger); }

.content { flex: 1; overflow-y: auto; padding: 28px 36px 60px; }
.view.hidden { display: none; }

.view-header { max-width: 760px; margin-bottom: 20px; }
.view-header h1 { font-size: 26px; margin: 0 0 6px; }
.subtitle { color: var(--text-secondary); font-size: 14px; line-height: 1.5; margin: 0; }

.card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  max-width: 760px;
  margin-bottom: 18px;
}

.field-group { margin-bottom: 18px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.02em; }

input[type="text"], input[type="url"] {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
input[type="text"]:focus, input[type="url"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-hint { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

/* --- Segmented control tipo macOS --- */
.segmented {
  display: inline-flex;
  background: var(--bg);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.segmented-item {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.segmented-item.active { background: var(--bg-elevated); box-shadow: 0 1px 2px rgba(0,0,0,0.15); font-weight: 600; }

/* --- Toggle tipo macOS --- */
.toggle-row { display: flex; align-items: flex-start; gap: 12px; }
.toggle { position: relative; display: inline-block; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track { display: block; width: 40px; height: 24px; background: #d1d1d6; border-radius: 999px; position: relative; transition: background 0.2s; }
.toggle input:checked + .toggle-track { background: var(--success); }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: white; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle-label { font-size: 13.5px; font-weight: 600; }

.muted { color: var(--text-secondary); }
.small { font-size: 12px; }

.primary-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.primary-button:hover { filter: brightness(1.08); }
.primary-button:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  margin-right: 10px;
}
.secondary-button:hover { background: var(--accent-soft); }

.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; }

.banner {
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.banner-warning { background: rgba(255, 149, 0, 0.12); color: #a35b00; border: 1px solid rgba(255, 149, 0, 0.3); }
@media (prefers-color-scheme: dark) { .banner-warning { color: #ffb340; } }
.banner code { background: rgba(0,0,0,0.08); padding: 1px 5px; border-radius: 4px; }

/* --- Progreso --- */
.progress-bar-track { width: 100%; height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.progress-bar-fill { height: 100%; width: 4%; background: linear-gradient(90deg, var(--accent), #34aaff); border-radius: 999px; transition: width 0.4s ease; }
.progress-stats { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 14px; }
.log-card { max-height: 320px; display: flex; flex-direction: column; }
.live-log { flex: 1; overflow-y: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.6; color: var(--text-secondary); white-space: pre-wrap; }

/* --- Reporte --- */
.launch-badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; margin-bottom: 10px; }
.launch-badge.ready { background: rgba(52,199,89,0.15); color: #1a7f37; }
.launch-badge.not-ready { background: rgba(255,59,48,0.12); color: #c00; }

.export-card { display: flex; gap: 8px; align-items: center; padding: 14px 24px; }

.findings-list { display: flex; flex-direction: column; gap: 14px; max-width: 820px; }
.finding-card { background: var(--bg-elevated); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.finding-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sev-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; letter-spacing: 0.03em; }
.sev-critical { background: rgba(255,59,48,0.15); color: #c00; }
.sev-high { background: rgba(255,149,0,0.15); color: #a35b00; }
.sev-medium { background: rgba(255,204,0,0.18); color: #8a7300; }
.sev-low { background: rgba(52,199,89,0.15); color: #1a7f37; }
.sev-cosmetic { background: rgba(142,142,147,0.15); color: #666; }
.finding-area { font-size: 12px; color: var(--text-secondary); }
.finding-title { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.finding-row { font-size: 13px; margin-bottom: 6px; line-height: 1.5; }
.finding-row b { color: var(--text-secondary); font-weight: 600; }
.finding-shots { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.finding-shots img { height: 90px; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; }
.prompt-box { background: #0d1117; color: #c9d1d9; padding: 12px 14px; border-radius: 9px; font-family: ui-monospace, monospace; font-size: 12px; white-space: pre-wrap; max-height: 160px; overflow-y: auto; margin-top: 8px; }
.copy-button { margin-top: 8px; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; z-index: 999; cursor: zoom-out; }
.lightbox.hidden { display: none; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }

.hidden { display: none !important; }
