:root {
  --bg: #f4f7f5;
  --card: #ffffff;
  --primary: #0f3d2e;
  --primary-2: #1a6b4f;
  --accent: #c9a227;
  --danger: #b42318;
  --muted: #5b6b63;
  --border: #d7e0db;
  --ok: #0e7a4b;
  --shadow: 0 8px 24px rgba(15, 61, 46, 0.08);
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: #122018; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; }
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.app-header h1 { font-size: 1.05rem; margin: 0; font-weight: 700; letter-spacing: .02em; }
.app-header .sub { font-size: .75rem; opacity: .85; }
.spacer { flex: 1; }
.badge {
  font-size: .7rem; padding: 4px 8px; border-radius: 999px;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25);
}
.badge.offline { background: #7a1f1f; }
.badge.online { background: rgba(14,122,75,.85); }
.wrap { max-width: 860px; margin: 0 auto; padding: 16px; padding-bottom: 96px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 1.05rem; color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; margin-bottom: 10px;
}
textarea { min-height: 72px; resize: vertical; }
.btn {
  appearance: none; border: none; border-radius: 12px; padding: 12px 14px;
  background: var(--primary); color: #fff; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:disabled { opacity: .5; }
.btn.secondary { background: #e8efeB; color: var(--primary); }
.btn.accent { background: var(--accent); color: #1a1400; }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.type-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type-pick button { min-height: 88px; flex-direction: column; font-size: .95rem; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px; z-index: 30;
}
.nav button {
  background: transparent; border: none; padding: 8px 4px; color: var(--muted); font-size: .72rem; cursor: pointer;
}
.nav button.active { color: var(--primary); font-weight: 700; }
.list-item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.list-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: #eee; }
.list-item .meta { font-size: .78rem; color: var(--muted); }
.list-item .title { font-weight: 700; color: var(--primary); }
.muted { color: var(--muted); font-size: .85rem; }
.hidden { display: none !important; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 78px;
  background: #122018; color: #fff; padding: 10px 14px; border-radius: 999px;
  font-size: .85rem; z-index: 40; opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; }
.preview { width: 100%; max-height: 240px; object-fit: contain; border-radius: 12px; background: #111; }
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at top, #1a6b4f, #0f3d2e 60%); }
.login-card { width: min(420px, 100%); }
.login-card h1 { color: var(--primary); margin-top: 0; }
.chip { display: inline-block; font-size: .7rem; padding: 2px 8px; border-radius: 999px; background: #e8efeB; color: var(--primary); }
.chip.warn { background: #fff4ce; color: #7a5b00; }
.chip.low { background: #fde8e6; color: #7a1f1f; }

.badge.live { background: rgba(14,122,75,.95); }
.badge.sse-off { background: #5b6b63; }
.badge.leyendo { background: #7a5b00; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
