:root {
  --ink: #16202b;
  --muted: #5b6773;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --border: #e3e8ee;
  --accent: #2f6f6a;
  --accent-dark: #245650;
  --success: #1f9d6b;
  --warning: #b26a00;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(16,32,43,.06), 0 8px 24px rgba(16,32,43,.06);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5; }
h1, h2, h3 { margin: 0 0 .2em; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--accent); }
button { font-family: inherit; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px; }
.login-card .brand { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.login-card .sub { color: var(--muted); margin-bottom: 20px; }

/* ── Layout app ── */
.topbar { background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; }
.topbar .brand { font-weight: 700; letter-spacing: -.02em; }
.topbar .who { font-size: 13px; color: #b9c4cf; display: flex; align-items: center; gap: 12px; }
.role-badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.container { max-width: 1160px; margin: 0 auto; padding: 20px; }

/* ── Controles ── */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--ink); }
/* Misma altura para inputs de texto/fecha y selects (los checkbox/radio se excluyen) */
input:not([type=checkbox]):not([type=radio]), select { height: 40px; line-height: 1.35; }
/* Select con la misma estética que los inputs + flecha propia (evita el render nativo) */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%235b6773' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
input[type=checkbox], input[type=radio] { width: auto; height: auto; padding: 0; margin: 0; cursor: pointer; accent-color: var(--accent); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; font-size: 14px; }
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--border); }
.btn.secondary:hover { background: #f0f3f6; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { background: var(--danger); border-color: var(--danger); }

/* ── Toolbar del listado ── */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; margin: 18px 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters .field { min-width: 140px; }
.filters .field.search { min-width: 220px; }

/* ── Tabla ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #fafbfc; color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcfc; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ── Pills de estado ── */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.pending { color: var(--warning); background: #fdf3e3; }
.pill.success { color: var(--success); background: #e6f6ef; }
.pill.failure { color: var(--danger); background: #fdecea; }
.pill.neutral { color: var(--muted); background: #eef1f4; }
.pill.completed { color: var(--success); background: #e6f6ef; }
.pill.in_progress { color: var(--accent); background: #e4efee; }
.pill.cancelled { color: var(--muted); background: #eef1f4; }
.pill.error { color: var(--danger); background: #fdecea; }

/* ── Paginación ── */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; color: var(--muted); font-size: 13px; }
.pager .pages { display: flex; gap: 6px; }

/* ── Modal / asistente ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,32,43,.5); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }
.x { background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }

/* Stepper (elemento distintivo: dos fases) */
.stepper { display: flex; align-items: center; gap: 7px; margin-bottom: 20px; flex-wrap: wrap; }
.stepper .step { display: inline-flex; align-items: center; }
/* Círculo con el número (pasos anteriores) */
.stepper .step .n { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; border: 1px solid var(--border); background: #fff; color: var(--muted); }
.stepper .step.done .n { background: var(--success); border-color: var(--success); color: #fff; }
/* Paso actual: pastilla desplegada con número + nombre */
.stepper .step.current { background: var(--accent); color: #fff; border-radius: 999px; padding: 3px 14px 3px 3px; gap: 8px; }
.stepper .step.current .n { background: #fff; color: var(--accent); border-color: #fff; }
.stepper .step.current .t { font-size: 13px; font-weight: 600; }
/* Pasos siguientes: solo un punto discreto */
.stepper .step.future .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); display: inline-block; margin: 0 4px; }
.stepper-count { margin-left: auto; font-size: 12px; color: var(--muted); }

.field-row { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Estado de fase en el asistente */
.phase-status { display: flex; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dropzone { position: relative; border: 2px dashed var(--border); border-radius: 10px; padding: 22px 16px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover { border-color: var(--accent); background: #fafcfc; }
.dropzone.dragover { border-color: var(--accent); background: #e9f4f3; color: var(--accent-dark); }
.dropzone.filled { border-style: solid; border-color: var(--accent); background: #f3f9f8; }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone .dz-icon { font-size: 22px; line-height: 1; }
.dropzone .dz-text { font-size: 13px; margin-top: 6px; }
.dropzone .fname { color: var(--ink); font-weight: 600; margin-top: 6px; word-break: break-all; }

/* Combobox con buscador */
.combo { position: relative; }
.combo-list { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); max-height: 240px; overflow: auto; }
.combo-opt { padding: 9px 12px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.combo-opt:hover { background: #f0f3f6; }
.combo-empty { padding: 9px 12px; color: var(--muted); font-size: 13px; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert.error { background: #fdecea; color: var(--danger); }
.alert.info { background: #e4efee; color: var(--accent-dark); }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; }
.hidden { display: none !important; }

/* Toasts (notificaciones flotantes) */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; background: #fff; color: var(--ink); border-left: 4px solid var(--muted); max-width: 360px; opacity: 0; transform: translateX(24px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; }
.toast .ti { font-size: 16px; line-height: 1; }
.toast.error { border-color: var(--danger); } .toast.error .ti { color: var(--danger); }
.toast.info { border-color: var(--accent); } .toast.info .ti { color: var(--accent); }
.toast.success { border-color: var(--success); } .toast.success .ti { color: var(--success); }

/* Interruptor on/off */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #cbd3db; border-radius: 999px; transition: background .15s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(16,32,43,.3); transition: transform .15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 640px) {
  .filters .field { min-width: 120px; }
  th.hide-sm, td.hide-sm { display: none; }
}
