/* GEOMASTERS · tokens y componentes comunes */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --glass: rgba(255, 255, 255, 0.92);
  --line: rgba(17, 24, 39, 0.09);
  --line-2: rgba(17, 24, 39, 0.16);
  --text: #1f2937;
  --text-2: #4b5563;
  --muted: #6b7280;
  --accent: #ea580c;
  --accent-2: #c2410c;
  --accent-strong: #c2410c;   /* naranja para texto y botones sobre blanco (contraste AA) */
  --accent-ink: #ffffff;
  --accent-soft: rgba(234, 88, 12, 0.09);
  --focus: #f97316;
  /* estado (semáforo) — siempre con icono y texto */
  --ok: #16a34a;
  --warn: #eab308;
  --crit: #dc2626;
  --info: #2563eb;
  /* series de gráficos */
  --series-1: #ea580c;
  --series-2: #64748b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 12px 34px rgba(17, 24, 39, 0.12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-strong); }
::selection { background: rgba(234, 88, 12, 0.22); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* scrollbars discretas */
* { scrollbar-width: thin; scrollbar-color: rgba(17,24,39,.22) transparent; }

/* ───── Formularios ───── */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .label { font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(17,24,39,.28); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.input[readonly], .textarea[readonly] { color: var(--text-2); background: transparent; }
.select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.select option { background: var(--panel); }
.textarea { resize: vertical; min-height: 80px; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ───── Botones ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: transform .08s, background .15s, border-color .15s, opacity .15s; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: #9a3412; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: #fff7ed; border-color: var(--line-2); }
.btn-danger { background: #fef2f2; border-color: rgba(220,38,38,.4); color: #b91c1c; }
.btn-danger:hover:not(:disabled) { background: #fee2e2; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-icon { padding: 8px; }
.btn-block { width: 100%; }

/* ───── Semáforo / etiquetas ───── */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; border: 1px solid; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.verde { color: #15803d; border-color: rgba(22,163,74,.45); background: #f0fdf4; }
.pill.amarillo { color: #a16207; border-color: rgba(234,179,8,.55); background: #fefce8; }
.pill.rojo { color: #b91c1c; border-color: rgba(220,38,38,.45); background: #fef2f2; }
.pill.completo { color: var(--accent-strong); border-color: rgba(234,88,12,.4); background: var(--accent-soft); }
.pill.completo::before { content: "✓"; background: none; width: auto; height: auto; font-size: 11px; }
.pill.neutral { color: var(--text-2); border-color: var(--line-2); background: transparent; }
.pill.neutral::before { display: none; }
.pill.rojo::before { border-radius: 2px; transform: rotate(45deg); }
.pill.amarillo::before { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: #f3f4f6; color: var(--text-2); }
.tag.admin { background: #eff6ff; color: #1d4ed8; }
.tag.editor { background: var(--accent-soft); color: var(--accent-strong); }
.tag.pantalla { background: #1f2937; color: #fdba74; }

/* ───── Mensajes ───── */
.alert { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; border: 1px solid; display: flex; gap: 8px; align-items: flex-start; }
.alert.error { background: #fef2f2; border-color: rgba(220,38,38,.35); color: #b91c1c; }
.alert.warn { background: #fefce8; border-color: rgba(234,179,8,.45); color: #854d0e; }
.alert.ok { background: #f0fdf4; border-color: rgba(22,163,74,.35); color: #15803d; }
.alert.info { background: #eff6ff; border-color: rgba(37,99,235,.35); color: #1d4ed8; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 5000; max-width: min(380px, calc(100vw - 36px)); }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--crit); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ───── Diálogos ───── */
dialog.modal { border: 1px solid var(--line-2); border-radius: 18px; background: var(--panel); color: var(--text); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(17, 24, 39, .4); backdrop-filter: blur(3px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 10px 20px 4px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px 20px; }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(17,24,39,.18); border-top-color: currentColor; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.toasts[popover] { inset: auto 16px 18px auto; margin: 0; padding: 0; border: 0; overflow: visible; background: transparent; max-width: calc(100vw - 32px); }
