/* ── RESET ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── DESIGN TOKENS ─────────────────────────────────────────────────────────── */
:root {
  --bg:    #08090e;
  --s1:    #0f111a;
  --s2:    #161923;
  --b1:    rgba(255,255,255,0.06);
  --b2:    rgba(255,255,255,0.11);
  --gold:  #c9a84c;
  --gold2: #e8c97a;
  --gd:    rgba(201,168,76,0.10);
  --green: #2ecc8f;
  --gnd:   rgba(46,204,143,0.10);
  --red:   #e05c5c;
  --t1:    #f0efe8;
  --t2:    #8a8a99;
  --t3:    #4a4a60;
  --r:     14px;
  --rs:    10px;
}

/* ── BASE ──────────────────────────────────────────────────────────────────── */
html, body {
  height: 100%; height: 100dvh;
  background: var(--bg);
  color: var(--t1);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── APP SHELL ─────────────────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  height: 100dvh;
  max-width: 960px;
  margin: 0 auto;
  overflow: hidden;
}

/* ── HEADER ────────────────────────────────────────────────────────────────── */
header {
  padding: max(env(safe-area-inset-top), 14px) 20px 13px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--b1);
  background: linear-gradient(180deg, rgba(201,168,76,0.05) 0%, transparent 100%);
  flex-shrink: 0;
}

.logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(201,168,76,0.26);
}

.htitle h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 19px; line-height: 1; letter-spacing: -.2px;
}
.htitle p  { font-size: 11px; color: var(--t2); margin-top: 3px; font-weight: 300; }

.hstats { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.stat {
  display: flex; flex-direction: column; align-items: center;
  background: var(--s1); border: 1px solid var(--b1);
  border-radius: 10px; padding: 6px 13px; min-width: 62px;
}
.stat-n { font-family: 'DM Serif Display', serif; font-size: 19px; color: var(--gold2); line-height: 1; }
.stat-n.g { color: var(--green); }
.stat-l { font-size: 10px; color: var(--t3); text-transform: uppercase; letter-spacing: .6px; margin-top: 2px; font-weight: 500; }

.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 7px var(--green);
  animation: pu 2s infinite; flex-shrink: 0;
}
.sync-dot.busy { background: var(--gold);  box-shadow: 0 0 7px var(--gold); }
.sync-dot.dead { background: var(--red);   box-shadow: 0 0 7px var(--red); animation: none; }

@keyframes pu { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ── SEARCH ROW ────────────────────────────────────────────────────────────── */
.search-row {
  padding: 14px 20px 0;
  display: flex; gap: 10px; align-items: center;
  flex-shrink: 0;
}
.search-wrap { flex: 1; position: relative; }
.search-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--t3); font-size: 16px; pointer-events: none;
}

#searchInput {
  width: 100%;
  background: var(--s1); border: 1.5px solid var(--b2);
  border-radius: var(--r);
  padding: 14px 13px 14px 42px;
  font-size: 17px; font-family: 'DM Sans', sans-serif; color: var(--t1);
  outline: none; -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
#searchInput::placeholder { color: var(--t3); }
#searchInput:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.12); }

.btn-add {
  width: 50px; height: 50px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  border: none; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #0a0806; cursor: pointer;
  transition: opacity .15s, transform .1s; line-height: 1;
}
.btn-add:active { opacity: .78; transform: scale(.95); }

/* ── PROGRESS BAR ──────────────────────────────────────────────────────────── */
.progress {
  height: 3px; background: var(--b1);
  margin: 10px 20px 0;
  border-radius: 2px; overflow: hidden; flex-shrink: 0;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--green));
  border-radius: 2px; transition: width .5s ease;
}

/* ── TABS ──────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px;
  padding: 10px 20px 0;
  flex-shrink: 0; overflow-x: auto;
}
.tab {
  padding: 7px 15px; border-radius: 20px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s; color: var(--t2);
  border: 1px solid transparent; white-space: nowrap; flex-shrink: 0;
}
.tab.on { background: var(--gd); border-color: rgba(201,168,76,.28); color: var(--gold2); }

/* ── GUEST LIST ────────────────────────────────────────────────────────────── */
.list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 20px 30px;
}

/* ── GUEST CARD ────────────────────────────────────────────────────────────── */
.card {
  background: var(--s1); border: 1px solid var(--b1);
  border-radius: var(--r);
  padding: 13px 14px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 13px;
  position: relative; overflow: hidden;
  transition: transform .1s, opacity .1s;
}
.card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--b2); transition: background .18s;
}
.card.ci { background: var(--gnd); border-color: rgba(46,204,143,.17); }
.card.ci::before { background: var(--green); }
.card:active { transform: scale(.99); opacity: .88; }

