:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --ink: #17202b;
  --muted: #5d6a7c;
  --line: #dde3ea;
  --brand: #14324a;
  --accent: #1f6fa8;
  --accent-ink: #ffffff;
  --good: #1d7a4c;
  --good-bg: #e3f4ea;
  --warn: #9a5b00;
  --warn-bg: #fdf0d9;
  --bad: #b3261e;
  --bad-bg: #fbe3e1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419; --surface: #182029; --surface-2: #212b36; --ink: #e6ebf1; --muted: #9aa7b6; --line: #2b3643;
    --brand: #0c1c29; --accent: #5aa9e0; --accent-ink: #0b1620;
    --good: #6fd19b; --good-bg: #173527; --warn: #f0b860; --warn-bg: #3a2a10; --bad: #f28b82; --bad-bg: #3d1c1a;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419; --surface: #182029; --surface-2: #212b36; --ink: #e6ebf1; --muted: #9aa7b6; --line: #2b3643;
  --brand: #0c1c29; --accent: #5aa9e0; --accent-ink: #0b1620;
  --good: #6fd19b; --good-bg: #173527; --warn: #f0b860; --warn-bg: #3a2a10; --bad: #f28b82; --bad-bg: #3d1c1a;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }

/* Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; margin-right: auto; }
.brand span { display: none; }
@media (min-width: 560px) { .brand span { display: inline; } }
.seg { display: inline-flex; background: rgba(255,255,255,.12); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; color: inherit; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; }
.seg button[aria-selected="true"] { background: #fff; color: var(--brand); }
.icon-btn { border: 0; background: rgba(255,255,255,.12); color: #fff; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn.spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.spinning svg { animation: none; } }

/* Pestañas: abajo en móvil, arriba en escritorio */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 9px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.tabs a.active { color: var(--accent); }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabs { position: sticky; top: 58px; bottom: auto; justify-content: center; gap: 8px; border-top: 0; border-bottom: 1px solid var(--line); }
  .tabs a { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 12px 18px; font-size: 14px; border-bottom: 2px solid transparent; }
  .tabs a.active { border-bottom-color: var(--accent); }
}

.view { max-width: 980px; margin: 0 auto; padding: 14px 16px 24px; }

