:root { --bg:#f3f5f8; --panel:#fff; --text:#1b2430; --muted:#6b7686; --line:#dfe4ea; --brand:#1d5fd6; --brand-ink:#fff; --ok:#1a8f3c; --warn:#d98a00; --bad:#c62828; --off:#7b8794; }
/* Temas: data-theme = auto | light | dark | dim (lo fija theme.js) */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; --bg:#080b10; --panel:#11161d; --text:#e8edf3; --muted:#9aa6b5; --line:#263140; --brand:#5b95f5; --brand-ink:#07101f; }
:root[data-theme="dim"] { color-scheme: dark; --bg:#2a2f37; --panel:#343a44; --text:#e4e8ed; --muted:#aab3bf; --line:#4b535f; --brand:#6ba1ff; --brand-ink:#0b1220; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"], :root:not([data-theme]) { color-scheme: dark; --bg:#12161c; --panel:#1b222b; --text:#e6ebf1; --muted:#98a3b1; --line:#2b3541; --brand:#5b95f5; --brand-ink:#0b1220; } }
.themesel { margin-top: 8px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 10px 14px; min-height: 44px; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.danger { color: var(--bad); } button.big { width: 100%; margin-top: 8px; font-weight: 600; }
button:disabled { opacity: .5; }
input, select, textarea { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
textarea { min-height: 90px; }
#login { display: grid; place-items: center; height: 100%; padding: 16px; }
#login form { background: var(--panel); padding: 24px; border-radius: 14px; width: min(380px, 100%); display: grid; gap: 12px; }
#login h1 { margin: 0; font-size: 22px; } .err { color: var(--bad); min-height: 1.3em; font-size: 14px; }
#app { display: grid; grid-template-rows: auto 1fr auto; height: 100%; }
#top { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
#top .name { font-weight: 700; } #top .sub { color: var(--muted); font-size: 13px; }
#top .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
#view { overflow: auto; padding: 12px; }
#tabs { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs button { border: 0; border-radius: 0; background: none; padding: 8px 2px; font-size: 13px; position: relative; }
#tabs button.on { color: var(--brand); font-weight: 700; }
#tabs button.sos { background: var(--bad); color: #fff; font-size: 17px; font-weight: 800; letter-spacing: .5px; min-height: 56px; }
#tabs button.sos.on { outline: 3px solid #fff; outline-offset: -5px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 13px; background: var(--line); }
.pill.ok { background: var(--ok); color: #fff; } .pill.warn { background: var(--warn); color: #fff; } .pill.bad { background: var(--bad); color: #fff; } .pill.off { background: var(--off); color: #fff; }
.card { background: var(--panel); border-radius: 12px; padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.card.tap { cursor: pointer; } .card h3 { margin: 0 0 4px; font-size: 16px; } .muted { color: var(--muted); font-size: 14px; }
.notice { border-left: 5px solid var(--warn); }
.kvs { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0; } .kvs dt { color: var(--muted); } .kvs dd { margin: 0; word-break: break-word; }
.sec { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; color: var(--muted); }
label.f { display: grid; gap: 4px; margin-bottom: 12px; color: var(--muted); font-size: 14px; } label.f.chk { display: flex; align-items: center; gap: 10px; color: var(--text); } label.f.chk input { width: 22px; height: 22px; }
.seg { display: flex; gap: 6px; margin-bottom: 10px; } .seg button { flex: 1; } .seg button.on { background: var(--brand); color: var(--brand-ink); }
.chat { display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: var(--panel); align-self: flex-start; white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); } .msg small { display: block; opacity: .7; font-size: 12px; } .msg a { color: inherit; text-decoration: underline; }
.composer { position: sticky; bottom: -12px; background: var(--bg); padding: 8px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.composer textarea { grid-column: 1 / -1; min-height: 76px; max-height: 160px; font-size: 17px; line-height: 1.35; resize: none; overflow-y: auto; padding: 12px; }
.composer button { min-height: 50px; font-size: 16px; font-weight: 600; }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: end; z-index: 50; } #modal.on { display: flex; }
#modal .box { background: var(--panel); width: 100%; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
#modal .btns { display: flex; gap: 8px; margin-top: 10px; } #modal .btns button { flex: 1; }
#toasts { position: fixed; left: 10px; right: 10px; top: 10px; z-index: 60; display: grid; gap: 6px; pointer-events: none; }
.toast { background: var(--panel); border-left: 5px solid var(--brand); padding: 10px 12px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.3); } .toast.bad { border-left-color: var(--bad); } .toast.ok { border-left-color: var(--ok); }
.photos { display: flex; gap: 6px; flex-wrap: wrap; } .photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.sosbtn { background: var(--bad); color: #fff; border-color: var(--bad); font-size: 44px; font-weight: 900; letter-spacing: 3px; min-height: 180px; border-radius: 16px; position: relative; overflow: hidden; user-select: none; touch-action: none; }
.sosbtn .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(0,0,0,.35); }
.flink { color: var(--brand); text-decoration: underline; cursor: pointer; }
.card p.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); border-left: 4px solid var(--warn); padding: 8px 10px; border-radius: 6px; font-size: 14px; }
