* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

/* Misma paleta que la app y el menú web (modo claro / oscuro del dispositivo). */
:root {
  --orange: #FF7A00;
  --orange-dark: #E86600;
  --page: #F4F1EC;
  --bg: #FFFFFF;
  --soft: #E5E1DB;
  --soft-a: rgba(229, 225, 219, .55);
  --muted: #77716A;
  --dark: #333333;
  --text: #111111;
  --line: rgba(0, 0, 0, .1);
  --open: #1E9E48;
  --closing: #B27600;
  --closed: #77716A;
  --danger: #D13B3B;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 24px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #000000;
    --bg: #090909;
    --soft: #232323;
    --soft-a: rgba(35, 35, 35, .7);
    --muted: #A8A29B;
    --dark: #D0D0D0;
    --text: #F2F2F2;
    --line: rgba(255, 255, 255, .1);
    --open: #34C759;
    --closing: #FFB300;
    --closed: #A8A29B;
    --danger: #FF6B6B;
    --shadow: none;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--page);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--soft); border-top-color: var(--orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--bg); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.login-card { width: 100%; max-width: 420px; padding: 28px 26px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.3px; }
.muted { color: var(--muted); font-size: .92rem; }

.brand-row { display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--orange); }
.brand-name { font-size: 1.35rem; font-weight: 900; letter-spacing: -.5px; }
.brand-sub { color: var(--muted); font-size: .8rem; font-weight: 600; margin-left: 4px; }

