:root {
  --bg: #0f172a; --bg-elev: #1e293b; --bg-elev2: #273449;
  --text: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8; --accent-strong: #0ea5e9;
  --green: #22c55e; --amber: #f59e0b; --red: #ef4444; --border: #334155;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
.hidden { display: none !important; }
button {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--border);
  background: var(--accent); color: #04283a; font-weight: 700; padding: .6rem .9rem;
}
button.ghost { background: var(--bg-elev2); color: var(--text); }
button.small { padding: .35rem .6rem; font-size: .85rem; }
button.danger { background: var(--bg-elev2); color: var(--red); border-color: var(--red); }
button.btn-move { background: var(--accent-strong); color: #04283a; }
button.btn-back { background: var(--bg-elev2); color: var(--text); }
input {
  width: 100%; padding: .6rem .7rem; margin: .25rem 0; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev2); color: var(--text); font: inherit;
}
.error { color: var(--red); font-size: .85rem; min-height: 1.1em; margin: .3rem 0 0; }
.muted { color: var(--muted); }

.screen.center { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.card { width: 100%; max-width: 380px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; text-align: center; }
.card h1 { margin: 0 0 .2rem; }
.tabs { display: flex; gap: .5rem; margin: 1rem 0; }
.tab { flex: 1; background: var(--bg-elev2); color: var(--muted); }
.tab.active { background: var(--accent); color: #04283a; }
form { display: flex; flex-direction: column; gap: .1rem; }
form button[type=submit] { margin-top: .5rem; }

#screen-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.app-header {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; padding-top: max(.75rem, env(safe-area-inset-top));
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.app-title { font-weight: 700; }
.header-right { display: flex; align-items: center; gap: .5rem; }
.chip { font-size: .8rem; color: var(--muted); background: var(--bg-elev2); padding: .2rem .55rem; border-radius: 999px; }
.chip.admin { color: var(--amber); }

.page { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 1rem; width: 100%; max-width: 640px; margin: 0 auto; }
.section-title { font-size: .95rem; color: var(--muted); margin: 1rem 0 .5rem; }
.cta { width: 100%; margin-bottom: 1rem; background: var(--bg-elev); color: var(--text); border: 1px dashed var(--green); }

.list { display: flex; flex-direction: column; gap: .5rem; }
.row { display: flex; align-items: center; gap: .6rem; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: .7rem .8rem; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { color: var(--muted); font-size: .82rem; }
.row.clickable { cursor: pointer; }
.badge-arch { font-size: .7rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 .4rem; margin-left: .3rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

.member { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.member:last-child { border-bottom: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-elev2); display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.back-link { color: var(--accent); cursor: pointer; display: inline-block; margin-bottom: .5rem; }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--bg-elev2); color: var(--text); padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--border); z-index: 40; transition: opacity .2s; }
.toast.hidden { opacity: 0; pointer-events: none; }

.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 1rem; }
.modal-card { width: 100%; max-width: 360px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; padding: 1.25rem; text-align: center; }
.modal-card h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.modal-actions { display: flex; gap: .5rem; margin-top: .6rem; }
.modal-actions button { flex: 1; }
.qr-box { display: grid; place-items: center; margin: .5rem 0; background: #fff; padding: .5rem; border-radius: 10px; }
.qr-box svg { width: 200px; height: 200px; }
.invite-url { font-size: .8rem; word-break: break-all; color: var(--muted); }

/* Balante */
.bal { font-weight: 700; white-space: nowrap; }
.bal.pos { color: var(--green); }
.bal.neg { color: var(--red); }
.bal.zero { color: var(--muted); }
.icon-x { background: var(--bg-elev2); color: var(--red); border: 1px solid var(--border); width: 34px; height: 34px; padding: 0; border-radius: 8px; flex: none; }

/* Bonuri (listare) */
.receipt-items { border-top: 1px solid var(--border); padding-top: .3rem; display: flex; flex-direction: column; gap: .15rem; }
.ri { display: flex; justify-content: space-between; gap: .5rem; font-size: .82rem; }
.ri .muted { white-space: nowrap; }

/* Adauga bon */
.lbl { display: block; text-align: left; font-size: .8rem; color: var(--muted); margin: .6rem 0 .2rem; }
.sel { width: 100%; padding: .55rem .6rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev2); color: var(--text); font: inherit; }
.ar-item { border: 1px solid var(--border); border-radius: 12px; padding: .5rem; margin-bottom: .5rem; background: var(--bg-elev); }
.ar-item-top { display: grid; grid-template-columns: 1fr 68px 44px 36px; gap: .3rem; align-items: center; }
.ar-item-top input { margin: 0; padding: .4rem; }
.ar-price, .ar-qty { text-align: right; }
.ar-split-line { display: flex; justify-content: space-between; align-items: center; margin-top: .35rem; }
.ar-split-editor { margin-top: .4rem; border-top: 1px solid var(--border); padding-top: .4rem; display: flex; flex-direction: column; gap: .25rem; }
.ar-share { display: flex; align-items: center; gap: .5rem; }
.ar-share .grow { flex: 1; }
.ar-share input[type=checkbox] { width: 18px; height: 18px; flex: none; margin: 0; }
.ar-samount { width: 80px; margin: 0; padding: .35rem; text-align: right; }

/* Thumbnails poze */
.newrest-thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.nr-thumb { position: relative; width: 76px; height: 76px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.nr-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.nr-thumb-x { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; padding: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; border: none; font-size: .8rem; line-height: 1; }

/* ===== Faza 1b/2 UI ===== */
.icon-btn { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; background: var(--bg-elev2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; }
.lbl { display: block; text-align: left; font-size: .78rem; color: var(--muted); margin: .6rem 0 .2rem; }
.sel { width: 100%; padding: .55rem .6rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev2); color: var(--text); font: inherit; }
button.xsmall { padding: .3rem .5rem; font-size: .78rem; }
.modal-card.modal-wide { max-width: 560px; max-height: calc(100dvh - 2rem); display: flex; flex-direction: column; overflow: hidden; }
.modal-card.modal-wide > h2 { flex: none; }
.modal-card.modal-wide > .modal-actions { flex: none; }
.modal-scroll { flex: 1 1 auto; min-height: 0; max-height: 66vh; max-height: 66dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; text-align: left; }

.ev-head { display: flex; align-items: center; justify-content: space-between; }
.ev-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: 1.2rem; font-weight: 700; margin: .3rem 0 .2rem; }
.panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: .3rem .7rem; }
.bal { font-weight: 700; white-space: nowrap; }
.bal.pos { color: var(--green); } .bal.neg { color: var(--red); } .bal.zero { color: var(--muted); }

