:root{
  --bg:#0b0f17;
  --panel:#0f1623;
  --panel-2:#0c1220;
  --border:rgba(255,255,255,.08);
  --text:#e8edf7;
  --muted:rgba(232,237,247,.65);

  --chip:#131d2d;
  --chip-on:#1d2b44;

  --accent:#7dd3fc;
  --ok:#34d399;
  --warn:#fbbf24;
  --danger:#fb7185;

  --shadow: 0 18px 60px rgba(0,0,0,.35);
  --radius:16px;
  --radius-sm:12px;
  text-rendering:optimizeLegibility;
  font-synthesis-weight:none;
}

*{ box-sizing:border-box; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background:
    radial-gradient(1000px 500px at 20% 0%, rgba(125,211,252,.10), transparent 60%),
    radial-gradient(900px 500px at 80% 20%, rgba(52,211,153,.08), transparent 55%),
    var(--bg);
  color:var(--text);
}
html, body {
  height: 100%;
  overflow: hidden; /* important: prevents whole-page scroll */
}

/* Make HTML hidden attribute bulletproof */
[hidden] { display: none !important; }

.app{
  height:100vh;
  display:flex;
  flex-direction:column;
  overflow: hidden;
}

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 18px;
  border-bottom:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.04), transparent);
  position:sticky; top:0; z-index:20;
  backdrop-filter: blur(10px);
}

select{
  width:100%;
  padding:12px 12px;
  border-radius: 12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);
  outline:none;
}
select option{ background:#0b0f17; }

.brand{ display:flex; gap:12px; align-items:center; }
.logo{
  width:40px; height:40px; border-radius:12px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, rgba(125,211,252,.25), rgba(52,211,153,.18));
  border:1px solid var(--border);
  box-shadow: var(--shadow);
  font-weight:900;
}
.title{ font-weight:900; letter-spacing:.2px; }
.subtitle{ font-size:12px; color:var(--muted); margin-top:2px; }

.top-actions{ display:flex; gap:10px; align-items:center; }
.pill{
  padding:8px 10px; border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  font-size:12px;
}
.pill.muted{ color:var(--muted); }

.main{
  display:grid;
  grid-template-columns: 460px 1fr;
  gap:14px;
  padding:14px;
  flex:1;
  min-height: 0;
  overflow: hidden;
}

.panel{
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent 45%), var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
  min-height: 0;
}

.panel.left{ display:flex; flex-direction:column; min-height: 0;}
.panel.right{
  position:relative;
  min-height: 0;
  overflow: hidden;
}

.toolbar{
  padding:14px;
  border-bottom:1px solid var(--border);
  background: var(--panel-2);
}

.toolbar-row{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
}

.search input{
  width:100%;
  padding:12px 12px;
  border-radius: 12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color:var(--text);
  outline:none;
}

.tabs{ display:flex; gap:8px; }
.tab{
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color:var(--text);
  padding:10px 12px;
  border-radius:999px;
  font-size:12px;
  cursor:pointer;
  font-weight:800;
}
.tab.active{
  border-color: rgba(125,211,252,.45);
  background: rgba(125,211,252,.10);
}

.datebar{
  display:flex;
  gap:10px;
  align-items:flex-end;
  margin-top:12px;
  flex-wrap:wrap;
}

.datefield{ display:flex; flex-direction:column; gap:6px; }
.datefield input{
  padding:10px 10px;
  border-radius: 12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);
  outline:none;
  min-width: 140px;
}

.filters{ display:flex; gap:8px; margin-top:12px; flex-wrap:wrap; }

.small{ font-size:12px; }
.muted{ color:var(--muted); }

.chip{
  border:1px solid var(--border);
  background: var(--chip);
  color:var(--text);
  padding:8px 10px;
  border-radius:999px;
  font-size:12px;
  cursor:pointer;
  font-weight:800;
}
.chip.active{ background: var(--chip-on); border-color: rgba(125,211,252,.35); }
.chip.ghost{
  background: rgba(255,255,255,.03);
}

.stats-row{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap:10px;
  margin-top:12px;
}
.stat{
  border:1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.02);
  padding:10px;
}
.stat-val{
  font-weight:900;
  font-size:16px;
  margin-top:4px;
}

.list-header{
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  font-weight:800;
}

.order-list{
  overflow:auto;
  padding:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height:0;
  flex: 1;
}

.order-card{
  border:1px solid var(--border);
  border-radius: 14px;
  padding:12px;
  cursor:pointer;
  background: rgba(255,255,255,.02);
  transition: transform .12s ease, border-color .12s ease;
}
.order-card:hover{ transform: translateY(-1px); border-color: rgba(125,211,252,.22); }
.order-card.active{ border-color: rgba(125,211,252,.45); background: rgba(125,211,252,.06); }

.row{ display:flex; justify-content:space-between; gap:10px; align-items:flex-start; }

.badge{
  font-size:12px;
  padding:6px 9px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  font-weight:900;
}
.badge.pending{ border-color: rgba(251,191,36,.35); color: rgba(251,191,36,.95); }
.badge.complete{ border-color: rgba(52,211,153,.35); color: rgba(52,211,153,.95); }
.badge.cancelled{ border-color: rgba(251,113,133,.35); color: rgba(251,113,133,.95); }
.badge.refunded{ border-color: rgba(251,113,133,.35); color: rgba(251,113,133,.95); opacity:.85; }

.tabpane{
  height:100%;
  min-height:0;
  overflow:auto;
 }
