:root{
  --bg:#0e0f14;
  --panel:#171823;
  --panel2:#1f2130;
  --text:#e8e8f0;
  --muted:#a8a8b9;
  --accent:#7c5cff;
  --good:#2fe28d;
  --bad:#ff4d6d;
  --warn:#ffd166;
  --border:#2b2d3f;
  --shadow:#00000099;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  color:var(--text);
  background:var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
  line-height:1.35;
  -webkit-font-smoothing:none;
  text-rendering:geometricPrecision;
}

/* pixel-ish backdrop */
body:before{
  content:'';
  position:fixed;
  inset:0;
  background:
    linear-gradient(0deg, transparent 24%, #ffffff0a 25%, #ffffff0a 26%, transparent 27%, transparent 74%, #ffffff0a 75%, #ffffff0a 76%, transparent 77%),
    linear-gradient(90deg, transparent 24%, #ffffff0a 25%, #ffffff0a 26%, transparent 27%, transparent 74%, #ffffff0a 75%, #ffffff0a 76%, transparent 77%);
  background-size:24px 24px;
  pointer-events:none;
  opacity:.35;
}

.app{display:flex; min-height:100vh; position:relative}

/* sidebar backdrop (mobile) */
.backdrop{display:none}
@media (max-width: 860px){
  .backdrop{
    display:block;
    position:fixed;
    inset:0;
    background:#00000088;
    z-index:998;
    opacity:0;
    pointer-events:none;
    transition:opacity .15s ease;
  }
  .menu-open .backdrop{
    display:block;
    opacity:1;
    pointer-events:auto;
  }
}

.sidebar{
  width:260px;
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border-right:3px solid var(--border);
  box-shadow:6px 0 0 var(--shadow);
  padding:16px;
  position:sticky;
  top:0;
  height:100vh;
}

.brand{display:flex; gap:12px; align-items:center; padding:10px; border:3px solid var(--border); background:#0f1020; box-shadow:6px 6px 0 var(--shadow); border-radius:14px}
.brand-logo{width:36px; height:36px; background:var(--accent); border:3px solid #ffffff22; box-shadow: inset -6px -6px 0 #00000055; border-radius:10px; image-rendering:pixelated}
.brand-title{font-weight:900; letter-spacing:.5px}
.brand-sub{color:var(--muted); font-size:12px}

.nav{margin-top:16px; display:grid; gap:10px}
.nav-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:10px 12px;
  border:3px solid var(--border);
  background:#111224;
  box-shadow:4px 4px 0 var(--shadow);
  border-radius:14px;
  color:var(--text);
  text-decoration:none;
  transition:transform .05s ease;
}
.nav-item:hover{transform:translate(-1px,-1px)}
.nav-item.active{background:var(--accent); border-color:#ffffff22}

.sidebar-footer{position:absolute; left:16px; right:16px; bottom:16px; display:grid; gap:10px}
.userchip{display:flex; gap:10px; align-items:center; padding:10px 12px; border:3px solid var(--border); background:#111224; box-shadow:4px 4px 0 var(--shadow); border-radius:14px}
.userchip-dot{width:10px; height:10px; background:var(--good); border:2px solid #000; box-shadow:2px 2px 0 var(--shadow); border-radius:4px}
.userchip-name{font-weight:800}
.userchip-role{color:var(--muted); font-size:12px}

.main{flex:1; min-width:0; padding:16px 16px 90px}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px;
  border:3px solid var(--border);
  background:linear-gradient(180deg,#111224,#0f1020);
  box-shadow:6px 6px 0 var(--shadow);
  border-radius:16px;
  position:sticky;
  top:16px;
  z-index:10;
}
.topbar-left{display:flex; align-items:center; gap:10px; min-width:0}
.topbar-title{font-weight:900; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.burger{display:none}

.content{margin-top:14px}

.card{
  border:3px solid var(--border);
  background:linear-gradient(180deg,var(--panel),#111224);
  box-shadow:6px 6px 0 var(--shadow);
  border-radius:18px;
  padding:14px;
  margin-bottom:14px;
}
.card h2{margin:0 0 10px 0; font-size:16px}

.grid{display:grid; gap:14px}
.grid.cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.grid.cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}

.kpi{
  padding:12px;
  border:3px solid var(--border);
  background:#0f1020;
  box-shadow:4px 4px 0 var(--shadow);
  border-radius:16px;
}
.kpi .label{color:var(--muted); font-size:12px}
.kpi .value{font-size:18px; font-weight:900; margin-top:4px}

.alert{padding:10px 12px; border:3px solid var(--border); border-radius:14px; box-shadow:4px 4px 0 var(--shadow); margin-bottom:12px}
.alert.success{background:#0b2a1c; border-color:#1d8d5b}
.alert.error{background:#2a0b13; border-color:#ff4d6d55}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 12px;
  border:3px solid var(--border);
  background:#111224;
  box-shadow:4px 4px 0 var(--shadow);
  border-radius:14px;
  color:var(--text);
  text-decoration:none;
  cursor:pointer;
}
.btn:hover{transform:translate(-1px,-1px)}
.btn:active{transform:translate(0,0)}
.btn-primary{background:var(--accent); border-color:#ffffff22}
.btn-danger{background:var(--bad); border-color:#ffffff22}
.btn-ghost{background:transparent}
.btn-small{padding:8px 10px; border-radius:12px; font-size:12px}

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

.input, select{
  width:100%;
  padding:10px 12px;
  border:3px solid var(--border);
  background:#0f1020;
  color:var(--text);
  border-radius:14px;
  box-shadow:4px 4px 0 var(--shadow);
  outline:none;
}
label{display:block; color:var(--muted); font-size:12px; margin-bottom:6px}
.form-grid{display:grid; gap:12px}
.form-grid.cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}

.table-wrap{overflow:auto; border-radius:16px}
.table{width:100%; border-collapse:separate; border-spacing:0}
.table th,.table td{padding:10px; border-bottom:2px dashed #ffffff14; text-align:left; font-size:13px}
.table th{color:var(--muted); font-weight:800}
.table tr:hover td{background:#ffffff06}

.badge{display:inline-flex; padding:4px 8px; border:2px solid var(--border); border-radius:999px; font-size:12px; box-shadow:2px 2px 0 var(--shadow); background:#0f1020}
.badge.good{border-color:#1d8d5b; color:var(--good)}
.badge.warn{border-color:#a27b00; color:var(--warn)}
.badge.bad{border-color:#ff4d6d66; color:var(--bad)}

.pager{display:flex; gap:8px; align-items:center; justify-content:flex-end; margin-top:10px; flex-wrap:wrap}
.pager .meta{color:var(--muted); font-size:12px}

.modal{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:#000000aa;
  z-index:999;
  padding:16px;
}
.modal.open{display:flex}
.modal .box{
  width:min(520px,100%);
  border:3px solid var(--border);
  background:linear-gradient(180deg,var(--panel),#0f1020);
  box-shadow:10px 10px 0 var(--shadow);
  border-radius:18px;
  padding:14px;
  max-height:calc(100vh - 32px);
  overflow:auto;
}
.modal .title{font-weight:900; margin-bottom:10px}
.modal .actions{display:flex; gap:10px; justify-content:flex-end; margin-top:12px; flex-wrap:wrap}

.bottomnav{
  position:fixed;
  left:0; right:0; bottom:0;
  display:none;
  gap:8px;
  padding:10px;
  background:#0f1020f2;
  border-top:3px solid var(--border);
  backdrop-filter:blur(6px);
}
.bottomnav-item{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
  padding:8px;
  border:3px solid var(--border);
  background:#111224;
  box-shadow:4px 4px 0 var(--shadow);
  border-radius:14px;
  color:var(--text);
  text-decoration:none;
  font-size:16px;
}
.bottomnav-item span{font-size:11px; color:var(--muted)}
.bottomnav-item.active{background:var(--accent); border-color:#ffffff22}

@media (max-width: 980px){
  .grid.cols-3{grid-template-columns:1fr}
  .grid.cols-2{grid-template-columns:1fr}
}

@media (max-width: 860px){
  .sidebar{position:fixed; left:-320px; top:0; bottom:0; z-index:999; transition:left .15s ease}
  .sidebar.open{left:0}
  .burger{display:inline-flex; padding:8px 10px; border:3px solid var(--border); background:#111224; color:var(--text); border-radius:12px; box-shadow:4px 4px 0 var(--shadow); cursor:pointer}
  .bottomnav{display:flex}
  .main{padding:12px 12px 96px}
  .topbar{top:12px}
}

/* Print styles for thermal */
@media print{
  body:before{display:none}
  .sidebar,.topbar,.bottomnav,.btn,.pager,.no-print{display:none !important}
  .main{padding:0}
  .card{border:none; box-shadow:none; background:transparent}
}

.thermal{
  width:72mm;
  margin:0 auto;
  background:#fff;
  color:#000;
  padding:4mm;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
}
.thermal h1{font-size:14px; margin:0}
.thermal .muted{color:#444; font-size:11px}
.thermal .line{border-top:1px dashed #000; margin:6px 0}
.thermal table{width:100%; border-collapse:collapse; font-size:11px}
.thermal td{padding:2px 0; vertical-align:top}
.thermal .right{text-align:right}

/* utilities */
.muted{color:var(--muted)}
.small{font-size:12px}
.mono{font-variant-numeric:tabular-nums}
.row.right{justify-content:flex-end}
.h{font-weight:900; font-size:16px}
.m{color:var(--muted); margin-top:6px}
.thermal .center{text-align:center}
.thermal .title{font-weight:900; font-size:14px}
.thermal .hr{border-top:1px dashed #000; margin:6px 0}
.thermal .row2{display:flex; justify-content:space-between; gap:8px}
.thermal .item{margin:4px 0}
.thermal .name{font-weight:800; font-size:11px}
.thermal .total{font-weight:900}
@media (max-width: 900px){
  .menu-open .sidebar{left:0}
}


/* typeahead */
.typeahead{position:relative}
.suggest{
  position:absolute;
  top:100%;
  left:0; right:0;
  margin-top:8px;
  background:#0f1020;
  border:3px solid var(--border);
  box-shadow:6px 6px 0 var(--shadow);
  border-radius:16px;
  max-height:320px;
  overflow:auto;
  z-index:50;
  display:none;
}
.suggest.open{display:block}
.suggest-item{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px;
  border-bottom:2px dashed #ffffff14;
  cursor:pointer;
}
.suggest-item:last-child{border-bottom:none}
.suggest-item:hover{background:#ffffff06}
.suggest-item.disabled{opacity:.55; cursor:not-allowed}
.suggest-left{min-width:0; flex:1}
.suggest-name{font-weight:900; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.suggest-meta{color:var(--muted); font-size:12px; margin-top:2px}


/* login */
.login-body{
  background:
    radial-gradient(800px 420px at 50% 0%, #7c5cff26 0%, transparent 60%),
    radial-gradient(700px 420px at 0% 100%, #2fe28d14 0%, transparent 65%),
    var(--bg);
}

.app-login{
  justify-content:center;
  align-items:center;
  padding:24px;
}

.login-card{
  width:min(520px,100%);
  padding:18px 18px 16px;
  position:relative;
  overflow:hidden;
}

.login-card:before{
  content:'';
  position:absolute;
  left:14px;
  right:14px;
  top:14px;
  height:4px;
  background:linear-gradient(90deg, var(--accent), transparent);
  border-radius:999px;
  opacity:.85;
}

.login-card h2{
  margin:0 0 8px 0;
  font-size:18px;
  display:flex;
  align-items:center;
  gap:10px;
  letter-spacing:.2px;
}

.login-card h2:before{
  content:'';
  width:18px;
  height:18px;
  background:var(--accent);
  border:3px solid #ffffff22;
  box-shadow: inset -6px -6px 0 #00000055;
  border-radius:8px;
}

.login-sub{margin:0 0 10px 0}
.login-footnote{margin:12px 0 0; font-size:12px}

.login-body .input:focus{
  border-color:#ffffff22;
  box-shadow:4px 4px 0 var(--shadow), 0 0 0 3px #7c5cff22;
}

.login-body .btn-primary{width:100%}
