:root {
  --brand: #0f3d68;
  --brand-soft: #1b5a92;
  --accent: #1565a8;
  --accent-press: #0f4f86;
  --bg: #f2f5f8;
  --card: #ffffff;
  --text: #17202a;
  --muted: #5b6b7b;
  --line: #cfd8e2;
  --danger: #b3261e;
  --ok: #1e7a46;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

.hidden { display: none !important; }

/* ── estructura ─────────────────────────────────────────── */

.view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--brand);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.panel {
  width: 100%;
  max-width: 460px;
  margin: 18px auto;
  padding: 18px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(15, 61, 104, .12);
}

@media (min-width: 700px) {
  .panel { margin-top: 40px; }
}

/* ── formularios ────────────────────────────────────────── */

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .4px;
}

label:first-child { margin-top: 0; }

input[type="password"],
input[type="text"],
select {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 101, 168, .18);
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  touch-action: manipulation;
}

button.primary {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border-radius: 10px;
  transition: background .15s;
}

button.primary:hover:not(:disabled) { background: var(--accent-press); }
button.primary:disabled { opacity: .5; cursor: default; }

button.ghost {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  font-size: 15px;
  color: var(--accent);
  background: #eef4fa;
  border: 1px solid var(--line);
  border-radius: 10px;
}

button.link {
  padding: 6px 10px;
  font-size: 14px;
  color: #dbe8f4;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 8px;
}

button.link:hover { background: rgba(255, 255, 255, .12); }

/* ── mensajes ───────────────────────────────────────────── */

.msg {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 14px;
  text-align: center;
  color: var(--danger);
}

.msg.ok { color: var(--ok); }

.hint {
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

h2 {
  margin: 0 0 10px;
  font-size: 19px;
  color: var(--brand);
}

/* ── pantalla de entrada ────────────────────────────────── */

#v-lock {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#v-lock .lock {
  width: 100%;
  max-width: 320px;
  background: var(--card);
  padding: 26px 22px;
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(15, 61, 104, .14);
}

#v-lock input { text-align: center; letter-spacing: 2px; }
#v-lock .primary { margin-top: 14px; }

/* ── código de recuperación ─────────────────────────────── */

.code {
  margin: 14px 0 0;
  padding: 16px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 17px;
  line-height: 1.6;
  letter-spacing: 1.5px;
  text-align: center;
  word-break: break-all;
  background: #f7f9fb;
  border: 1px dashed var(--line);
  border-radius: 10px;
  user-select: all;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.big-label {
  margin: 4px 0 14px;
  font-size: 20px;
  font-weight: 700;
  color: var(--brand);
  text-transform: capitalize;
}

/* ── fichas ─────────────────────────────────────────────── */

input[readonly] {
  background: #eef2f6;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.row > input,
.row > select {
  flex: 1 1 0;
  min-width: 0;
}

.row > .ghost,
.row > .plus,
.row > .x {
  flex: 0 0 auto;
  width: auto;
  margin-top: 0;
}

.plus {
  padding: 0 20px;
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--accent);
  border-radius: 10px;
}

.plus:hover { background: var(--accent-press); }

.duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 380px) {
  .duo { grid-template-columns: 1fr; }
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 16px 0 6px;
}

.label-row label { margin: 0; }

.inline-plus {
  width: 34px;
  height: 34px;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
}

.inline-plus:hover { background: var(--accent-press); }

.ficha-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.ficha-head h2 {
  margin: 0;
  font-size: 18px;
  color: var(--brand);
  letter-spacing: .5px;
}

.ghost.small {
  width: auto;
  margin: 0;
  padding: 9px 12px;
  font-size: 14px;
}

.seg-card {
  margin-top: 14px;
  padding: 14px;
  background: #fafcfd;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.seg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand);
}

.x {
  width: 30px;
  height: 30px;
  font-size: 14px;
  color: var(--danger);
  background: #fdeceb;
  border-radius: 8px;
}

.x:hover { background: #f9d9d7; }

.field-money {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
}

.field-money input { padding-right: 34px; }

.suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  color: var(--muted);
  pointer-events: none;
}

.anio-row {
  align-items: baseline;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 15px;
  color: var(--muted);
}

.anio-row strong {
  font-size: 17px;
  color: var(--brand);
}

#tels .row { margin-bottom: 8px; }

.status {
  min-height: 20px;
  margin: 16px 0 0;
  font-size: 13px;
  text-align: right;
  color: var(--muted);
}

.status.warn {
  color: var(--danger);
  text-align: left;
}

.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  font-size: 16px;
  border-bottom: 1px solid var(--line);
}

.stat:last-child { border-bottom: 0; }

.stat strong {
  font-size: 22px;
  color: var(--brand);
}
