/* Agrosmart - Level monitor: base visual (publica). El resto de los estilos de la app viene con la sesion (app.css). */

/* ---------- Tokens ---------- */
:root {
    color-scheme: light;
    --bg: #f3f6f6; --surface: #ffffff; --surface-2: #f7faf9; --text: #0f1f1e; --muted: #3f5452; --subtle: #5a6f6d;
    --line: #e0e8e7; --line-strong: #c9d6d4;
    --brand: #0f766e; --brand-strong: #0b5c55; --brand-soft: #e3f3f1; --brand-ink: #ffffff;
    --ok: #15803d; --ok-soft: #e7f6ec; --bad: #c42b2b; --bad-soft: #fcebea; --warn: #b45309; --warn-soft: #fdf3e4;
    --off: #64748b; --off-soft: #eef1f5; --on-warn: #ffffff;
    --radius: 16px; --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 40, 38, .06);
    --shadow: 0 1px 2px rgba(16, 40, 38, .05), 0 6px 20px rgba(16, 40, 38, .07);
    --shadow-lg: 0 10px 40px rgba(16, 40, 38, .18);
    --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 32%, transparent);
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
    --ease: cubic-bezier(.2, .7, .2, 1);
    --page-max: 1570px;   /* ancho del contenido (encabezado y paginas alineados) */
    --gutter: clamp(16px, 3vw, 32px);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0a1413; --surface: #101d1c; --surface-2: #0d1817; --text: #eef6f5; --muted: #b3c6c3; --subtle: #93aaa7;
        --line: #1d2e2c; --line-strong: #2a3f3d;
        --brand: #2dd4bf; --brand-strong: #5eead4; --brand-soft: #0f2e2b; --brand-ink: #032b27;
        --ok: #4ade80; --ok-soft: #10291a; --bad: #f87171; --bad-soft: #321616; --warn: #fbbf24; --warn-soft: #2e2410;
        --off: #94a3b8; --off-soft: #18222b; --on-warn: #1c1404;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .25);
        --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a1413; --surface: #101d1c; --surface-2: #0d1817; --text: #eef6f5; --muted: #b3c6c3; --subtle: #93aaa7;
    --line: #1d2e2c; --line-strong: #2a3f3d;
    --brand: #2dd4bf; --brand-strong: #5eead4; --brand-soft: #0f2e2b; --brand-ink: #032b27;
    --ok: #4ade80; --ok-soft: #10291a; --bad: #f87171; --bad-soft: #321616; --warn: #fbbf24; --warn-soft: #2e2410;
    --off: #94a3b8; --off-soft: #18222b; --on-warn: #1c1404;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; font-size: 112.5%; }   /* 18 px: legible para todas las edades */
@media (max-width: 640px) { html { font-size: 106.25%; } }   /* 17 px en el celular */
body {
    margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
    font: 1rem/1.55 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
a { color: var(--brand); }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }
.skip {
    position: absolute; left: 12px; top: -48px; z-index: 50; padding: 8px 14px; border-radius: 10px;
    background: var(--brand); color: var(--brand-ink); text-decoration: none; font-weight: 600; transition: top .15s;
}
.skip:focus { top: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { text-align: center; padding: 40px 16px; color: var(--muted); }

/* ---------- Encabezado ---------- */
.top {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--line);
}
.top-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; max-width: var(--page-max); margin: 0 auto;
    padding: 12px max(var(--gutter), env(safe-area-inset-right)) 12px max(var(--gutter), env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; color: inherit; text-decoration: none; border-radius: 10px; }
.brand img { flex: none; width: 42px; height: 42px; border-radius: 11px; box-shadow: var(--shadow-sm); }
/* Logo: fondo negro en el tema claro y fondo blanco en el oscuro (sigue al sistema o a la eleccion del boton de tema) */
.brand .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .brand .logo-light { display: none; }
    :root:not([data-theme="light"]) .brand .logo-dark { display: block; }
}
:root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }
.brand-text { line-height: 1.15; font-size: 1.3rem; letter-spacing: -.015em; white-space: nowrap; }
.brand-text b { font-weight: 750; }
.brand-text .sep, .brand-text .sub { color: var(--muted); font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-slot { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-slot:empty { display: none; }
.theme-btn {
    width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 50%;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.theme-btn:hover { color: var(--text); border-color: var(--subtle); }
.theme-btn svg { width: 20px; height: 20px; }
.theme-btn .sun, .theme-btn[data-mode="dark"] .moon { display: none; }
.theme-btn[data-mode="dark"] .sun { display: block; }
@media (max-width: 640px) {
    .top-inner { min-height: 64px; padding-top: 10px; padding-bottom: 10px; }
    .brand img { width: 38px; height: 38px; }
    .brand-text { font-size: 1.05rem; white-space: normal; }
    .brand-text .sep { display: none; }
    .brand-text b, .brand-text .sub { display: block; }
    .brand-text .sub { font-size: .76rem; }
}

main { outline: none; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
    border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
    font-weight: 600; cursor: pointer; text-decoration: none; user-select: none;
    transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--subtle); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: var(--brand); border-color: transparent; color: var(--brand-ink); box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--brand-strong); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; }
.link { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ---------- Campos ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; align-content: start; }   /* en filas de dos, la ayuda de un campo no estira al otro */
.field > label, .label { font-size: .92rem; font-weight: 600; color: var(--muted); }
.input {
    width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--subtle); }
