:root {
  --bg: #0f1220;
  --bg-2: #171b2e;
  --bg-3: #1f2440;
  --card: #1a1f38;
  --border: #2a3052;
  --text: #eef1fb;
  --text-2: #9aa3c7;
  --accent: #4f7cff;
  --danger: #ff5c6c;
  --ok: #35d07f;
  --warn: #ffb454;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.hint { color: var(--text-2); font-size: 12px; }

/* topbar */
#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(15,18,32,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.logo-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.logo-dot.big { width: 44px; height: 44px; margin: 0 auto 6px; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  width: 40px; height: 40px; font-size: 18px; cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* layout */
#view { padding: 14px 16px 90px; max-width: 720px; margin: 0 auto; }
.home-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.home-head h1 { font-size: 20px; margin: 0; }

#filtro { display: flex; gap: 8px; margin-bottom: 14px; }
#filtro select, #filtro input {
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; width: 100%;
}
#filtro select { flex: 0 0 132px; }

/* cards */
.rp-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; margin-bottom: 12px;
  cursor: pointer; transition: transform .1s;
}
.rp-card:active { transform: scale(.985); }
.rp-card .head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rp-card .cliente { font-weight: 700; font-size: 15px; }
.rp-card .equipo { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.rp-card .descripcion { margin-top: 8px; font-size: 14px; line-height: 1.45; }
.rp-card .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.rp-card .fecha { color: var(--text-2); font-size: 12px; margin-left: auto; }

.badge {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  text-transform: capitalize;
}
.estado-abierto { background: #3a1620; color: #ff8ba0; }
.estado-en_proceso { background: #16284a; color: #8ab4ff; }
.estado-espera_repuesto { background: #3a2a10; color: #ffcf8a; }
.estado-espera_cliente { background: #3a2a10; color: #ffcf8a; }
.estado-resuelto { background: #12331f; color: #7ff0ab; }
.prio-urgente { background: #ff5c6c; color: #fff; }
.prio-alta { background: #ff8a4c; color: #fff; }
.prio-normal { background: #4f7cff; color: #fff; }
.prio-baja { background: #565f85; color: #fff; }

/* empty / loading */
.vacio { text-align: center; color: var(--text-2); padding: 60px 20px; }
.vacio .ico { font-size: 42px; display: block; margin-bottom: 10px; }
.cargando { text-align: center; color: var(--text-2); padding: 40px; }

/* detalle */
.back-btn {
  background: none; border: none; color: var(--accent);
  font-size: 15px; padding: 6px 0 14px; cursor: pointer; font-weight: 600;
}
.det-head { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.det-head .cliente { font-size: 18px; font-weight: 700; }
.det-head .equipo { color: var(--text-2); margin-top: 2px; }
.det-row { margin-top: 12px; }
.det-row label { color: var(--text-2); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 3px; }
.det-row .valor { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }

.estado-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.estado-btn {
  flex: 1 1 calc(50% - 8px); min-width: 0;
  padding: 12px 8px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
}
.estado-btn.activo { border-color: var(--accent); background: #20305e; color: #fff; }
.estado-btn:active { transform: scale(.97); }

.notas { margin-top: 16px; }
.notas h3 { font-size: 14px; margin: 0 0 10px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.nota {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
}
.nota .n-texto { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.nota .n-meta { margin-top: 6px; font-size: 11px; color: var(--text-2); }

.nueva-nota { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.nueva-nota textarea {
  width: 100%; min-height: 80px; resize: vertical;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 14px; font-family: inherit;
}

/* botones */
.btn-primary, .btn-ghost {
  border: none; border-radius: 12px; padding: 14px; font-size: 15px; font-weight: 700; cursor: pointer; width: 100%;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { transform: scale(.98); }
.btn-ghost { background: var(--bg-3); color: var(--text); border: 1px solid var(--border); }
.btn-primary[disabled] { opacity: .6; }
.btn-primary.danger { background: var(--danger); }

/* login */
#login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% -10%, #233061 0%, var(--bg) 55%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 340px; background: var(--card);
  border: 1px solid var(--border); border-radius: 18px; padding: 28px 22px;
}
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo h1 { margin: 0; font-size: 22px; }
.login-logo p { margin: 2px 0 0; color: var(--text-2); }
#login-form label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text-2); }
#login-form input {
  width: 100%; margin-top: 4px; padding: 12px 14px; font-size: 15px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
}
.error { color: var(--danger); font-size: 13px; margin: 8px 0; }

/* modal */
#modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.modal-card h2 { margin: 0 0 14px; font-size: 17px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn-primary, .modal-actions .btn-ghost { width: auto; flex: 1; padding: 12px; }
#modal-body label { display: block; font-size: 13px; color: var(--text-2); }
#modal-body select, #modal-body input {
  width: 100%; margin-top: 4px; padding: 12px; font-size: 15px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
}

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #232a4d; border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
#toast.ok { border-color: var(--ok); }
#toast.err { border-color: var(--danger); }
