* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* Tema CLARO fijo, tipografía grande (usuario de tercera edad) */
:root {
  --bg: #f2f5f9;
  --bg2: #ffffff;
  --card: #ffffff;
  --text: #17202b;
  --hint: #4e5d70;
  --accent: #1d6fe0;
  --accent-text: #ffffff;
  --green: #157a45;
  --red: #c92f2f;
  --amber: #9a6a00;
  --border: rgba(20, 40, 70, .14);
  --radius: 14px;
}

html { color-scheme: light; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  max-width: 640px;
  margin: 0 auto;
}

.hidden { display: none !important; }
.hint { color: var(--hint); font-size: 15px; }
.right { text-align: right; }
.green { color: var(--green); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.strike { text-decoration: line-through; opacity: .5; }

/* ── Auth ── */
#auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-box { width: 100%; max-width: 340px; text-align: center; display: flex; flex-direction: column; gap: 16px; }
.auth-logo { font-size: 64px; }
.auth-box h1 { font-size: 26px; }

/* ── Layout ── */
#view { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
#nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px;
  display: flex; background: var(--bg2);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(20, 40, 70, .06);
}
#nav button {
  flex: 1; background: none; border: none; color: var(--hint);
  font-size: 13px; font-weight: 600; padding: 9px 0 7px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
#nav button span { font-size: 27px; }
#nav button.active { color: var(--accent); }

h2.title { font-size: 23px; margin: 4px 2px 14px; display: flex; align-items: center; justify-content: space-between; }

/* ── Cards ── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(20, 40, 70, .05);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.stat .lbl { font-size: 14.5px; color: var(--hint); margin-bottom: 4px; font-weight: 600; }
.stat .val { font-size: 24px; font-weight: 800; }
.stat .sub { font-size: 14px; color: var(--hint); margin-top: 3px; }

.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }
.row-item { padding: 13px 2px; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: none; }
.row-title { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 14.5px; color: var(--hint); margin-top: 3px; }
.amount { font-weight: 800; font-size: 18px; white-space: nowrap; }

.badge {
  display: inline-block; font-size: 14px; font-weight: 700;
  padding: 4px 12px; border-radius: 20px; background: rgba(29,111,224,.12); color: var(--accent);
}
.badge.warn { background: rgba(154,106,0,.14); color: var(--amber); }
.badge.ok { background: rgba(21,122,69,.12); color: var(--green); }

/* ── Botones e inputs ── */
.btn {
  border-radius: 12px; padding: 14px 18px;
  font-size: 17px; font-weight: 700; cursor: pointer;
  background: var(--bg2); color: var(--text); border: 1px solid var(--border);
}
.btn.primary { background: var(--accent); color: var(--accent-text); border: none; width: 100%; padding: 16px; font-size: 18px; }
.btn.danger { color: var(--red); }
.btn.small { padding: 10px 14px; font-size: 15px; border-radius: 10px; }
.btn:active { opacity: .75; }

input, select, textarea {
  width: 100%; background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 13px 14px; color: var(--text); font-size: 17px;
  outline: none; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label.fld { display: block; margin-bottom: 13px; }
label.fld > div { font-size: 15px; color: var(--hint); margin-bottom: 6px; font-weight: 600; }
.fld-row { display: flex; gap: 10px; }
.fld-row > * { flex: 1; }

.fab {
  position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(86px + env(safe-area-inset-bottom));
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); border: none;
  font-size: 32px; cursor: pointer; z-index: 40;
  box-shadow: 0 5px 18px rgba(29,111,224,.4);
}

/* ── Sheet (overlay) ── */
.sheet-back {
  position: fixed; inset: 0; background: rgba(15,25,40,.45); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 640px;
  border-radius: 20px 20px 0 0; max-height: 92vh; overflow-y: auto;
  padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h3 { font-size: 20px; }
.sheet-close { background: var(--bg2); border: 1px solid var(--border); color: var(--hint); width: 40px; height: 40px; border-radius: 50%; font-size: 19px; cursor: pointer; }

/* ── Picker de productos ── */
.pick-list { max-height: 300px; overflow-y: auto; margin-top: 8px; }
.pick-item { padding: 12px 10px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 8px; }
.pick-item:active { background: rgba(29,111,224,.08); }

/* ── Carrito ── */
.cart-item { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 9px; }
.qty-btn {
  width: 42px; height: 42px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--bg2); color: var(--text); font-size: 20px; cursor: pointer;
}
.cart-item input.price { width: 104px; padding: 9px 10px; font-size: 17px; text-align: right; }
.total-line { display: flex; justify-content: space-between; font-size: 21px; font-weight: 800; padding: 14px 4px; }

/* ── Productos ── */
.prod-thumb {
  width: 62px; height: 62px; border-radius: 12px; background: #e8edf4;
  display: flex; align-items: center; justify-content: center; font-size: 30px;
  object-fit: cover; overflow: hidden; flex-shrink: 0;
}
img.prod-thumb { object-fit: cover; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 10px; }
.photo-grid .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #e8edf4; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .del {
  position: absolute; top: 5px; right: 5px; width: 30px; height: 30px;
  border-radius: 50%; border: none; background: rgba(10,20,35,.7); color: #fff; font-size: 14px; cursor: pointer;
}
.photo-add {
  aspect-ratio: 1; border-radius: 10px; border: 2px dashed var(--border);
  background: none; color: var(--hint); font-size: 32px; cursor: pointer;
}

/* ── Toast ── */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(102px + env(safe-area-inset-bottom));
  background: #24303f; color: #fff; padding: 13px 20px; border-radius: 13px;
  font-size: 16.5px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 200;
  max-width: 90%; text-align: center; box-shadow: 0 4px 14px rgba(20,40,70,.3);
}
#toast.show { opacity: 1; }
#toast.err { background: #8e2626; }

.seg { display: flex; background: #e8edf4; border-radius: 12px; padding: 4px; margin-bottom: 13px; }
.seg button { flex: 1; border: none; background: none; color: var(--hint); padding: 11px; border-radius: 9px; font-size: 16px; font-weight: 700; cursor: pointer; }
.seg button.active { background: var(--accent); color: var(--accent-text); }