/* Controles */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .label { font-size: .8rem; font-weight: 700; color: var(--dark); }
.hint { font-size: .78rem; color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel], input[type=time], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--bg); outline: none; min-height: 44px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); }
input:disabled, select:disabled { opacity: .55; }
.error { color: var(--danger); font-size: .88rem; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 700;
  text-decoration: none; white-space: nowrap; transition: transform .1s, opacity .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: .86rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.link-btn { background: none; border: none; color: var(--orange); font-weight: 700; cursor: pointer; padding: 6px; align-self: center; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1rem;
}
.icon-btn:hover { border-color: var(--muted); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger { color: var(--danger); }

/* Barra superior */
.topbar { position: sticky; top: 0; z-index: 40; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1100px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar-mid { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-mid select { max-width: 260px; min-height: 38px; padding: 6px 10px; }
.rest-name { font-weight: 800; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.topbar-end { display: flex; gap: 8px; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 14px; background: var(--soft-a); }
.status-chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-chip.open { color: var(--open); } .status-chip.soon { color: var(--closing); } .status-chip.closed { color: var(--closed); }
.status-chip span { color: var(--text); }
.tabs { max-width: 1100px; margin: 0 auto; padding: 0 14px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: none; padding: 12px 16px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected=true] { color: var(--text); border-bottom-color: var(--orange); }

.banner { background: rgba(255,122,0,.12); border-bottom: 1px solid rgba(255,122,0,.3); padding: 12px 20px; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; font-size: .92rem; }

.view { max-width: 1100px; margin: 0 auto; padding: 22px 20px 80px; }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.3px; }
.view-head .muted { margin-top: 2px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Menú */
.cat { margin-bottom: 18px; overflow: hidden; }
.cat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--soft-a); border-left: 5px solid var(--orange); }
.cat-title { flex: 1; min-width: 0; font-weight: 800; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { color: var(--muted); font-weight: 600; font-size: .86rem; white-space: nowrap; }
.cat-tools { display: flex; gap: 6px; }
.items { padding: 0 14px; }
.item { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item.off { opacity: .6; }
.item-img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--soft); flex: none; }
.item-img.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.4rem; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-weight: 700; }
.item-desc { color: var(--muted); font-size: .85rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-price { color: var(--orange); font-weight: 800; font-size: .95rem; margin-top: 2px; }
.item-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.add-item { padding: 12px 14px 14px; }
.empty-box { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty-box strong { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 6px; }

/* Interruptor */
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; inset: 0; cursor: pointer; z-index: 1; min-height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 14px; background: var(--soft); transition: background .15s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + .track { background: var(--orange); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--orange); outline-offset: 2px; }

/* Formularios */
.form-card { padding: 20px; margin-bottom: 18px; }
.form-card h3 { font-size: 1rem; font-weight: 800; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { border: 1.5px solid var(--line); background: var(--bg); border-radius: 20px; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: .88rem; }
.chip-btn:hover { border-color: var(--muted); }
.chip-btn[aria-pressed=true] { background: var(--orange); border-color: var(--orange); color: #fff; }
.chip-btn:disabled { opacity: .4; cursor: default; }
.photo-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.photo-prev { width: 96px; height: 96px; border-radius: 18px; object-fit: cover; background: var(--soft); flex: none; }
.photo-prev.wide { width: 170px; height: 96px; }
.photo-prev.round { border-radius: 50%; }
.photo-ph { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.6rem; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(to top, var(--page) 70%, transparent); padding: 14px 0 6px; display: flex; justify-content: flex-end; gap: 10px; }

/* Horario */
.sched-row { display: grid; grid-template-columns: 110px 70px 1fr 1fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sched-row:last-child { border-bottom: none; }
.sched-day { font-weight: 700; }
.sched-row.today .sched-day { color: var(--orange); }
.sched-row.closed input[type=time] { opacity: .35; }
.sched-lbl { display: none; }
.status-box { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: space-between; }
.status-box .big { font-weight: 800; font-size: 1.1rem; }

/* Galería */
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.gal-item { position: relative; border-radius: 14px; overflow: hidden; background: var(--soft); aspect-ratio: 1; cursor: pointer; border: none; padding: 0; }
.gal-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-item .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; font-size: .75rem; color: #fff; background: rgba(0,0,0,.55); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gal-add { aspect-ratio: 1; border-radius: 14px; border: 2px dashed var(--line); background: var(--soft-a); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--orange); font-weight: 700; cursor: pointer; font-size: .9rem; }
.gal-add:hover { border-color: var(--orange); }
.gal-add.disabled { opacity: .45; cursor: default; }
.progress { height: 6px; border-radius: 4px; background: var(--soft); overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--orange); width: 0; transition: width .2s; }

/* Modal */
.modal-bd { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal h3 { font-size: 1.15rem; font-weight: 800; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.modal img.preview { max-width: 100%; max-height: 260px; object-fit: contain; border-radius: 12px; background: var(--soft); align-self: center; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { width: 20px; height: 20px; min-height: 0; margin-top: 2px; accent-color: var(--orange); flex: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1b1b1b; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 200; font-weight: 600; font-size: .92rem; box-shadow: 0 8px 28px rgba(0,0,0,.35); max-width: calc(100vw - 32px); }
.toast.err { background: #8e1f1f; }

@media (max-width: 640px) {
  .view { padding: 16px 14px 90px; }
  .topbar-in { padding: 8px 14px; }
  .topbar-end .btn { padding: 0 10px; }
  .sched-row { grid-template-columns: 1fr 1fr; grid-template-areas: 'day day' 'chk chk' 'o c'; gap: 8px 10px; }
  .sched-row .sched-day { grid-area: day; }
  .sched-row .sched-open-sw { grid-area: chk; }
  .sched-lbl { display: block; font-size: .72rem; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
  .item { flex-wrap: wrap; }
  .item-tools { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Modo edición: secciones de solo lectura hasta tocar "Editar" */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.stack { display: flex; flex-direction: column; gap: 14px; }
.edit-badge { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 10px; background: rgba(255,122,0,.14); color: var(--orange); font-weight: 800; font-size: .82rem; }
.tag-off { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: var(--soft); color: var(--muted); font-size: .72rem; font-weight: 700; vertical-align: middle; }
fieldset:disabled input:not([type=checkbox]), fieldset:disabled textarea, fieldset:disabled select { opacity: 1; background: var(--soft-a); border-color: transparent; color: var(--text); -webkit-text-fill-color: var(--text); cursor: default; }
fieldset:disabled label.btn { display: none; }
fieldset:disabled .chip-btn { cursor: default; opacity: 1; }
fieldset:disabled .chip-btn:hover { border-color: var(--line); }
fieldset:disabled .switch { opacity: .75; }
fieldset:disabled .d-from, fieldset:disabled .d-to { -webkit-text-fill-color: var(--text); }

/* Logo de Niam: las letras toman el color del texto (claro/oscuro); el punto es naranja de marca. */
.niam-logo { height: 26px; width: auto; color: var(--text); display: block; }
.topbar .niam-logo { height: 22px; }
.login-card .niam-logo { height: 32px; margin-bottom: 4px; }

/* Código QR */
.qr-card { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 24px; align-items: start; }
.qr-box { background: #fff; border-radius: 16px; padding: 10px; border: 1px solid var(--line); line-height: 0; }
.qr-box canvas { width: 100%; height: auto; image-rendering: pixelated; }
.qr-link { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.qr-link a { word-break: break-all; font-weight: 600; color: var(--orange); }
.qr-tips { margin-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: .9rem; color: var(--dark); }
@media (max-width: 640px) { .qr-card { grid-template-columns: 1fr; } .qr-box { max-width: 300px; margin: 0 auto; } }
