:root {
  --bg: #f4f2f8;
  --card: #ffffff;
  --text: #1c1730;
  --muted: #6b6680;
  --line: #e2deec;
  --brand: #4c1d95;
  --brand-2: #6d28d9;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14111d; --card: #1f1a2c; --text: #ece9f5; --muted: #a39db8; --line: #332c45;
    --brand: #a78bfa; --brand-2: #8b5cf6;
    --ok: #4ade80; --ok-bg: #14321f; --warn: #fbbf24; --warn-bg: #3a2c0c; --bad: #f87171; --bad-bg: #3b1515;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #4c1d95; color: #fff;
}
.brand { font-weight: 700; font-size: 18px; }
.brand small { font-weight: 400; opacity: .7; font-size: 12px; }
.chip {
  border: 0; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,.18); color: #fff;
}
.chip.off { background: #fbbf24; color: #3a2c0c; }
.chip.err { background: #f87171; color: #3b1515; }

.update { background: var(--warn-bg); color: var(--warn); padding: 10px 16px; font-size: 14px; }
.update button { margin-left: 8px; }

main { padding: 12px 16px; max-width: 720px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.big { font-size: 20px; font-weight: 700; }

.dayhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.userchip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.userchip.falta { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: none; padding: 7px 12px; font-size: 14px; }
.seg button.on { background: var(--brand-2); color: #fff; }
.search {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); margin-bottom: 10px;
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px;
}
.card h3 { margin: 0 0 8px; font-size: 16px; }

.tienda { display: block; }
.tienda .t1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tienda .nom { font-weight: 700; font-size: 17px; }
.tienda .km { font-size: 13px; color: var(--muted); white-space: nowrap; }
.tienda .tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.tag.due { background: var(--warn-bg); color: var(--warn); border-color: transparent; font-weight: 600; }
.tag.late { background: var(--bad-bg); color: var(--bad); border-color: transparent; font-weight: 600; }
.tag.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; font-weight: 600; }
.tienda .nota { font-size: 13px; color: var(--muted); }
.tienda .btns { display: flex; gap: 8px; margin-top: 8px; }
.tienda.hecha { opacity: .6; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 10px 14px; text-decoration: none; color: var(--text); font-weight: 600; min-height: 44px;
}
.btn.sm { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.ghost { background: none; }
.btn.disabled, .btn:disabled { opacity: .45; pointer-events: none; }
.link { border: 0; background: none; color: var(--brand-2); font-weight: 600; padding: 6px 0; }

.corte-head h2 { margin: 4px 0; font-size: 22px; }
.corte-links { display: flex; gap: 8px; margin: 8px 0 12px; }

.grid-head, .grow {
  display: grid; grid-template-columns: 56px 1fr 1fr 64px; gap: 8px; align-items: center;
}
.grid-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.grow { margin-bottom: 8px; }
.grow .gid {
  font-weight: 700; text-align: center; padding: 10px 0; border-radius: 10px; background: var(--bg);
}
input:not([type=file]), select, textarea {
  width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; }
.foto {
  width: 64px; height: 48px; border-radius: 10px; border: 1px dashed var(--muted);
  background: var(--bg) center/cover no-repeat; font-size: 12px; color: var(--muted);
}
.foto.falta { border: 2px solid var(--bad); color: var(--bad); }
.foto.tiene { border: 2px solid var(--ok); color: transparent; }

.sub { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin: 8px 0; }
.sub b { color: var(--text); }
.fld { display: block; font-size: 14px; color: var(--muted); margin-top: 6px; }
.fld input, .fld select, .fld textarea { margin-top: 4px; color: var(--text); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.total {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--brand); color: #fff; border-radius: var(--radius); padding: 14px 16px; margin: 4px 0 10px;
}
@media (prefers-color-scheme: dark) { .total { background: #3b1a78; } }
.total b { font-size: 24px; }
.actions { display: flex; gap: 10px; margin-bottom: 20px; }
.actions .btn { flex: 1; }
.actions.col { flex-direction: column; }

.msg {
  text-align: left; white-space: pre-wrap; background: var(--bg); border-radius: 10px;
  padding: 10px; font: 14px/1.35 system-ui, sans-serif;
}

.env .t1 { display: flex; justify-content: space-between; gap: 8px; }
.env .err { color: var(--bad); font-size: 13px; margin-top: 4px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { flex: 1; border: 0; background: none; padding: 14px 0; font-weight: 600; color: var(--muted); }
.tabs button.on { color: var(--brand-2); box-shadow: inset 0 3px 0 var(--brand-2); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; margin-left: 4px; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 10;
  background: #1c1730; color: #fff; padding: 12px 14px; border-radius: 10px; font-size: 14px;
  max-width: 560px; margin: 0 auto; pointer-events: none;
}
