*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:       #F4F1EC;
  --bg-el:    #FFFFFF;
  --bg-panel: rgba(255,255,255,0.92);
  --bg-h:     rgba(0,0,0,0.03);
  --ink:      #1A1A1A;
  --ink-inv:  #FFFFFF;
  --muted:    #8C857B;
  --accent:   #D94630;
  --ok:       #22C55E;
  --warn:     #D97706;
  --blue:     #2563EB;
  --bdr:      rgba(0,0,0,0.06);
  --bdr-d:    rgba(0,0,0,0.12);
  --shsm:     0 4px 24px rgba(0,0,0,0.04);
  --shmd:     0 32px 64px -12px rgba(0,0,0,0.12);
  --sans:     'Plus Jakarta Sans', sans-serif;
  --mono:     'IBM Plex Mono', monospace;
  --disp:     'Playfair Display', serif;
  --spring:   cubic-bezier(0.175,0.885,0.32,1.1);
  --ease:     cubic-bezier(0.16,1,0.3,1);
  --sidebar-w: 260px;
  --header-h:  72px;
}
[data-theme="dark"] {
  --bg:       #111111;
  --bg-el:    #1C1C1C;
  --bg-panel: rgba(28,28,28,0.92);
  --bg-h:     rgba(255,255,255,0.04);
  --ink:      #EDEDED;
  --ink-inv:  #111111;
  --muted:    #9CA3AF;
  --accent:   #E05C45;
  --bdr:      rgba(255,255,255,0.08);
  --bdr-d:    rgba(255,255,255,0.14);
  --shsm:     0 8px 32px rgba(0,0,0,0.4);
  --shmd:     0 32px 64px -12px rgba(0,0,0,0.8);
}
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  background: var(--bg) url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='1' cy='1' r='1' fill='rgba(0,0,0,0.04)'/%3E%3C/svg%3E");
  color: var(--ink); font-family: var(--sans);
  display: grid; grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh; overflow-x: hidden;
  transition: background-color .4s, color .4s;
}
[data-theme="dark"] body {
  background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='1' cy='1' r='1' fill='rgba(255,255,255,0.03)'/%3E%3C/svg%3E");
}
::-webkit-scrollbar { width: 0; height: 0; background: transparent; }
kbd {
  font-family: var(--mono); font-size: .65rem; font-weight: 700;
  background: var(--bg-h); color: var(--muted);
  padding: 2px 7px; border-radius: 6px;
  border: 1px solid var(--bdr); box-shadow: 0 1px 0 var(--bdr-d);
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px;
}
/* ── APP SHELL ── */
.app-sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--bg-el); border-right: 1px solid var(--bdr);
  display: flex; flex-direction: column; padding: 1.5rem;
  z-index: 100; overflow: hidden;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2.5rem; flex-shrink: 0;
}
.sidebar-header .logo { font-family: var(--disp); font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.sidebar-header .cafe { font-style: italic; font-weight: 500; color: var(--muted); }
.logo-tag { font-family: var(--mono); font-size: .6rem; font-weight: 700; background: var(--accent); color: #fff; padding: 3px 9px; border-radius: 999px; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-close { display: none; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-section {
  font-family: var(--mono); font-size: .6rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .12em;
  margin: 1.5rem 0 .5rem; padding-left: .75rem;
}
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .75rem; border-radius: 14px;
  font-family: var(--sans); font-size: .88rem; font-weight: 700;
  color: var(--muted); text-decoration: none;
  transition: all .2s var(--ease); position: relative; cursor: pointer;
}
.nav-item:hover { background: var(--bg-h); color: var(--ink); }
.nav-item.active { background: var(--ink); color: var(--ink-inv); box-shadow: var(--shsm); }
.nav-icon { flex-shrink: 0; opacity: .7; transition: opacity .2s; }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { opacity: 1; }
.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--bdr); display: flex; flex-direction: column; gap: .5rem; flex-shrink: 0; }

