:root {
  --bg: #FBFBFA;
  --card: #FFFFFF;
  --border: #EAEAEA;
  --border-strong: #DAD9D5;
  --ink: #111111;
  --ink-sec: #2F3437;
  --ink-muted: #787774;
  --ink-faint: #9B9A97;
  --ok: #346538;
  --ok-bg: #EDF3EC;
  --warn: #956400;
  --warn-bg: #FBF3DB;
  --err: #9F2F2D;
  --err-bg: #FDEBEC;
  --term-bg: #161618;
  --term-border: #2A2A2D;
  --term-text: #E6E6E3;
  --serif: "Charter", "New York", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", Menlo, ui-monospace, monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
}

.shell {
  width: 100%;
  max-width: 520px;
}

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.header h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.link-btn {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 13px;
  padding: 6px 2px;
  cursor: pointer;
}

.link-btn:hover { color: var(--ink); }
.link-btn.small { font-size: 12px; }

.tabs {
  display: flex;
  gap: 22px;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 0 8px;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink-muted);
  cursor: pointer;
}

.tab.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--ink);
}

.hairline {
  height: 1px;
  background: var(--border);
  width: 100%;
}

.mt-12 { margin-top: 12px; }
.my-10 { margin: 10px 0; }
.hidden { display: none !important; }

.mode-container {
  height: 44px;
  margin-top: 12px;
  display: flex;
  align-items: center;
}

.mode-container.drag-over .file-well,
.mode-container.drag-over .input-box {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.input-row {
  display: flex;
  gap: 10px;
  width: 100%;
  align-items: center;
}

.input-box, .file-well {
  flex: 1;
  min-width: 0;
  height: 40px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-box:focus-within {
  border-color: var(--ink);
}

.input-box input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 16px; /* evita zoom automático en iOS Safari */
  color: var(--ink);
}

.input-box input::placeholder { color: var(--ink-faint); }

.file-well {
  cursor: pointer;
  justify-content: space-between;
}

.file-placeholder {
  font-size: 13.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-placeholder.has-file {
  color: var(--ink);
}

.inline-link {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 12.5px;
  font-family: var(--sans);
  padding: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-primary, .btn-danger, .btn-ghost {
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-primary {
  background: var(--ink);
  color: #FFFFFF;
  border: none;
}

.btn-primary:disabled {
  background: var(--ink-faint);
  cursor: default;
}

.btn-danger {
  background: var(--err);
  color: #FFFFFF;
  border: none;
}

.btn-ghost {
  background: var(--card);
  color: var(--ink-sec);
  border: 1px solid var(--border-strong);
  height: 36px;
  padding: 0 13px;
  font-size: 12.5px;
}

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 13.5px;
  color: var(--ink-sec);
}

/* Switch estilo iOS */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  background: #D7D6D1;
  border-radius: 24px;
  transition: background 0.18s ease;
  cursor: pointer;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #FFFFFF;
  border-radius: 50%;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}

.switch input:checked + .slider { background: var(--ink); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* Estado y progreso */
.status-section {
  margin-top: 16px;
}

.status-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-title {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-title.ok { color: var(--ok); }
.status-title.warn { color: var(--warn); }
.status-title.err { color: var(--err); }

.badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }

.elapsed {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.substatus {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-track {
  margin-top: 9px;
  height: 3px;
  width: 100%;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--ink);
  transition: width 0.2s ease, background 0.2s ease;
}

.progress-fill.indeterminate {
  width: 34%;
  position: absolute;
  animation: slide 1.15s infinite ease-in-out;
}

.progress-fill.ok { background: var(--ok); }
.progress-fill.warn { background: var(--warn); }
.progress-fill.err { background: var(--err); }

@keyframes slide {
  0% { left: -35%; }
  100% { left: 100%; }
}

/* Lista de pasos */
.steps-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  min-height: 18px;
}

.step-dot {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.step-dot.pending::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid #CFCECA;
}

.step-dot.active::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  animation: pulse 0.9s infinite ease-in-out;
}

.step-dot.fail::after {
  content: "";
  width: 7px;
  height: 1.5px;
  background: #B4B3AF;
}

.step-dot.ok {
  background: var(--ok);
  border-radius: 50%;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
}
.step-dot.ok::after { content: "✓"; }

.step-dot.sent {
  background: var(--warn);
  border-radius: 50%;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
}
.step-dot.sent::after { content: "–"; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.28; }
}

.step-name { color: var(--ink-faint); }
.step-row.active .step-name,
.step-row.ok .step-name,
.step-row.sent .step-name { color: var(--ink); }

.step-detail {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.step-row.active .step-detail { color: var(--ink-muted); }
.step-row.ok .step-detail { color: var(--ok); }
.step-row.sent .step-detail { color: var(--warn); }

/* Acciones */
.actions-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-btn {
  height: 36px;
  padding: 0 13px;
  border-radius: 7px;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.action-btn.primary {
  background: var(--ink);
  color: #fff;
  border: none;
}

.action-btn.secondary {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--border-strong);
}

/* Registro técnico consola oscura */
.log-header {
  margin-top: 14px;
}

.log-box {
  margin-top: 6px;
  background: var(--term-bg);
  border: 1px solid var(--term-border);
  border-radius: 8px;
  height: 170px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px;
}

.log-box pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  color: var(--term-text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Modal de Ajustes */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal {
  width: 100%;
  max-width: 440px;
  background: var(--bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.modal h2 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.field-row input {
  width: 195px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 9px;
  font-size: 15px;
  background: var(--card);
  color: var(--ink);
}

.pass-wrap {
  width: 195px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 6px 0 9px;
  display: flex;
  align-items: center;
  background: var(--card);
}

.pass-wrap input {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 0;
}

.pair-input {
  display: flex;
  gap: 8px;
}

.short-input {
  width: 72px !important;
  text-align: center;
}

.modal-note {
  margin: 12px 0 16px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-muted);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-right {
  display: flex;
  gap: 8px;
}