.input:hover { border-color: var(--subtle); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 84px; }
.input-wrap .reveal {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 32px; padding: 0 10px;
    border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .88rem; font-weight: 600; cursor: pointer;
}
.input-wrap .reveal:hover { background: var(--surface-2); color: var(--text); }
.help { font-size: .88rem; color: var(--subtle); }
.help.warn { color: var(--warn); }

/* ---------- Mensajes ---------- */
.alert {
    display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: var(--radius-sm);
    font-size: .95rem; line-height: 1.45; margin: 4px 0 14px;
}
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--brand-soft); color: var(--brand-strong); }
.alert svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }

.spinner {
    width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, currentColor 22%, transparent);
    border-top-color: currentColor; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 60dvh; color: var(--muted); }
.boot .spinner { color: var(--brand); }

/* ---------- Ingreso ---------- */
.auth {
    display: grid; min-height: calc(100dvh - 73px);
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}
.auth-hero {
    position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
    padding: clamp(28px, 5vw, 64px); color: #ecfdf9;
    background:
        radial-gradient(1200px 600px at 110% -10%, rgba(94, 234, 212, .35), transparent 60%),
        radial-gradient(800px 500px at -20% 120%, rgba(14, 165, 233, .35), transparent 60%),
        linear-gradient(150deg, #0f766e 0%, #0b4f4a 55%, #072f2c 100%);
}
.auth-hero::after {   /* agua: dos ondas suaves al pie */
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 30%; opacity: .13; pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 200' preserveAspectRatio='none'%3E%3Cpath d='M0 62C100 34 200 92 300 62S500 34 600 62V200H0Z' fill='%23ffffff' fill-opacity='.45'/%3E%3Cpath d='M0 104C120 76 220 134 330 104S520 76 600 100V200H0Z' fill='%23ffffff' fill-opacity='.7'/%3E%3C/svg%3E") bottom / 100% 100% no-repeat;
}
.auth-hero h1 { font-size: clamp(1.9rem, 3.4vw, 2.9rem); line-height: 1.08; letter-spacing: -.025em; margin: 0 0 14px; max-width: 14ch; }
.auth-hero p { margin: 0; max-width: 42ch; color: #c7efe8; font-size: 1.04rem; }
.kicker { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #99f6e4; margin-bottom: 18px; }
.kicker::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5eead4; box-shadow: 0 0 0 4px rgba(94, 234, 212, .25); }
.feats { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; position: relative; z-index: 1; }
.feats li { display: flex; gap: 12px; align-items: flex-start; }
.feats .ico {
    flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
    background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16);
}
.feats .ico svg { width: 18px; height: 18px; }
.feats b { display: block; font-size: .95rem; }
.feats span { color: #c9efe8; font-size: .92rem; }
.auth-side { display: grid; place-items: center; padding: clamp(20px, 4vw, 48px) 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 1.55rem; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-card .lead { color: var(--muted); margin: 0 0 22px; }
.seg {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 22px;
    border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
}
.seg button {
    min-height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer;
    transition: background .15s, color .15s, box-shadow .15s;
}
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; font-size: .88rem; }
.legal { margin-top: 28px; font-size: .84rem; color: var(--subtle); text-align: center; }
@media (max-width: 900px) {
    .auth { grid-template-columns: 1fr; min-height: auto; }
    .auth-hero { display: none; }
    .auth-side { padding-top: 32px; }
}

/* ---------- Cuenta pendiente ---------- */
.state-card {
    max-width: 460px; margin: 10dvh auto 0; padding: 32px 26px; text-align: center;
    background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
}
.state-card .badge-ico {
    width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px; display: grid; place-items: center;
    background: var(--warn-soft); color: var(--warn);
}
.state-card .badge-ico svg { width: 28px; height: 28px; }
.state-card h2 { margin: 0 0 8px; font-size: 1.3rem; letter-spacing: -.01em; }
.state-card p { margin: 0 0 10px; color: var(--muted); }
.state-card .who { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.state-card .actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.state-card .badge-ico.brand { background: var(--brand-soft); color: var(--brand); }
.state-card .badge-ico.ok { background: var(--ok-soft); color: var(--ok); }
.state-card .aside { margin: 16px 0 0; font-size: .92rem; }
.state-card form { text-align: left; margin-top: 18px; }
.state-card .alert { text-align: left; margin-top: 14px; }
@media (max-width: 520px) {
    .state-card { margin: 5dvh 16px 0; padding: 26px 20px; }
    .state-card .actions { flex-direction: column-reverse; }   /* la accion principal arriba */
    .state-card .actions .btn { width: 100%; }
}

/* ---------- Avisos flotantes ---------- */
.toasts {
    position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
    display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none;
}
.toast {
    pointer-events: auto; padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--bg);
    box-shadow: var(--shadow-lg); font-size: .92rem; animation: rise .25s var(--ease);
}
.toast.bad { background: var(--bad); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
