@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600;700&display=swap');

:root{
  --bg:#0A0F1C; --surface:rgba(17,24,39,0.86); --surface2:#1A2338; --border:#26314A;
  --text:#E8ECF7; --sub:#8A96B5; --teal:#0FB4E8; --amber:#F5A524; --red:#F1554C; --violet:#8B87FF;
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  font-family:'IBM Plex Sans',sans-serif; color:var(--text); min-height:100vh;
  background:
    linear-gradient(180deg, rgba(10,15,28,0.55), rgba(10,15,28,0.72)),
    url('../img/bg.jpg');
  background-size:cover; background-position:center; background-attachment:fixed;
}
::-webkit-scrollbar{width:8px;height:8px;}
::-webkit-scrollbar-thumb{background:#26314A;border-radius:8px;}

#app{display:flex; min-height:100vh;}
#sidebar{
  width:220px; background:rgba(17,24,39,0.72); backdrop-filter:blur(10px);
  border-right:1px solid var(--border); padding:20px 14px; display:flex; flex-direction:column; gap:22px; flex-shrink:0;
  position:sticky; top:0; height:100vh; overflow-y:auto;
}
#logo-wrap img{width:100%; max-width:178px; display:block;}
.nav-btn{
  display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:9px;
  background:transparent; color:var(--sub); border:none; cursor:pointer; font-family:'IBM Plex Sans';
  font-size:13px; font-weight:600; text-align:left; width:100%;
  transition:background .18s ease, color .18s ease, transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s ease;
}
.nav-btn:hover{background:#1A2338; color:var(--teal); transform:scale(1.035) translateX(2px); box-shadow:0 4px 14px rgba(15,180,232,.18);}
.nav-btn:active{transform:scale(0.97);}
.nav-btn.active{background:var(--surface2); color:var(--text);}
.nav-icon{font-size:15px; width:18px; text-align:center; transition:transform .18s ease;}
.nav-btn:hover .nav-icon{transform:scale(1.15);}

#main{flex:1; padding:26px; overflow-y:auto; position:relative; z-index:2;}

/* ============================= MOBILE-FIRST (app-like slide-out sidebar) ============================= */
#mobile-topbar{display:none; position:fixed; top:0; left:0; right:0; height:52px; background:rgba(10,15,28,.94); backdrop-filter:blur(10px); border-bottom:1px solid var(--border); align-items:center; padding:0 14px; z-index:900; gap:12px;}
#mobile-topbar .hamburger{background:none;border:none;color:var(--text);font-size:22px;cursor:pointer;padding:4px 8px;line-height:1;}
#mobile-topbar .brand{font-weight:700;font-size:14px;}
#mobile-menu-overlay{display:none; position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:998;}
#mobile-menu-overlay.open{display:block;}
@media(max-width:760px){
  #mobile-topbar{display:flex;}
  #sidebar{
    position:fixed; left:0; top:0; height:100vh; width:250px; z-index:999;
    transform:translateX(-105%); transition:transform .25s ease; box-shadow:10px 0 30px rgba(0,0,0,.45);
  }
  #sidebar.open{transform:translateX(0);}
  #main{padding:16px; padding-top:68px;}
  .stat-grid{grid-template-columns:repeat(2,1fr) !important;}
}
@media(max-width:420px){
  .stat-grid{grid-template-columns:1fr !important;}
}
.bb-fade{animation:bbFadeIn .28s ease both;}
@keyframes bbFadeIn{from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:translateY(0);}}

.card{
  background:var(--surface); backdrop-filter:blur(8px); border:1px solid var(--border);
  border-radius:14px; padding:18px; transition:transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, border-color .2s ease, background .2s ease;
}
.card.hoverable:hover{transform:translateY(-3px) scale(1.012); box-shadow:0 14px 32px rgba(15,180,232,.16), 0 4px 14px rgba(0,0,0,.35); border-color:var(--teal); background:linear-gradient(180deg, rgba(15,180,232,.06), var(--surface) 60%);}
.list-row{transition:background .16s ease, padding-left .16s ease, border-color .16s ease;}
.list-row:hover{background:rgba(15,180,232,.07); padding-left:24px; border-color:rgba(15,180,232,.35) !important;}
.table-wrap tr{transition:background .15s ease;}
.table-wrap tbody tr:hover{background:rgba(15,180,232,.09) !important;}
.section-title{font-family:'IBM Plex Sans'; font-size:23px; font-weight:700; letter-spacing:-0.2px;}
.section-sub{color:var(--sub); font-size:13px; margin-top:2px;}
.card-title{font-family:'IBM Plex Sans'; font-weight:700; font-size:14px; margin-bottom:12px;}

.stat-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:14px;}
@media(max-width:900px){.stat-grid{grid-template-columns:repeat(2,1fr);}}
.stat-card{padding:16px; transition:transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, border-color .2s ease;}
.stat-card:hover{transform:translateY(-3px) scale(1.02); box-shadow:0 12px 26px rgba(15,180,232,.16); border-color:var(--teal);}
.stat-label{font-size:11.5px; color:var(--sub); font-weight:600; margin-bottom:8px; letter-spacing:.3px;}
.stat-value{font-family:'IBM Plex Mono'; font-size:21px; font-weight:700;}

