/* ============================================================
   Exótica Campo — PWA móvil
   Diseñado para smartphones (375-430px) y guantes de trabajo
   Touch targets ≥ 48px, contraste alto, un solo botón principal
   ============================================================ */
:root {
  --green-deep: #14342B;
  --green:      #1F5A47;
  --gold:       #C4A662;
  --cream:      #FAF7F0;
  --surface:    #FFFFFF;
  --fg:         #1A2B24;
  --muted:      #6B7A73;
  --border:     #E5DFCF;
  --err:        #A13230;
  --warn:       #C47A1A;
  --ok:         #1F5A47;
  --info:       #4A7BA8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--cream); color: var(--fg);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16px; line-height: 1.5;
  min-height: 100vh; min-height: 100dvh;
  overscroll-behavior: none;
}

#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; color: var(--muted); font-size: 15px;
}

/* ============ Header ============ */
.hdr {
  background: var(--green-deep); color: var(--cream);
  padding: 18px 20px 16px;
  display: flex; align-items: center; justify-content: space-between;
  padding-top: calc(18px + env(safe-area-inset-top));
}
.hdr__title { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.hdr__sub   { font-size: 12px; opacity: .7; margin-top: 2px; }
.hdr__logout {
  background: transparent; border: 1px solid rgba(196, 166, 98, .5); color: var(--gold);
  padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 500;
  cursor: pointer;
}
.hdr__back {
  background: transparent; border: 0; color: var(--gold);
  font-size: 14px; padding: 6px 10px; cursor: pointer;
}

/* ============ Main ============ */
.main {
  flex: 1; padding: 20px 20px 40px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.h2 { font-size: 20px; font-weight: 600; margin: 0 0 6px; }
.p  { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

/* ============ Login ============ */
.login {
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
  padding: 40px 24px; background: linear-gradient(180deg, var(--cream) 0%, #efe8d5 100%);
  padding-top: calc(40px + env(safe-area-inset-top));
}
.login__brand {
  text-align: center; margin-top: 8vh; margin-bottom: 40px;
}
.login__logo {
  width: 60px; height: 66px; margin: 0 auto 14px; color: var(--green-deep);
}
.login__title { font-size: 26px; font-weight: 600; color: var(--green-deep); letter-spacing: -.02em; }
.login__sub   { color: var(--muted); font-size: 14px; margin-top: 6px; }

.field {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px;
}
.field label { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select {
  padding: 14px 16px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--surface); font-size: 16px; font-family: inherit; color: var(--fg);
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(196,166,98,.18);
}
.pin-field input {
  font-size: 24px; letter-spacing: .5em; text-align: center; font-weight: 600;
}

.btn-primary {
  width: 100%; padding: 16px; background: var(--green-deep);
  color: var(--cream); border: 0; border-radius: 10px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  margin-top: 8px;
  transition: background .15s;
}
.btn-primary:hover { background: var(--green); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.err-msg { color: var(--err); font-size: 13.5px; text-align: center; margin-top: 10px; min-height: 20px; }

/* ============ Home (post login) ============ */
.tile-grid {
  display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 16px;
}
.tile {
  display: flex; align-items: center; gap: 16px;
  padding: 22px 20px; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 14px;
  text-decoration: none; color: var(--fg);
  transition: border-color .15s, transform .1s;
  min-height: 84px; cursor: pointer; text-align: left;
  width: 100%; font-family: inherit; font-size: 16px;
}
.tile:hover { border-color: var(--gold); }
.tile:active { transform: scale(.98); }
.tile__ico {
  width: 52px; height: 52px; border-radius: 12px;
  background: linear-gradient(135deg, var(--green-deep), var(--green));
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); flex-shrink: 0;
}
.tile__ico svg { width: 26px; height: 26px; }
.tile__body { flex: 1; min-width: 0; }
.tile__t    { font-size: 17px; font-weight: 600; margin-bottom: 2px; }
.tile__s    { font-size: 13px; color: var(--muted); }
.tile__arrow { color: var(--muted); }

/* ============ Alertas resumen ============ */
.summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin: 20px 0;
}
.sm-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 8px; text-align: center;
}
.sm-card__v { font-size: 22px; font-weight: 600; }
.sm-card__l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.sm-card--err  .sm-card__v { color: var(--err); }
.sm-card--warn .sm-card__v { color: var(--warn); }
.sm-card--ok   .sm-card__v { color: var(--ok); }

/* ============ Escáner QR ============ */
.scanner-wrap {
  background: #000; border-radius: 14px; overflow: hidden;
  aspect-ratio: 1 / 1; position: relative;
  max-width: 340px; margin: 0 auto;
}
#qr-reader { width: 100%; }
.scanner-hint { text-align: center; color: var(--muted); margin: 14px 0 6px; font-size: 13.5px; }
.manual-id {
  display: flex; gap: 8px; margin-top: 20px;
}
.manual-id input { flex: 1; padding: 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 15px; }
.manual-id button {
  padding: 12px 20px; background: var(--green-deep); color: var(--cream);
  border: 0; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}

/* ============ Ficha planta ============ */
.planta-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 14px; padding: 22px; margin-bottom: 16px;
}
.planta-id { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.planta-especie { color: var(--muted); font-size: 14px; margin-top: 4px; }

.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.info-row:last-child { border-bottom: 0; }
.info-row__l { color: var(--muted); }
.info-row__v { font-weight: 500; text-align: right; }

.pill {
  display: inline-flex; padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
}
.pill--err   { background: rgba(200, 60, 60, .14); color: var(--err); }
.pill--warn  { background: rgba(196, 122, 26, .16); color: var(--warn); }
.pill--amber { background: rgba(196, 166, 98, .22); color: #7a5e26; }
.pill--info  { background: rgba(74, 123, 168, .15); color: var(--info); }
.pill--ok    { background: rgba(31, 90, 71, .15); color: var(--ok); }
.pill--blue  { background: rgba(74, 123, 168, .15); color: var(--info); }

/* Historial */
.hist { margin-top: 14px; }
.hist h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }
.hist-item {
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px; display: flex; justify-content: space-between; gap: 12px;
}
.hist-item:last-child { border-bottom: 0; }
.hist-item .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.hist-empty { text-align: center; color: var(--muted); font-style: italic; padding: 12px; font-size: 13px; }

/* ============ Rotaciones del día ============ */
.rot-item {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 16px; margin-bottom: 12px;
  display: block; text-decoration: none; color: var(--fg);
  transition: border-color .15s;
}
.rot-item:hover { border-color: var(--gold); }
.rot-item__top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px;
}
.rot-item__id  { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; font-size: 15px; }
.rot-item__cli { font-weight: 500; margin: 2px 0; }
.rot-item__ubc { color: var(--muted); font-size: 13px; }
.rot-item__dias{ font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ============ Cierre modal (bottom sheet) ============ */
.sheet-scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sheet-scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 24px 22px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 -8px 28px rgba(0,0,0,.15);
}
.sheet.open { transform: translateY(0); }
.sheet__grip {
  width: 40px; height: 4px; background: var(--border); border-radius: 999px;
  margin: -6px auto 16px;
}
.sheet__title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.sheet__sub   { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.sheet__actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet__actions .btn-primary { margin-top: 0; }
.btn-ghost {
  flex: 1; padding: 16px; background: transparent;
  color: var(--muted); border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 15px; font-weight: 500; cursor: pointer; font-family: inherit;
}

.action-buttons {
  display: flex; flex-direction: column; gap: 10px; margin-top: 20px;
}
.action-buttons .btn-primary { margin-top: 0; }
.action-buttons .btn-ghost   { width: 100%; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--green-deep); color: var(--cream);
  padding: 12px 22px; border-radius: 999px; font-size: 14px;
  z-index: 200; opacity: 0; transition: opacity .25s;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.open { opacity: 1; }
.toast--err { background: var(--err); }

/* ============ Estados vacíos ============ */
.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty__icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty__t    { font-size: 16px; font-weight: 500; color: var(--fg); margin-bottom: 6px; }
.empty__s    { font-size: 13.5px; }
