:root {
  --bg: #0E1116; --bg2: #0B0E13; --card: #171B22; --card2: #141920;
  --line: #232A34; --line2: #2A313C; --tx: #E6E9EE; --tx2: #C4CBD5; --mut: #9AA3AF; --mut2: #8F98A5;
  --blue: #7FB2FF; --blueBg: #16243A; --violet: #C4A5FF; --violetBg: #251D38;
  --amber: #F2B544; --amberBg: #2B2414; --teal: #5EEAD4; --tealBg: #12302C;
  --red: #FF9B85; --redBg: #33191A; --green: #4ADE80; --greenBg: #11291B;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx); font-family: var(--sans); }
body { overscroll-behavior-y: none; }
button { font-family: inherit; color: inherit; }
input { font-family: inherit; }
[hidden] { display: none !important; }
.muted { color: #AEB6C2; }
.kicker { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--mut2); }

/* ---------- login ---------- */
.login { min-height: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: calc(64px + env(safe-area-inset-top)) 28px calc(36px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; }
.login-top { display: flex; flex-direction: column; gap: 18px; }
.logo { width: 56px; height: 56px; border-radius: 16px; background: var(--blueBg); border: 1px solid #2A4468; display: flex; align-items: center; justify-content: center; }
.login h1 { margin: 0; font-size: 34px; line-height: 1.1; }
.login p { margin: 0; font-size: 15px; line-height: 1.5; }
.login-bottom { display: flex; flex-direction: column; gap: 16px; }
.gbtn { min-height: 44px; display: flex; justify-content: center; }
.login-msg { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--redBg); color: var(--red); font-size: 14px; line-height: 1.45; }
.login-msg.info { background: var(--blueBg); color: #A9CBFF; }
.checks { list-style: none; margin: 0; padding: 14px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.checks li { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--tx2); }
.checks li::before { content: ''; width: 6px; height: 6px; border-radius: 3px; background: var(--green); flex: none; }

/* ---------- shell ---------- */
.app { height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }
.top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid #1E242D; }
.title { font-size: 20px; font-weight: 700; margin-top: 2px; }
.top-r { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line2); background: var(--card2); color: var(--tx2); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.avatar { width: 44px; height: 44px; border-radius: 22px; border: 1px solid #2A4468; background: var(--blueBg); color: #A9CBFF; font-family: var(--mono); font-size: 13px; font-weight: 600; cursor: pointer; }
.user-menu { position: absolute; right: 16px; top: calc(100% + 6px); z-index: 20; width: 250px; padding: 14px; border-radius: 14px; background: #1B2029; border: 1px solid var(--line2); box-shadow: 0 12px 30px rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 4px; }
.um-name { font-weight: 600; font-size: 15px; }
.um-mail { font-size: 12px; color: var(--mut); margin-bottom: 10px; word-break: break-all; }
.btn-danger { height: 44px; border-radius: 10px; border: 1px solid #5A2A24; background: var(--redBg); color: var(--red); font-weight: 600; font-size: 14px; cursor: pointer; }

.view { flex: 1; overflow-y: auto; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 14px; outline: none; -webkit-overflow-scrolling: touch; }
.nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 6px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid #1E242D; background: var(--bg2); }
.nav button { height: 56px; border: none; background: transparent; color: #7D8693; font-size: 11px; font-weight: 500; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; }
.nav button.on { color: var(--blue); }

/* ---------- controles ---------- */
.search { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line2); }
.search:focus-within { border-color: #3B6BB0; }
.search input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; color: var(--tx); font-size: 16px; }
.search input::placeholder { color: #7D8693; }
.search .pref { font-family: var(--mono); font-size: 12px; color: var(--blue); white-space: nowrap; }
.search .clear { width: 32px; height: 32px; border: none; border-radius: 16px; background: #222936; color: var(--mut); cursor: pointer; font-size: 16px; line-height: 1; }
.lbl { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--mut2); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line2); background: var(--card2); color: var(--tx2); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--blueBg); border-color: #3B6BB0; color: #A9CBFF; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; padding: 4px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); }
.seg button { height: 40px; border-radius: 9px; border: none; background: transparent; color: #AEB6C2; font-size: 14px; font-weight: 600; cursor: pointer; }
.seg.violet button.on { background: var(--violetBg); color: var(--violet); }
.seg.amber button.on { background: var(--amberBg); color: var(--amber); }
.days { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.day { height: 56px; border-radius: 12px; border: 1px solid var(--line2); background: var(--card2); color: var(--tx2); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.day b { font-size: 13px; font-weight: 600; }
.day span { font-family: var(--mono); font-size: 11px; }
.day.on { background: var(--tealBg); border-color: #2E8C7E; color: var(--teal); }
.date-pick { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line2); font-size: 13px; color: var(--tx2); }
.date-pick.on { border-color: #2E8C7E; color: var(--teal); }
.date-pick input { flex: 1; background: transparent; border: none; color: var(--tx); font-size: 15px; color-scheme: dark; outline: none; min-width: 0; }
.meta { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12px; color: var(--mut); }
.meta .mono { font-family: var(--mono); }
.ok { color: var(--green); font-family: var(--mono); font-size: 11px; }

/* ---------- tarjetas inicio ---------- */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi { text-align: left; display: flex; flex-direction: column; gap: 9px; padding: 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); cursor: pointer; min-width: 0; }
.kpi:active { transform: scale(.98); }
.kpi-h { display: flex; justify-content: space-between; align-items: center; width: 100%; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; }
.kpi-n { font-size: 36px; font-weight: 700; line-height: 1; }
.kpi-s { font-size: 12px; color: #AEB6C2; line-height: 1.35; }
.kpi-f { font-family: var(--mono); font-size: 11px; color: var(--mut2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-blue { color: var(--blue); } .c-violet { color: var(--violet); } .c-amber { color: var(--amber); } .c-teal { color: var(--teal); } .c-red { color: var(--red); }

.list { list-style: none; margin: 0; padding: 0; border-radius: 14px; background: var(--card); border: 1px solid var(--line); overflow: hidden; }
.list li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid #1F252E; }
.list li:last-child { border-bottom: none; }
.dot { width: 8px; height: 8px; border-radius: 4px; flex: none; }
.li-b { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.li-t { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-s { font-size: 12px; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-d { font-family: var(--mono); font-size: 11px; color: var(--mut2); flex: none; }

.res { text-align: left; display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); cursor: pointer; }
.tag { flex: none; padding: 3px 7px; border-radius: 6px; font-family: var(--mono); font-size: 10px; font-weight: 600; }
.t-base { color: #A9CBFF; background: var(--blueBg); } .t-i2 { color: var(--violet); background: var(--violetBg); }
.t-retro { color: var(--amber); background: var(--amberBg); } .t-eventos { color: var(--teal); background: var(--tealBg); }
.res-b { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.res-t { font-size: 14px; font-weight: 600; line-height: 1.35; }
.res-s { font-size: 12px; color: var(--mut); line-height: 1.4; }

/* ---------- tarjetas de registro ---------- */
.card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.card-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.code { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--blue); word-break: break-word; }
.date { font-family: var(--mono); font-size: 12px; color: var(--mut); white-space: nowrap; }
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.b-rel { color: var(--amber); background: var(--amberBg); border: 1px solid #4A3B1C; }
.b-none { color: #8A93A0; border: 1px solid var(--line2); }
.b-ok { color: var(--green); background: var(--greenBg); } .b-pend { color: var(--red); background: var(--redBg); }
.b-amber { color: var(--amber); background: var(--amberBg); } .b-gray { color: var(--tx2); background: #1F2833; font-weight: 500; }
.b-teal { color: var(--teal); background: var(--tealBg); font-weight: 500; }
.txt { font-size: 13px; line-height: 1.55; color: #DDE2E9; white-space: pre-line; word-break: break-word; }
.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.more { align-self: flex-start; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line2); background: transparent; color: var(--blue); font-size: 12px; font-weight: 600; cursor: pointer; }
.loc { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; color: #AEB6C2; line-height: 1.4; }
.loc svg { flex: none; margin-top: 1px; }
.amp { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 10px; background: #12202F; border: 1px solid #22384F; }
.amp .lbl { color: var(--blue); font-size: 10px; letter-spacing: .1em; }
.amp .txt { font-size: 12px; color: var(--tx2); }
.box-v { padding: 10px 12px; border-radius: 10px; background: #1C1729; border: 1px solid #2E2546; font-size: 12px; line-height: 1.5; color: #DDD3F5; white-space: pre-line; word-break: break-word; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; font-size: 12px; }
.kv > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv .k { color: var(--mut2); }
.kv .v { color: var(--tx); word-break: break-word; }
.kv .wide { grid-column: span 2; }
.h2 { font-size: 15px; font-weight: 600; line-height: 1.35; }
.sub { font-size: 12px; color: var(--mut); line-height: 1.4; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.retro-d { flex: none; width: 50px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 2px; }
.retro-d span { font-family: var(--mono); font-size: 11px; color: var(--amber); }
.retro-d b { font-size: 22px; line-height: 1; }
.desc { font-size: 12px; line-height: 1.55; color: #AEB6C2; padding-top: 8px; border-top: 1px solid var(--line); white-space: pre-line; word-break: break-word; }

.tl { display: flex; gap: 12px; }
.tl-h { flex: none; width: 52px; display: flex; flex-direction: column; align-items: center; }
.tl-h b { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--teal); padding-top: 14px; text-align: center; line-height: 1.3; }
.tl-h i { flex: 1; width: 1px; background: var(--line); margin-top: 6px; }
.tl .card { flex: 1; margin-bottom: 10px; min-width: 0; }
.dayhead { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--teal); margin: 6px 0 2px; }

/* ---------- estados ---------- */
.empty { padding: 24px; text-align: center; font-size: 14px; color: var(--mut); border: 1px dashed var(--line2); border-radius: 12px; line-height: 1.5; }
.err { padding: 18px; border-radius: 12px; background: var(--redBg); color: var(--red); font-size: 14px; line-height: 1.5; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.err button { height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid #5A2A24; background: transparent; color: var(--red); font-weight: 600; cursor: pointer; }
.sk { border-radius: 14px; background: linear-gradient(90deg, #161A21 0%, #1D222B 50%, #161A21 100%); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* pantalla de privacidad al salir de la app */
.shield { position: fixed; inset: 0; z-index: 100; background: var(--bg); }
body.oculto #app { filter: blur(24px); }

@media (prefers-reduced-motion: reduce) { .sk, .icon-btn.spin svg { animation: none; } }