/* ── MAIN LAYOUT ── */
.app-layout { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.app-header {
  position: sticky; top: 0; z-index: 90; height: var(--header-h);
  background: var(--bg-panel); backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--bdr);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; gap: 1rem;
}
.header-search { position: relative; width: 320px; }
.header-search .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.header-search .fsearch {
  width: 100%; padding: 10px 14px 10px 40px;
  border: 1.5px solid var(--bdr); border-radius: 999px;
  background: var(--bg-el); color: var(--ink); outline: none;
  font-family: var(--sans); font-size: .88rem; transition: .25s;
}
.header-search .fsearch:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.header-actions { display: flex; align-items: center; gap: .6rem; }
.app-content { flex: 1; padding: 0 2rem 2rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.mobile-header { display: none; }

/* ── BUTTONS ── */
.icon-btn {
  background: var(--bg-h); border: none; width: 38px; height: 38px;
  border-radius: 999px; cursor: pointer; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, background .2s;
}
.icon-btn:hover { transform: scale(1.08); background: var(--ink); color: var(--ink-inv); }
.pill {
  font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  background: var(--bg-el); border: 1px solid var(--bdr);
  padding: 7px 14px; border-radius: 999px; color: var(--ink);
  display: flex; align-items: center; gap: 6px;
}
.pill.live-clock { cursor: default; min-width: 90px; justify-content: center; }
.theme-btn { background: var(--bg-h); border: none; width: 38px; height: 38px; border-radius: 999px; cursor: pointer; position: relative; overflow: hidden; outline: none; transition: transform .2s; }
.theme-btn:hover { transform: scale(1.08); }
.ticon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; transition: transform .6s var(--spring), opacity .4s; }
.ticon.sun { opacity:1; transform:translateY(0); color: var(--ok); }
.ticon.moon { opacity:0; transform:translateY(-100%); color: #A66A38; }
[data-theme="dark"] .ticon.sun  { opacity:0; transform:translateY(100%); }
[data-theme="dark"] .ticon.moon { opacity:1; transform:translateY(0); }

/* ── STAT CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 1.5rem; margin: 2rem 0; }
.stat-card {
  background: var(--bg-el); border: 1px solid var(--bdr); border-radius: 28px;
  padding: 2rem; box-shadow: var(--shsm);
  transition: transform .4s var(--spring), box-shadow .4s;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--muted); opacity: 0; transition: opacity .4s;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shmd); }
.stat-card:hover::before { opacity: 1; }
.stat-lbl { font-family: var(--mono); font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: .6rem; }
.stat-val { font-family: var(--disp); font-size: 3.2rem; font-weight: 700; color: var(--ink); letter-spacing: -.02em; line-height: 1; }
.stat-sub { font-family: var(--mono); font-size: .72rem; color: var(--muted); margin-top: 1rem; border-top: 1px solid var(--bdr); padding-top: 1rem; }

/* ── SHOP TABLE ── */
.panel-wrap {
  background: var(--bg-el); border-radius: 28px; border: 1px solid var(--bdr);
  box-shadow: var(--shsm); overflow: hidden; margin-bottom: 1.5rem;
  transition: box-shadow .3s;
}
.panel-wrap:hover { box-shadow: var(--shmd); }
.panel-top {
  padding: 1.4rem 2rem; border-bottom: 1px solid var(--bdr);
  display: flex; justify-content: space-between; align-items: center;
}
.panel-top h2 { font-family: var(--sans); font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.tbl-scroll { width: 100%; overflow-x: auto; padding-bottom: 4px; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
thead th {
  padding: 1.2rem 2rem; font-family: var(--mono); font-size: .68rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .09em;
  border-bottom: 1px solid var(--bdr); background: var(--bg-el);
  position: sticky; top: 0; z-index: 2; text-align: left;
}
tbody td { padding: 1.2rem 2rem; border-bottom: 1px solid var(--bdr); vertical-align: middle; }
tbody tr { transition: background .18s; cursor: pointer; }
tbody tr:hover { background: var(--bg-h); }
.c-name { font-family: var(--sans); font-size: .95rem; font-weight: 700; color: var(--ink); }
.c-id { font-family: var(--mono); font-size: .72rem; color: var(--muted); margin-top: 2px; }
.c-metric { font-family: var(--mono); font-weight: 700; font-size: .95rem; color: var(--ink); }

/* ── STATUS BADGES ── */
.sbadge { display: inline-flex; padding: 6px 14px; border-radius: 999px; font-family: var(--sans); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; border: 1.5px solid transparent; }
.sbadge.ok   { background: var(--ink); color: var(--ink-inv); }
.sbadge.warn { color: var(--warn); border-color: var(--warn); }
.sbadge.err  { color: var(--accent); background: rgba(217,70,48,.1); }
.sbadge.pend { color: var(--muted); border-color: var(--bdr); }
.abtn { background: var(--ink); color: var(--ink-inv); border: none; padding: 10px 20px; border-radius: 999px; font-family: var(--sans); font-size: .78rem; font-weight: 700; cursor: pointer; transition: transform .2s var(--spring); }
.abtn:hover { transform: scale(1.06); }
.abtn.danger { background: var(--accent); }
.abtn.ghost { background: transparent; border: 1.5px solid var(--bdr); color: var(--ink); }
.abtn.ghost:hover { background: var(--bg-h); }

/* ── SLIDE PANEL ── */
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); backdrop-filter: blur(8px); z-index: 1999; opacity: 0; pointer-events: none; transition: opacity .4s var(--ease); }
#overlay.on { opacity: 1; pointer-events: auto; }
.slide-panel {
  position: fixed; z-index: 2000;
  background: var(--bg-panel); backdrop-filter: blur(40px);
  display: flex; flex-direction: column;
  transition: transform .5s var(--spring), opacity .4s;
  box-shadow: var(--shmd); border: 1px solid var(--bdr);
  top:1.5rem; right:1.5rem; width:520px; height:calc(100vh - 3rem); border-radius:28px;
}
.slide-panel.off { transform: translateX(120%); opacity: 0; }
.slide-panel.on  { transform: translateX(0); opacity: 1; }
.ph { padding: 1.8rem; border-bottom: 1px solid var(--bdr); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.ph h2 { font-family: var(--sans); font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.ph-close { background: var(--bg-h); border: none; width: 38px; height: 38px; border-radius: 999px; color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: .2s; }
.ph-close:hover { background: var(--ink); color: var(--ink-inv); }
.pb { padding: 1.8rem; overflow-y: auto; flex-grow: 1; }
.pb::-webkit-scrollbar { width: 0; }
.pf { padding: 1.8rem; border-top: 1px solid var(--bdr); flex-shrink: 0; }

/* ── DETAIL CARDS ── */
.detail-card {
  background: var(--bg-el); border: 1px solid var(--bdr); border-radius: 20px;
  padding: 1.5rem; margin-bottom: 1rem; box-shadow: var(--shsm);
}
.detail-kicker { font-family: var(--mono); font-size: .65rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: .75rem; }
.detail-title { font-family: var(--disp); font-size: 2rem; font-weight: 700; color: var(--ink); margin-bottom: .5rem; }
.detail-line { font-family: var(--sans); font-size: .88rem; color: var(--muted); margin-bottom: .35rem; font-weight: 500; line-height: 1.5; }
.detail-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* ── FORM CONTROLS ── */
.pr-sec { font-family: var(--sans); font-size: 1.1rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); margin: 2rem 0 1.2rem; }
.pr-sec:first-child { margin-top: 0; }
.pr-grp { margin-bottom: 1rem; }
.pr-lbl { display: block; font-family: var(--sans); font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .45rem; }
.pr-wrap { display: flex; align-items: center; background: var(--bg-el); border: 1.5px solid var(--bdr); border-radius: 14px; overflow: hidden; transition: .2s; }
.pr-wrap:focus-within { border-color: var(--ink); }
.pr-in { flex: 1; border: none; background: transparent; padding: 14px; font-family: var(--mono); font-size: .95rem; font-weight: 700; color: var(--ink); outline: none; }
.pr-sfx { padding: 0 14px; font-family: var(--sans); font-weight: 700; color: var(--muted); font-size: .95rem; border-left: 1px solid var(--bdr); display: flex; align-items: center; height: 100%; }
.pr-row2 { display: flex; gap: .8rem; }
.pr-row2 .pr-grp { flex: 1; }
.save-btn { width: 100%; background: var(--ink); color: var(--ink-inv); font-family: var(--sans); font-size: .95rem; font-weight: 700; padding: 18px; border: none; border-radius: 999px; cursor: pointer; transition: transform .2s var(--spring); letter-spacing: .04em; text-transform: uppercase; }
.save-btn:hover { transform: scale(1.02); }
.save-btn.compact { width: auto; padding: 12px 24px; font-size: .82rem; }
.save-btn.secondary { background: var(--bg-h); color: var(--ink); }
.save-btn.danger { background: var(--accent); color: #fff; }

/* ── KV ROWS ── */
.kv-row { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .8rem; padding: 8px 0; border-bottom: 1px solid var(--bdr); color: var(--muted); }
.kv-row:last-child { border: none; }
.kv-row strong { color: var(--ink); }

/* ── TELEMETRY ── */
.tel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1rem; }
.tel-item { text-align: center; }
.tel-lbl { font-family: var(--mono); font-size: .65rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; }
.tel-val { font-family: var(--mono); font-size: 1.2rem; font-weight: 700; color: var(--ink); margin-top: .3rem; }

/* ── QR CODE ── */
.qr-container { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 2rem 0; }
.qr-container canvas, .qr-container img { border-radius: 16px; border: 1px solid var(--bdr); box-shadow: var(--shsm); }

/* ── KEY MODAL ── */
#keyModal { position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(16px); z-index: 3000; display: none; align-items: center; justify-content: center; }
#keyModal.on { display: flex; }
.key-box { background: var(--bg-el); border-radius: 28px; padding: 2.5rem; width: 380px; border: 1px solid var(--bdr); box-shadow: var(--shmd); }
.key-box h2 { font-family: var(--disp); font-size: 1.8rem; font-weight: 800; color: var(--ink); margin-bottom: .5rem; }
.key-box p { font-family: var(--sans); font-size: .88rem; color: var(--muted); margin-bottom: 1.5rem; line-height: 1.5; }
.key-in { width: 100%; font-family: var(--mono); font-size: 1rem; font-weight: 700; border: 2px solid var(--bdr); border-radius: 14px; padding: 14px 16px; background: var(--bg); color: var(--ink); outline: none; margin-bottom: .8rem; }
.key-in:focus { border-color: var(--ink); }
.key-err { font-family: var(--mono); font-size: .75rem; color: var(--accent); margin-bottom: .8rem; min-height: 1em; }
.key-btn { width: 100%; background: var(--ink); color: var(--ink-inv); font-family: var(--sans); font-size: .9rem; font-weight: 700; padding: 16px; border: none; border-radius: 999px; cursor: pointer; text-transform: uppercase; letter-spacing: .04em; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--muted); font-weight: 600; }

/* ── ADD SHOP FORM ── */
.add-shop-form { display: flex; flex-direction: column; gap: 1rem; }

/* ── FOOTER ── */
footer { padding: 2rem; text-align: center; font-family: var(--sans); font-size: .75rem; color: var(--muted); }
.foot-brand { font-family: var(--disp); font-size: .95rem; font-weight: 700; color: var(--ink); }
.foot-brand .cafe { color: var(--muted); font-style: italic; font-weight: 500; }

/* ── RESPONSIVE ── */
@media (max-width: 1200px) {
  :root { --sidebar-w: 76px; }
  .app-sidebar { padding: 1rem; align-items: center; }
  .sidebar-header .logo { display: none; }
  .sidebar-header::before {
    content: 'HQ'; font-family: var(--mono); font-size: .7rem; font-weight: 800; color: var(--ink-inv);
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    background: var(--accent); border-radius: 14px;
  }
  .nav-item { justify-content: center; padding: 12px; border-radius: 12px; }
  .nav-item span, .nav-section { display: none; }
  .sidebar-footer { align-items: center; width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  body { display: flex; flex-direction: column; }
  .app-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px;
    transform: translateX(-100%); transition: transform .4s var(--spring);
    z-index: 500; padding: 1.5rem; align-items: stretch;
    border-right: none; box-shadow: none;
  }
  .sidebar-header .logo { display: flex; font-size: 1.6rem; }
  .sidebar-header::before { display: none; }
  .sidebar-close { display: flex; }
  .nav-item { justify-content: flex-start; padding: .8rem .75rem; }
  .nav-item span, .nav-section { display: block !important; }
  body.drawer-open .app-sidebar { transform: translateX(0); box-shadow: var(--shmd); }
  body.drawer-open::after {
    content: ''; position: fixed; inset: 0;
    background: rgba(0,0,0,.3); backdrop-filter: blur(4px); z-index: 499;
  }
  .app-header { display: none; }
  .mobile-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem; background: var(--bg-panel); backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--bdr); position: sticky; top: 0; z-index: 95;
  }
  .mobile-header .logo { font-family: var(--disp); font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
  .mobile-header .cafe { font-style: italic; font-weight: 500; color: var(--muted); }
  .menu-toggle { background: var(--bg-h); border: none; width: 40px; height: 40px; border-radius: 12px; cursor: pointer; color: var(--ink); display: flex; align-items: center; justify-content: center; }
  .app-content { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr; margin: 1.5rem 0; }
  .slide-panel { bottom:0; left:0; right:0; top: auto; width:100%; height: 90vh; border-radius: 32px 32px 0 0; }
  .slide-panel.off { transform: translateY(100%); opacity: 0; }
  .slide-panel.on  { transform: translateY(0); opacity: 1; }
  .key-box { width: calc(100vw - 2rem); }
}