/* Tareas en curso */
.taskbar { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.task { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.task .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.task.running .dot { animation: pulse 1.2s ease-in-out infinite; }
.task.done .dot { background: var(--good); }
.task.error .dot { background: var(--bad); }
.task .msg { flex: 1; min-width: 0; }
.task button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
@keyframes pulse { 50% { opacity: .3; } }

/* Controles */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; min-height: 40px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.good { color: var(--good); }
.btn.bad { color: var(--bad); }
.btn.on { background: var(--surface-2); border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="search"], input[type="number"], input[type="password"], input[type="url"], input[type="month"], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px; min-height: 40px; width: 100%;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.category { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.category button { border: 0; background: transparent; color: var(--muted); padding: 10px 8px; border-radius: 9px; font-weight: 700; font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.category button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.category .count { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--line); color: var(--muted); font-variant-numeric: tabular-nums; }
.category button[aria-selected="true"] .count { background: var(--accent); color: var(--accent-ink); }
.category-hint { margin: 8px 2px 12px; }
@media (max-width: 420px) { .category button { font-size: 13px; padding: 9px 4px; gap: 5px; } }
.zone { display: inline-block; font-size: 11px; font-weight: 700; color: var(--accent); margin-left: 4px; }

/* Mapa */
.map { height: 260px; border-radius: 10px; overflow: hidden; background: var(--surface-2); z-index: 0; }
@media (min-width: 720px) { .map { height: 320px; } }
.map-dot { display: block; width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.map-home { display: block; font-size: 18px; line-height: 22px; text-align: center; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.leaflet-container { font: inherit; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
}
:root[data-theme="dark"] .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }

/* Versiones de CV */
.cv-grid { display: grid; gap: 10px; }
@media (min-width: 720px) { .cv-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); } }
.cv-grid .card + .card { margin-top: 0; }
.cv-card.over { border-color: var(--accent); background: var(--surface-2); }
.small-drop { padding: 10px; margin-top: 10px; font-size: 14px; }
label.chip { display: inline-flex; align-items: center; gap: 6px; }

/* Propuestas freelance */
.btn.copy { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.proposal { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.proposal-text { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-top: 6px; font-size: 14px; }

/* Anuncios de Fiverr */
.gig + .gig { margin-top: 10px; }
.gig summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gig-title { font-weight: 650; }
.gig-field { border-top: 1px solid var(--line); padding: 8px 0; }
.gig-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.gig-value { margin-top: 4px; font-size: 14px; }
.gig-value.pre { white-space: pre-wrap; }
.gig-value p { margin: 0 0 6px; }
.packages { display: grid; gap: 8px; margin: 6px 0 4px; }
@media (min-width: 720px) { .packages { grid-template-columns: repeat(3, 1fr); } }
.pkg { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.pkg-price { font-size: 20px; font-weight: 800; color: var(--accent); margin: 2px 0; }
@media (max-width: 420px) { .tabs a { font-size: 11px; } }
.filters { display: grid; gap: 10px; margin-bottom: 12px; }
.filters .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .pair input { grid-column: 1 / -1; }
@media (min-width: 720px) { .filters .pair { grid-template-columns: 1fr 1fr 2fr; } .filters .pair input { grid-column: auto; } }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Tarjetas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card + .card { margin-top: 10px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }

.job { display: grid; grid-template-columns: 52px 1fr; gap: 12px; text-decoration: none; color: inherit; }
.job:hover { border-color: var(--accent); }
.job + .job { margin-top: 8px; }
.job .title { font-weight: 650; line-height: 1.3; }
.job .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.job .reason { font-size: 13px; margin-top: 6px; color: var(--muted); }
.score { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 17px; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.score.hi { background: var(--good-bg); color: var(--good); }
.score.mid { background: var(--warn-bg); color: var(--warn); }
.score small { display: block; font-size: 9px; font-weight: 700; letter-spacing: .05em; margin-top: -6px; opacity: .8; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.accent { background: var(--accent); color: var(--accent-ink); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* Detalle */
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; text-decoration: none; font-weight: 600; }
.detail-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.detail-head h2 { margin: 0; font-size: 20px; line-height: 1.25; }
.big-score { text-align: center; }
.big-score .score { width: 64px; height: 64px; font-size: 24px; }
.list { margin: 0; padding-left: 18px; }
.list li { margin: 4px 0; }
.list.good li::marker { color: var(--good); }
.list.warn li::marker { color: var(--warn); }
.desc { white-space: pre-wrap; font-size: 14px; max-height: 480px; overflow: auto; background: var(--surface-2); padding: 12px; border-radius: 10px; }
.grid2 { display: grid; gap: 10px; }
@media (min-width: 720px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.kbd-hint { font-size: 12px; color: var(--muted); }
@media (hover: none) { .kbd-hint { display: none; } }

/* Seguimiento */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.kanban .col { scroll-snap-align: start; background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.kanban .col h4 { margin: 2px 4px 10px; font-size: 14px; display: flex; justify-content: space-between; }
.kanban .job { grid-template-columns: 40px 1fr; padding: 10px; }
.kanban .score { width: 38px; height: 38px; font-size: 14px; border-radius: 10px; }

/* Perfil */
.drop { display: block; border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; cursor: pointer; background: var(--surface); }
.drop.over { border-color: var(--accent); background: var(--surface-2); }
.notice { padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.good { background: var(--good-bg); color: var(--good); }
.cert { display: grid; grid-template-columns: 1fr 140px 130px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 560px) { .cert { grid-template-columns: 1fr 1fr; } .cert > :first-child { grid-column: 1 / -1; } }
details summary { cursor: pointer; font-weight: 600; }
.json-editor { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; min-height: 360px; }

dialog { border: 0; border-radius: 16px; padding: 20px; background: var(--surface); color: var(--ink); width: min(360px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: grid; gap: 10px; }
dialog h3 { margin: 0; }