.btn{
  display:inline-flex; align-items:center; gap:6px; font-family:'IBM Plex Sans'; font-weight:600;
  font-size:13px; padding:9px 14px; border-radius:9px; cursor:pointer; border:none;
  transition:opacity .15s ease, transform .16s cubic-bezier(.34,1.56,.64,1), box-shadow .16s ease, filter .16s ease;
}
.btn:hover{transform:scale(1.045); filter:brightness(1.12); box-shadow:0 6px 16px rgba(15,180,232,.22);}
.btn:active{transform:scale(0.97);}
.btn-primary{background:var(--teal); color:#04182B;}
.btn-ghost{background:transparent; color:var(--text); border:1px solid var(--border);}
.btn-danger{background:transparent; color:var(--red); border:1px solid rgba(241,85,76,.27);}
.btn:disabled{opacity:.5; cursor:not-allowed;}
.btn-icon{border:none;background:transparent;cursor:pointer;color:var(--sub);padding:4px;}
.btn-icon.danger{color:var(--red);}

input, select{
  background:var(--bg); border:1px solid var(--border); border-radius:8px; padding:8px 10px;
  color:var(--text); font-family:'IBM Plex Sans'; font-size:13px; outline:none; width:100%;
}
input[type=number]{font-family:'IBM Plex Mono';}
label.field{display:flex; flex-direction:column; gap:5px; font-family:'IBM Plex Sans';}
label.field span.lbl{font-size:12px; color:var(--sub); font-weight:600; letter-spacing:.2px;}
label.field span.hint{font-size:11px; color:var(--sub);}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.grid3{display:grid; grid-template-columns:1fr 1fr 1fr; gap:12px;}

.flowbar{display:flex; width:100%; border-radius:4px; overflow:hidden; background:var(--surface2);}
.legend{display:flex; flex-wrap:wrap; gap:14px; font-size:12px; color:var(--sub); font-family:'IBM Plex Sans';}
.legend-item{display:flex; align-items:center; gap:6px;}
.legend-dot{width:9px; height:9px; border-radius:2px; display:inline-block;}

.preview-row{display:flex; justify-content:space-between; font-size:13px; color:var(--text);}
.preview-row .lbl{font-family:'IBM Plex Sans'; font-weight:500;}
.preview-row .val{font-family:'IBM Plex Mono'; font-weight:500;}
.preview-row.bold .lbl, .preview-row.bold .val{font-weight:700;}
.preview-row.sub{font-size:12px; color:var(--sub);}
.divider{border-top:1px dashed var(--border); margin:4px 0;}
.divider-solid{border-top:1px solid var(--border); margin:4px 0;}

.modal-overlay{position:fixed; inset:0; background:#000000aa; display:none; align-items:center; justify-content:center; z-index:50; padding:20px;}
.modal-overlay.open{display:flex;}
.modal-box{background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:22px; width:420px; max-width:94vw; max-height:88vh; overflow-y:auto; font-family:'IBM Plex Sans';}
.modal-box.wide{width:780px;}
.modal-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:18px;}
.modal-title{font-family:'IBM Plex Sans'; font-weight:700; font-size:17px;}
.modal-close{background:transparent; border:none; color:var(--sub); cursor:pointer; font-size:18px;}
.modal-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:18px;}

.badge{font-size:10.5px; font-weight:700; padding:2px 8px; border-radius:20px;}
.order-card-head{display:flex; justify-content:space-between; align-items:flex-start; cursor:pointer;}
.order-card-name{display:flex; align-items:center; gap:8px;}
.order-card-meta{color:var(--sub); font-size:12.5px; margin-top:3px; margin-left:23px;}
.order-detail-grid{margin-top:16px; border-top:1px solid var(--border); padding-top:14px; display:grid; grid-template-columns:1fr 1fr; gap:20px;}
@media(max-width:700px){.order-detail-grid, .grid2, .grid3, .stat-grid{grid-template-columns:1fr;}.advance-group-grid{grid-template-columns:1fr !important;}}

table{border-collapse:collapse; width:100%;}
th{padding:10px 12px; text-align:left; font-family:'IBM Plex Sans'; font-size:11px; font-weight:700; color:var(--sub);
  letter-spacing:.3px; text-transform:uppercase; white-space:nowrap; position:sticky; top:0; background:var(--surface2); border-bottom:1px solid var(--border);}
td{padding:10px 12px; font-size:12.5px; white-space:nowrap; border-bottom:1px solid var(--border);}
td.mono{font-family:'IBM Plex Mono';}
.table-wrap{overflow-x:auto; max-height:520px; overflow-y:auto;}

.mini-stat .lbl{font-size:10.5px; color:var(--sub); margin-bottom:3px;}
.mini-stat .val{font-family:'IBM Plex Mono'; font-size:13.5px; font-weight:700;}
.mini-stat.sub .val{font-size:12px; font-weight:500; color:var(--sub);}

.save-err{background:rgba(241,85,76,.09); border:1px solid rgba(241,85,76,.33); color:var(--red); border-radius:10px; padding:9px 14px; margin-bottom:16px; font-size:12.5px; display:flex; gap:8px; align-items:center;}
.empty-note{color:var(--sub); font-size:13px;}

/* ===================== v2 additions: login screen ===================== */
#login-root{display:none;position:fixed;inset:0;z-index:100000;background:linear-gradient(180deg,rgba(10,15,28,.92),rgba(10,15,28,.97));overflow:auto;}
.login-wrap{min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px;}
.login-card{width:100%;max-width:380px;background:var(--surface);border:1px solid var(--border);border-radius:18px;padding:28px 24px;
  box-shadow:0 20px 60px rgba(15,180,232,.18);display:flex;flex-direction:column;gap:10px;backdrop-filter:blur(8px);}
.login-logo{width:84px;height:auto;align-self:center;border-radius:16px;margin-bottom:4px;}
.login-title{font-weight:700;font-size:19px;text-align:center;letter-spacing:.3px;}
.login-sub{font-size:12.5px;color:var(--sub);text-align:center;margin-bottom:6px;}
.login-err{background:rgba(241,85,76,.12);border:1px solid var(--red);color:#ffb4ae;padding:9px 12px;border-radius:9px;font-size:12.5px;}