.empty{
  height:100%;
  display:grid;
  place-items:center;
  padding:24px;
}
.empty-card{
  width:min(620px, 100%);
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.02);
  padding:18px;
}
.empty-title{ font-weight:900; font-size:18px; }
.empty-subtitle{ margin-top:6px; color:var(--muted); }

.details{ height:100%; overflow:auto; }
.details-header{
  padding:16px;
  border-bottom:1px solid var(--border);
  display:flex; justify-content:space-between; align-items:flex-start; gap:10px;
  background: var(--panel-2);
  position:sticky;
  top:0;
  z-index:5;
}
.h-title{ font-weight:950; font-size:18px; }
.h-sub{ color:var(--muted); font-size:12px; margin-top:4px; }

.status-pill{
  border:1px solid var(--border);
  padding:8px 10px;
  border-radius:999px;
  font-weight:900;
  font-size:12px;
  background: rgba(255,255,255,.03);
}

.grid{
  padding:14px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}

.card{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.02);
  padding:14px;
}
.card.span-2{ grid-column: span 2; }

.card-title{
  font-weight:950;
  margin-bottom:10px;
  letter-spacing:.2px;
}

.kv{ display:grid; gap:8px; }
.kv .line{
  display:flex; justify-content:space-between; gap:10px;
  font-size:13px;
}
.kv .key{ color:var(--muted); }
.kv .val{ text-align:right; }

.items{ display:grid; gap:8px; }
.item{
  display:flex; justify-content:space-between; gap:10px;
  padding:10px;
  border:1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
  font-size:13px;
}
.total{
  margin-top:10px;
  display:flex; justify-content:space-between;
  padding-top:10px;
  border-top:1px solid var(--border);
  font-weight:950;
}

.note-compose textarea,
.form textarea{
  width:100%;
  min-height:84px;
  resize:vertical;
  padding:12px;
  border-radius: 12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color:var(--text);
  outline:none;
}
.form input,
.settings-row input{
  width:100%;
  padding:12px 12px;
  border-radius: 12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color:var(--text);
  outline:none;
}

.btn-row{ display:flex; gap:10px; margin-top:10px; flex-wrap:wrap; }

.btn{
  border:1px solid rgba(125,211,252,.35);
  background: rgba(125,211,252,.14);
  color: var(--text);
  padding:10px 12px;
  border-radius: 12px;
  cursor:pointer;
  font-weight:900;
  font-size:12px;
}
.btn:hover{ border-color: rgba(125,211,252,.55); }
.btn.ghost{
  border-color: var(--border);
  background: rgba(255,255,255,.03);
}
.btn.ok{
  border-color: rgba(52,211,153,.35);
  background: rgba(52,211,153,.14);
}
.btn.warn{
  border-color: rgba(251,191,36,.35);
  background: rgba(251,191,36,.14);
}
.btn.danger{
  border-color: rgba(251,113,133,.35);
  background: rgba(251,113,133,.14);
}

.status-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.notes{ margin-top:12px; display:grid; gap:10px; }
.note{
  border:1px solid var(--border);
  border-radius: 14px;
  padding:12px;
  background: rgba(255,255,255,.02);
}
.note .meta{ display:flex; justify-content:space-between; color:var(--muted); font-size:12px; }
.note .text{ margin-top:8px; font-size:13px; line-height:1.4; white-space:pre-wrap; }

.toast{
  position:sticky;
  bottom:14px;
  margin: 0 14px 14px 14px;
  padding:12px 14px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(10px);
  font-size:13px;
}

.overlay{
  position:fixed; inset:0;
  background: rgba(0,0,0,.55);
  display:grid;
  place-items:center;
  z-index:100;
  padding:18px;
}

.modal{
  width:min(420px, 100%);
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  box-shadow: var(--shadow);
  padding:16px;
}
.modal.wide{ width:min(720px, 100%); }
.modal-title{ font-weight:950; font-size:18px; }
.modal-subtitle{ margin-top:6px; color:var(--muted); font-size:12px; }

.form{ margin-top:12px; display:grid; gap:10px; }
.form label{ font-size:12px; color:var(--muted); font-weight:800; }

.settings-row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

@media (max-width: 980px){
  .main{ grid-template-columns: 1fr; }
  .stats-row{ grid-template-columns: 1fr; }
}

.loading-overlay{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(6px);
}

.spinner{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 3px solid rgba(255,255,255,.18);
  border-top-color: rgba(255,255,255,.85);
  animation: spin 0.8s linear infinite;
}

.loading-text{
  margin-top: 10px;
  font-size: 13px;
  color: rgba(232,237,247,.85);
  font-weight: 800;
}

@keyframes spin{
  from{ transform: rotate(0deg); }
  to{ transform: rotate(360deg); }
}

.copyable{
  cursor: pointer;
  display: inline-block;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px dashed rgba(255,255,255,.18);
  background: rgba(255,255,255,.02);
}

.copyable:hover{
  border-color: rgba(125,211,252,.35);
  background: rgba(125,211,252,.06);
}

.note-actions{
  display:flex;
  gap:8px;
  margin-top:10px;
  flex-wrap:wrap;
}

.btn-mini{
  padding:8px 10px;
  font-size:11px;
  border-radius:12px;
}

.note-edit{
  width:100%;
  min-height:70px;
  margin-top:10px;
  padding:10px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);
  outline:none;
  resize: vertical;
}

.sep{
  border:0;
  border-top:1px solid var(--border);
  margin:14px 0;
  opacity:.9;
}

.tenant-select{
  padding:8px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);
  font-weight: 900;
  font-size: 12px;
}