:root {
  color-scheme: light;
  --ink: #1a2227;
  --ink-soft: #4a565d;
  --muted: #6b767c;
  --paper: #fbf8f2;
  --paper-2: #eef3f5;
  --card: #ffffff;
  --line: #e2ddd2;
  --brand: #1f3d4c;
  --brand-2: #2c5a70;
  --accent: #b8893b;
  --ok: #2f7d57;
  --ok-bg: #e6f3ec;
  --warn: #9a6a12;
  --warn-bg: #fbf1dc;
  --error: #a4432f;
  --error-bg: #f9e9e4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 35, 45, .06), 0 8px 24px rgba(20, 35, 45, .08);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(1200px 600px at 10% -10%, #f3ead8 0%, transparent 60%),
              linear-gradient(165deg, var(--paper) 0%, var(--paper-2) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.2rem; }

a { color: var(--brand-2); }

code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: .85em;
  background: rgba(31, 61, 76, .07);
  padding: .1rem .35rem;
  border-radius: 4px;
}

.muted { color: var(--muted); margin: .25rem 0 0; }
.hint { color: var(--muted); font-size: .85rem; }

/* Layout */
.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 2rem 1.25rem 3rem; flex: 1; }
.auth-wrap { flex: 1; display: grid; place-items: center; padding: 2rem 1rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1.25rem;
  background: rgba(255, 255, 255, .75);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--brand); text-decoration: none; font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.brand img { height: 40px; width: auto; object-fit: contain; }
.brand span { font-family: var(--font); font-size: 1rem; font-weight: 600; color: var(--ink-soft); padding-left: .6rem; border-left: 1px solid var(--line); }
.topbar-user { display: flex; align-items: center; gap: .75rem; }
.topbar-user form { margin: 0; }
.user-chip { font-size: .9rem; color: var(--ink-soft); padding: .3rem .7rem; background: var(--paper-2); border-radius: 999px; }

.footer {
  display: flex; justify-content: center; gap: 1rem;
  padding: 1rem; font-size: .8rem; color: var(--muted);
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card { width: 100%; max-width: 420px; padding: 2rem 1.75rem; }
.auth-head { text-align: center; margin-bottom: 1.25rem; }
.auth-tagline { font-family: var(--font); font-size: 1.08rem; font-weight: 500; line-height: 1.4; color: var(--ink-soft); letter-spacing: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Globo (la red) ··· logo del cliente: distingue este acceso remoto del login local del equipo. */
.remote-link {
  display: flex; align-items: center; gap: .75rem;
  max-width: 300px; margin: 0 auto 1.25rem;
}
.remote-globe {
  flex: none; display: grid; place-items: center;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--brand); color: #fff;
  box-shadow: 0 0 0 5px rgba(31, 61, 76, .1);
}
.remote-globe svg { width: 34px; height: 34px; }
.remote-line {
  position: relative; flex: 1; min-width: 48px; height: 4px;
  background-image: radial-gradient(circle, var(--brand) 1.6px, transparent 2px);
  background-size: 11px 4px;
  background-repeat: repeat-x;
  background-position: 0 50%;
  animation: remote-flow 1.1s linear infinite;
  opacity: .8;
}
.remote-logo { flex: none; height: 90px; width: auto; object-fit: contain; }
.remote-break { display: none; }
@keyframes remote-flow { to { background-position: 11px 50%; } }

.remote-link.is-broken .remote-globe { background: #6b767c; box-shadow: 0 0 0 5px rgba(107, 118, 124, .12); }
.remote-link.is-broken .remote-line {
  animation: none;
  background-image: radial-gradient(circle, var(--error) 1.6px, transparent 2px);
}
.remote-link.is-broken .remote-break {
  display: grid; place-items: center;
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--card); color: var(--error);
  border: 2px solid var(--error);
  font: 700 14px/1 var(--font);
}
@media (prefers-reduced-motion: reduce) { .remote-line { animation: none; } }

/* Forms */
.form label { display: block; margin: .9rem 0 .35rem; font-size: .88rem; font-weight: 500; color: var(--ink-soft); }
.form input, .search {
  width: 100%; padding: .7rem .8rem;
  border: 1px solid #cfc8ba; border-radius: 10px;
  font: inherit; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form input:focus, .search:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(44, 90, 112, .18); }

.password-field { position: relative; }
.password-field input { padding-right: 4rem; }
.toggle-pass {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--brand-2); font: inherit; font-size: .85rem; cursor: pointer; padding: .35rem .5rem;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .72rem 1.1rem; margin: 0;
  border: 1px solid transparent; border-radius: 10px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn-ghost:hover { background: rgba(31, 61, 76, .06); }
.btn-sm { padding: .4rem .8rem; font-size: .85rem; }
.btn-block { width: 100%; }
.form .btn-block { margin-top: 1.4rem; }

.actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }
.actions form { margin: 0; }

.alert { padding: .75rem .9rem; border-radius: 10px; border: 1px solid; font-size: .93rem; margin: 0 0 1rem; }
.alert-error { background: var(--error-bg); border-color: #e3b3a6; color: var(--error); }
.alert-ok { background: var(--ok-bg); border-color: #a9d4bd; color: var(--ok); }
.alert-info { background: var(--paper-2); border-color: #c5d5dc; color: var(--brand); }

/* Devices */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.search { max-width: 320px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }

.device { display: flex; flex-direction: column; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.device:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(20, 35, 45, .08), 0 14px 32px rgba(20, 35, 45, .12); }
.device[hidden] { display: none; }
.device-media { position: relative; aspect-ratio: 4 / 3; background: linear-gradient(160deg, #e9eef0, #f6f1e6); }
.device-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.device-body { padding: 1rem 1.1rem .5rem; flex: 1; }
.device-foot { padding: .5rem 1.1rem 1.1rem; }

.meta { display: grid; grid-template-columns: auto 1fr; gap: .3rem .75rem; margin: .75rem 0 0; font-size: .88rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }

.badge {
  position: absolute; top: .75rem; left: .75rem;
  font-size: .75rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-error { color: var(--error); background: var(--error-bg); }
.badge-muted { color: var(--ink-soft); background: #eef1f3; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* Offline */
.watch-status { display: flex; align-items: center; gap: .6rem; color: var(--ink-soft); font-size: .92rem; background: var(--paper-2); padding: .65rem .8rem; border-radius: 10px; }
.spinner { width: 16px; height: 16px; flex: none; border: 2px solid #c9d5db; border-top-color: var(--brand-2); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

@media (max-width: 560px) {
  h1 { font-size: 1.5rem; }
  .container { padding-top: 1.25rem; }
  .auth-card { padding: 1.5rem 1.25rem; }
  .remote-globe { width: 52px; height: 52px; }
  .remote-globe svg { width: 30px; height: 30px; }
  .remote-logo { height: 78px; }
  .search { max-width: none; }
}