.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--s2), var(--b2));
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Serif Display', serif; font-size: 16px; color: var(--gold2);
  border: 1px solid var(--b2);
}
.card.ci .avatar {
  background: linear-gradient(135deg, rgba(46,204,143,.17), rgba(46,204,143,.07));
  color: var(--green); border-color: rgba(46,204,143,.24);
}

.guest-info  { flex: 1; min-width: 0; }
.guest-name  { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.ci .guest-name { color: var(--green); }
.guest-meta  { font-size: 12px; color: var(--t2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 300; }
.guest-ctime { font-size: 11px; color: var(--green); margin-top: 2px; }

.card-actions { display: flex; gap: 7px; align-items: center; flex-shrink: 0; }

.btn-checkin {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  border: none; border-radius: 9px; padding: 9px 15px;
  font-size: 13px; font-weight: 600; color: #0a0806; cursor: pointer;
  font-family: 'DM Sans', sans-serif; white-space: nowrap;
  transition: opacity .13s, transform .1s;
}
.btn-checkin:active { opacity: .76; transform: scale(.96); }
.btn-checkin.done {
  background: transparent; border: 1.5px solid rgba(46,204,143,.36);
  color: var(--green); font-weight: 500;
}

.btn-info {
  width: 34px; height: 34px;
  background: var(--s2); border: 1px solid var(--b2); border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer; color: var(--t2);
  transition: all .13s;
}
.btn-info:active, .btn-info:hover { border-color: var(--gold); color: var(--gold); }

/* ── EMPTY STATE ───────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 50px 30px; color: var(--t3); }
.empty .ic  { font-size: 42px; margin-bottom: 13px; }
.empty h3   { font-size: 16px; color: var(--t2); margin-bottom: 7px; font-family: 'DM Serif Display', serif; }
.empty p    { font-size: 13px; line-height: 1.6; }

/* ── SKELETON ──────────────────────────────────────────────────────────────── */
.skel {
  background: linear-gradient(90deg, var(--s1) 25%, var(--s2) 50%, var(--s1) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: var(--r); height: 66px; margin-bottom: 8px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── OVERLAY / CENTERED MODAL ──────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.overlay.on { opacity: 1; pointer-events: all; }

.sheet {
  background: var(--s1); border: 1px solid var(--b2);
  border-radius: 22px;
  width: 100%; max-width: 520px;
  max-height: 88dvh; overflow-y: auto;
  padding: 0 24px 28px;
  transform: scale(.95) translateY(16px);
  transition: transform .28s cubic-bezier(.34,1.3,.64,1), opacity .22s;
  opacity: 0;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.overlay.on .sheet { transform: scale(1) translateY(0); opacity: 1; }

.sheet-handle {
  width: 34px; height: 4px; background: var(--b2);
  border-radius: 2px; margin: 14px auto 20px;
}
.sheet h2 { font-family: 'DM Serif Display', serif; font-size: 21px; margin-bottom: 18px; }

/* ── CUSTOM CONFIRM DIALOG ─────────────────────────────────────────────────── */
#confirmDialog {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.76);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#confirmDialog.on { opacity: 1; pointer-events: all; }

.confirm-box {
  background: var(--s1); border: 1px solid var(--b2);
  border-radius: 22px; padding: 30px 26px 22px;
  width: 100%; max-width: 340px;
  text-align: center;
  transform: scale(.93);
  transition: transform .26s cubic-bezier(.34,1.4,.64,1);
  box-shadow: 0 24px 60px rgba(0,0,0,.7);
}
#confirmDialog.on .confirm-box { transform: scale(1); }

.confirm-icon  { font-size: 44px; margin-bottom: 14px; line-height: 1; }
.confirm-title { font-family: 'DM Serif Display', serif; font-size: 21px; margin-bottom: 9px; }
.confirm-msg   { font-size: 14px; color: var(--t2); line-height: 1.6; margin-bottom: 24px; }
.confirm-btns  { display: flex; gap: 10px; }

/* ── DETAIL VIEW / EDIT MODES ──────────────────────────────────────────────── */
.detail-view, .detail-edit { width: 100%; }
.detail-edit { display: none; }
.sheet.editing .detail-view { display: none; }
.sheet.editing .detail-edit { display: block; }

.detail-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px; margin-bottom: 6px;
}
.detail-header h2 { margin-bottom: 0; flex: 1; }

.btn-edit {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 13px; border-radius: 8px;
  font-size: 12px; font-weight: 600; font-family: 'DM Sans', sans-serif;
  background: var(--s2); border: 1px solid var(--b2); color: var(--t2);
  cursor: pointer; transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.btn-edit:hover, .btn-edit:active { border-color: var(--gold); color: var(--gold); }

/* ── FORM ──────────────────────────────────────────────────────────────────── */
.form-row  { display: grid; gap: 10px; margin-bottom: 10px; }
.form-row2 { grid-template-columns: 1fr 1fr; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .7px; color: var(--t3); }

.field input, .field select {
  background: var(--s2); border: 1.5px solid var(--b1);
  border-radius: var(--rs);
  padding: 12px; font-size: 16px; font-family: 'DM Sans', sans-serif; color: var(--t1);
  outline: none; -webkit-appearance: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.1); }
.field select option { background: var(--s2); }

.form-actions { display: flex; gap: 9px; margin-top: 16px; }

/* ── BUTTONS ───────────────────────────────────────────────────────────────── */
.btn {
  flex: 1; padding: 13px; border-radius: var(--rs);
  font-size: 15px; font-weight: 600; font-family: 'DM Sans', sans-serif;
  cursor: pointer; border: none;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: opacity .13s, transform .1s;
}
.btn:active { opacity: .8; transform: scale(.97); }
.btn-primary  { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #0a0806; }
.btn-success  { background: linear-gradient(135deg, var(--green), #27b07a); color: #03150d; }
.btn-outline  { background: transparent; border: 1.5px solid var(--b2); color: var(--t2); }
.btn-danger   { background: transparent; border: 1.5px solid rgba(224,92,92,.4); color: var(--red); }

/* ── DETAIL SHEET ──────────────────────────────────────────────────────────── */
.detail-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 18px;
  font-size: 13px; font-weight: 500; margin-bottom: 16px;
}
.detail-badge.ci { background: var(--gnd); color: var(--green); border: 1px solid rgba(46,204,143,.26); }
.detail-badge.nc { background: var(--gd);  color: var(--gold2); border: 1px solid rgba(201,168,76,.26); }

.detail-field { margin-bottom: 13px; }
.detail-field .label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .7px; color: var(--t3); margin-bottom: 3px; }
.detail-field .value { font-size: 15px; color: var(--t1); }
.detail-divider { height: 1px; background: var(--b1); margin: 14px 0; }

/* ── TOAST ─────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(14px);
  background: var(--s2); border: 1px solid var(--b2);
  border-radius: 18px; padding: 10px 20px;
  font-size: 13px; font-weight: 500; color: var(--t1);
  z-index: 200; opacity: 0; transition: all .22s;
  pointer-events: none; white-space: nowrap;
  box-shadow: 0 5px 24px rgba(0,0,0,.5);
}
#toast.on  { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok  { color: var(--green); border-color: rgba(46,204,143,.36); }
#toast.err { color: var(--red);   border-color: rgba(224,92,92,.36);  }

/* ── DEVICE BADGE ──────────────────────────────────────────────────────────── */
.device-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--gd); border: 1px solid rgba(201,168,76,.17);
  border-radius: 7px; padding: 3px 9px;
  font-size: 11px; color: var(--gold2); cursor: pointer;
}

/* ── ADD TO HOME SCREEN BANNER ─────────────────────────────────────────────── */
.a2hs {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: linear-gradient(135deg, #181c28, #0d1018);
  border-top: 1px solid var(--gold);
  padding: 13px 20px max(26px, env(safe-area-inset-bottom));
  z-index: 150; display: none; animation: slideUp .26s ease;
}
.a2hs.on  { display: block; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.a2hs-row { display: flex; align-items: center; gap: 13px; }
.a2hs h4  { font-size: 13px; color: var(--gold2); font-weight: 600; }
.a2hs p   { font-size: 12px; color: var(--t2); margin-top: 2px; }
.a2hs-close { color: var(--t3); font-size: 18px; cursor: pointer; padding: 4px; margin-left: auto; }

/* ── MISC ──────────────────────────────────────────────────────────────────── */
mark { background: rgba(201,168,76,.2); color: var(--gold2); border-radius: 3px; padding: 0 1px; }
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 2px; }
