/* ============ Joy — design system ============
   Premium spa aesthetic sampled from the equipment: white surfaces,
   charcoal/near-black chrome, warm gold accent. */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --ink: #171b23;
  --muted: #6b7482;
  --faint: #9aa2ae;
  --line: #e7e9ee;
  --line-2: #eef0f3;
  --gold: #c6a15b;
  --gold-d: #a8843f;
  --gold-soft: #f6efe1;
  --charcoal: #14171f;
  --charcoal-2: #1d222c;
  --slate: #2a3442;
  --green: #16a34a; --green-s: #e7f6ec;
  --orange: #f59e0b; --orange-s: #fdf1dc;
  --red: #dc2626; --red-s: #fbe9e9;
  --grey: #94a3b8; --grey-s: #eef1f5;
  --blue: #2b6cb0; --blue-s: #e7f0f9;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,23,31,.04), 0 8px 24px -12px rgba(20,23,31,.18);
  --shadow-lg: 0 24px 60px -20px rgba(20,23,31,.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; font-size: 14px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: radial-gradient(120% 120% at 20% 10%, #232a36 0%, #14171f 60%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero .logo { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; }
.login-hero .logo .wordmark { font-size: 26px; font-weight: 800; letter-spacing: .02em; color: var(--gold); }
.login-hero .dot { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--gold), #e6c988); box-shadow: 0 0 0 6px rgba(198,161,91,.12); }
.login-hero h1 { font-size: 40px; line-height: 1.08; margin: 24px 0 14px; max-width: 12ch; }
.login-hero p { color: #aab2c0; max-width: 40ch; line-height: 1.6; }
.login-hero .feat { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.login-hero .feat span { font-size: 12px; padding: 6px 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; color: #cfd5df; }
.login-form { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(380px, 92vw); }
.login-card h2 { font-size: 24px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); margin-bottom: 26px; }
.demo-chips { display: grid; gap: 8px; margin-top: 18px; }
.demo-chip { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 12px; font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.demo-chip:hover { border-color: var(--gold); color: var(--ink); }
.demo-chip b { color: var(--ink); font-weight: 600; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.sidebar { background: var(--charcoal); color: #cdd3dd; display: flex; flex-direction: column; padding: 18px 14px; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand .dot { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--gold), #e6c988); }
.brand b { color: var(--gold); font-size: 16px; letter-spacing: .02em; font-weight: 800; }
details.visits-dd > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; padding: 6px 0; }
details.visits-dd > summary::-webkit-details-marker { display: none; }
details.visits-dd > summary::before { content: '▸'; color: var(--muted); font-size: 12px; transition: transform .15s; }
details.visits-dd[open] > summary::before { transform: rotate(90deg); }
details.visits-dd > summary .dd-title { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.link-btn { background: none; border: none; color: var(--gold-d); cursor: pointer; font-size: 13px; padding: 0 3px; }
.link-btn:hover { color: var(--gold); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.brand small { display:block; color:#7b8494; font-weight:500; font-size:11px; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6b7484; padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; color: #c2c9d4; font-size: 13.5px; border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(198,161,91,.22), rgba(198,161,91,.06)); color: #fff; box-shadow: inset 2px 0 0 var(--gold); }
.nav-item .ic { width: 18px; text-align: center; opacity: .9; }
.sidebar .spacer { flex: 1; }
.side-user { border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; margin-top: 8px; font-size: 12.5px; }
.side-user .nm { color: #fff; font-weight: 600; }
.side-user .rl { color: #7b8494; text-transform: capitalize; }

.main { overflow-y: auto; height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(244,245,247,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 14px 26px; display: flex; align-items: center; gap: 16px; }
.topbar h1 { font-size: 19px; }
.topbar .sub { color: var(--muted); font-size: 12.5px; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.content { padding: 24px 26px 60px; flex: 1; }

/* ---------- Generic UI ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.grid { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; }
.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-variant-numeric: tabular-nums; }
.right-align { text-align: right; }
.sec-title { display:flex; align-items:center; gap:10px; margin: 4px 0 14px; }
.sec-title h2 { font-size: 16px; }
.sec-title .count { color: var(--muted); font-size: 13px; }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 9px 15px; border-radius: 10px; font-size: 13.5px; font-weight: 550; display: inline-flex; align-items: center; gap: 7px; transition: .12s; }
.btn:hover { border-color: #d3d7de; box-shadow: var(--shadow); }
.btn.primary { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }
.btn.primary:hover { background: #000; }
.btn.gold { background: var(--gold); border-color: var(--gold-d); color: #241c08; }
.btn.gold:hover { background: var(--gold-d); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--grey-s); color: var(--ink); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.danger { color: var(--red); border-color: #f2cfcf; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); outline: none; }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(198,161,91,.14); }
.field.inline { grid-template-columns: 1fr 1fr; gap: 12px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.chip .d { width: 7px; height: 7px; border-radius: 50%; }
.c-green { background: var(--green-s); color: #0f7a37; } .c-green .d { background: var(--green); }
.c-orange { background: var(--orange-s); color: #9a6206; } .c-orange .d { background: var(--orange); }
.c-red { background: var(--red-s); color: #b71c1c; } .c-red .d { background: var(--red); }
.c-grey, .c-guest { background: var(--grey-s); color: #566072; } .c-grey .d, .c-guest .d { background: var(--grey); }
.c-blocked { background: #201b1b; color: #ffb4b4; } .c-blocked .d { background: #ff6b6b; }
.c-frozen { background: var(--blue-s); color: #1e558c; } .c-frozen .d { background: var(--blue); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); }
.tbl tr:hover td { background: var(--panel-2); }
.tbl tr:last-child td { border-bottom: none; }
.tbl .clickable { cursor: pointer; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 550; }
.kpi .val { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
.kpi .val small { font-size: 14px; color: var(--muted); font-weight: 500; }
.kpi .sub { font-size: 12px; margin-top: 4px; }

/* Live grid */
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 13px; }
.face-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border-top: 4px solid var(--grey); }
.face-card.b-green { border-top-color: var(--green); } .face-card.b-orange { border-top-color: var(--orange); }
.face-card.b-red { border-top-color: var(--red); } .face-card.b-blocked { border-top-color: #ff5252; }
.face-card.b-frozen { border-top-color: var(--blue); } .face-card.b-guest, .face-card.b-grey { border-top-color: var(--grey); }
.face-card .avatar { height: 118px; display: grid; place-items: center; background: linear-gradient(160deg, #f0f2f5, #e5e8ee); font-size: 34px; font-weight: 700; color: #9aa3b1; overflow: hidden; }
.face-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.face-card .avatar.guest { background: repeating-linear-gradient(45deg, #eef1f5, #eef1f5 10px, #e8ebf0 10px, #e8ebf0 20px); }
.face-card .meta { padding: 10px 12px; }
.face-card .meta .nm { font-weight: 620; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.face-card .meta .mn { color: var(--faint); font-size: 11.5px; }
.face-card .meta .tm { font-size: 12px; color: var(--muted); margin-top: 5px; display:flex; justify-content:space-between; }
.face-card .badge { position: absolute; top: 8px; right: 8px; font-size: 10.5px; padding: 2px 8px; border-radius: 999px; background: rgba(20,23,31,.72); color: #fff; }
.face-card.out { opacity: .74; }

.empty { text-align: center; color: var(--faint); padding: 40px; }
.seg { display: inline-flex; background: var(--grey-s); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: none; background: none; padding: 6px 13px; border-radius: 8px; font-size: 12.5px; color: var(--muted); font-weight: 550; }
.seg button.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* Modal */
#modal-root:empty, #toast-root:empty { display: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(20,23,31,.42); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(560px, 96vw); max-height: 92vh; overflow: auto; }
.modal.wide { width: min(920px, 96vw); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--panel); }
.x { border: none; background: none; font-size: 20px; color: var(--muted); line-height: 1; }

/* Toast */
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: grid; gap: 10px; }
.toast { background: var(--charcoal); color: #fff; padding: 12px 18px; border-radius: 11px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .2s; }
.toast.err { background: #7f1d1d; }
.toast.ok { background: #14532d; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* Charts */
.chart-card { padding: 18px; }
.chart-card h3 { font-size: 14px; margin-bottom: 2px; }
.chart-card .h-sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
svg.chart { width: 100%; display: block; overflow: visible; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* POS */
.pos { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.pos .catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 12px; }
.pos-item { border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: var(--panel); text-align: left; }
.pos-item:hover { border-color: var(--gold); box-shadow: var(--shadow); }
.pos-item .nm { font-weight: 600; font-size: 13px; }
.pos-item .pr { color: var(--gold-d); font-weight: 700; margin-top: 6px; }
.pos-item .tag { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cart { position: sticky; top: 86px; }
.cart-line { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.cart-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 16px; margin: 12px 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: .2s; z-index: 90; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 89; }
  .menu-btn { display: inline-flex !important; }
  .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; }
  .pos { grid-template-columns: 1fr; } .cart { position: static; }
  .content { padding: 16px; }
}
.menu-btn { display: none; }

@media print {
  body * { visibility: hidden; }
  .modal-bg, .modal-bg * { visibility: visible; }
  .modal-bg { position: absolute; inset: 0; background: #fff; display: block; padding: 0; }
  .modal { box-shadow: none; width: 100%; max-height: none; }
  .modal-head .x, .modal-foot { display: none; }
}