.check-ok { background: rgba(34,197,94,.12); border: 1px solid var(--green); color: var(--green); border-radius: 10px; padding: .45rem .6rem; font-size: .82rem; margin-bottom: .5rem; }
.check-warn { background: rgba(245,158,11,.12); border: 1px solid var(--amber); color: var(--amber); border-radius: 10px; padding: .45rem .6rem; font-size: .82rem; margin-bottom: .5rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-toggle { background: var(--bg-elev2); color: var(--muted); border: 1px solid var(--border); padding: .35rem .6rem; font-weight: 600; font-size: .85rem; }
.chip-toggle.on { background: var(--accent); color: #04283a; border-color: var(--accent); }

.rate-row { display: flex; align-items: center; gap: .3rem; margin-top: .3rem; }
.rate-row input { width: 90px; margin: 0; text-align: right; }

.thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.thumb { position: relative; width: 76px; height: 76px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb-x { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; padding: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; border: none; font-size: .8rem; line-height: 1; }
.thumb-x2 { background: var(--bg-elev2); color: var(--red); border: 1px solid var(--border); width: 34px; height: 34px; padding: 0; border-radius: 8px; }

.img-lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; padding: 1rem; cursor: zoom-out; }
.img-lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* Add-receipt items */
.ar-item { border: 1px solid var(--border); border-radius: 12px; padding: .5rem; margin-bottom: .5rem; background: var(--bg-elev); }
.ar-item-top { display: grid; grid-template-columns: 1fr 64px 40px 34px; gap: .3rem; align-items: center; }
.ar-item-top input { margin: 0; padding: .4rem; }
.ar-price, .ar-qty { text-align: right; }
.ar-split-line { display: flex; justify-content: space-between; align-items: center; margin-top: .35rem; }
.ar-split-editor { margin-top: .4rem; border-top: 1px solid var(--border); padding-top: .4rem; display: flex; flex-direction: column; gap: .25rem; }
.ar-share { display: flex; align-items: center; gap: .5rem; }
.ar-share .grow { flex: 1; }
.ar-share input[type=checkbox] { width: 18px; height: 18px; flex: none; margin: 0; }
.ar-samount, .rcs-amt { width: 78px; margin: 0; padding: .35rem; text-align: right; }

/* Receipt detail modal */
.rc-meta { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.rc-items { display: flex; flex-direction: column; }
.rc-item { border-top: 1px solid var(--border); padding: .5rem 0; }
.rc-item:first-child { border-top: none; }
.rc-item-top { display: flex; justify-content: space-between; gap: .5rem; }
.rc-name { font-weight: 600; }
.rc-price { white-space: nowrap; }
.rc-split { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.rc-actions { display: flex; gap: .35rem; margin-top: .35rem; }
.rc-actions .del, .usr-actions .del { color: var(--red); }
.rc-split-editor { margin-top: .4rem; border-top: 1px dashed var(--border); padding-top: .4rem; display: flex; flex-direction: column; gap: .25rem; }

/* Users modal */
.usr { display: flex; align-items: flex-start; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.usr:last-child { border-bottom: none; }
.usr .grow { flex: 1; min-width: 0; }
.usr-actions { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: flex-end; max-width: 55%; }
.badge-block { font-size: .7rem; color: var(--red); border: 1px solid var(--red); border-radius: 999px; padding: 0 .4rem; }

/* ---- Drawer (burger) — cont comun / navigare intre aplicatii ---- */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer.hidden { display: none; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.drawer-panel { position: absolute; top: 0; left: 0; bottom: 0; width: 82%; max-width: 320px; background: var(--bg-elev); border-right: 1px solid var(--border); padding: 18px 16px; overflow-y: auto; box-shadow: 6px 0 30px rgba(0,0,0,.4); animation: drawer-in .16s ease; }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.drawer-head { font-weight: 800; font-size: 18px; margin-bottom: 14px; }
.drawer-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 6px; font-weight: 700; }
.drawer-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; text-decoration: none; padding: 12px; border-radius: 10px; background: var(--bg-elev2); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: 15px; margin-bottom: 8px; cursor: pointer; }
.drawer-item:active { background: var(--border); }
.drawer-item.current { border-color: var(--accent); background: #12314a; }
.drawer-item.danger { color: var(--red); border-color: rgba(239,68,68,.4); }
.drawer-user { font-size: 13px; color: var(--muted); padding: 4px 2px 8px; }
