/* ZJ Tools - Unified left sidebar layout v3 */
:root{
  --brand-primary:#2563eb;
  --brand-primary-dark:#1d4ed8;
  --brand-primary-soft:#dbeafe;
  --brand-ink:#1e293b;
  --brand-muted:#64748b;
  --brand-border:#e2e8f0;
  --brand-bg:#f1f5f9;
  --brand-sidebar-w:240px;
  --brand-shadow:0 1px 3px rgba(15,23,42,.06),0 1px 2px rgba(15,23,42,.04);
  --brand-shadow-lg:0 10px 30px rgba(15,23,42,.10);
  --brand-radius:12px;
  --brand-font:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;
}

/* ===== Reset body for sidebar ===== */
body{margin:0!important}

/* ===== Sidebar ===== */
.brand-sidebar{
  position:fixed;top:0;left:0;bottom:0;
  width:var(--brand-sidebar-w);
  background:#fff;border-right:1px solid var(--brand-border);
  display:flex;flex-direction:column;z-index:50;
  font-family:var(--brand-font);
  overflow-y:auto;overflow-x:hidden;
  transition:transform .2s ease;
}
.brand-sidebar .sidebar-header{
  display:flex;align-items:center;gap:10px;
  padding:18px 16px;border-bottom:1px solid var(--brand-border);
  text-decoration:none;color:var(--brand-ink);font-weight:800;font-size:16px;
  white-space:nowrap;
}
.brand-sidebar .sidebar-header svg{width:28px;height:28px;flex:0 0 28px}
.brand-sidebar .sidebar-header b{color:var(--brand-primary)}

/* ===== Menu groups ===== */
.brand-sidebar .sidebar-menu{flex:1;padding:8px 0;overflow-y:auto}
.brand-sidebar .menu-group{margin-bottom:2px}
.brand-sidebar .menu-group-title{
  display:flex;align-items:center;justify-content:space-between;
  padding:9px 16px;font-size:11px;font-weight:700;
  color:var(--brand-muted);text-transform:uppercase;letter-spacing:.08em;
  cursor:pointer;user-select:none;
}
.brand-sidebar .menu-group-title .arrow{
  display:inline-block;width:14px;text-align:center;
  transition:transform .15s ease;font-size:10px;
}
.brand-sidebar .menu-group.collapsed .menu-group-title .arrow{transform:rotate(-90deg)}
.brand-sidebar .menu-group-items{
  overflow:hidden;max-height:600px;transition:max-height .2s ease;
}
.brand-sidebar .menu-group.collapsed .menu-group-items{max-height:0}

.brand-sidebar .menu-item{
  display:flex;align-items:center;gap:10px;
  padding:9px 16px 9px 36px;
  text-decoration:none;color:var(--brand-muted);
  font-size:13.5px;font-weight:500;white-space:nowrap;
  transition:all .12s ease;
}
.brand-sidebar .menu-item .mi-icon{font-size:15px;width:18px;text-align:center;flex:0 0 18px}
.brand-sidebar .menu-item:hover{background:var(--brand-bg);color:var(--brand-ink)}
.brand-sidebar .menu-item.active{
  background:var(--brand-primary-soft);color:var(--brand-primary);font-weight:600;
}
.brand-sidebar .menu-item .usage-badge{
  margin-left:auto;font-size:11px;color:var(--brand-muted);
  background:var(--brand-bg);border-radius:999px;padding:1px 8px;min-width:20px;text-align:center;
}
.brand-sidebar .menu-item.active .usage-badge{background:var(--brand-primary);color:#fff}

/* ===== Sidebar footer (user area) ===== */
.brand-sidebar .sidebar-footer{
  padding:12px 16px;border-top:1px solid var(--brand-border);
  display:flex;align-items:center;gap:8px;white-space:nowrap;
}
.brand-sidebar .sidebar-footer .user-chip{
  flex:1;font-size:12px;color:var(--brand-muted);
  overflow:hidden;text-overflow:ellipsis;
}
.brand-sidebar .sidebar-footer .user-chip b{color:var(--brand-ink)}
.brand-sidebar .sidebar-footer button{
  display:inline-flex;align-items:center;height:32px;padding:0 12px;
  border-radius:8px;border:1px solid var(--brand-border);background:#fff;
  color:var(--brand-ink);font-size:12px;font-weight:600;cursor:pointer;
  transition:all .15s;
}
.brand-sidebar .sidebar-footer button.primary{background:var(--brand-primary);color:#fff;border-color:var(--brand-primary)}
.brand-sidebar .sidebar-footer button.primary:hover{background:var(--brand-primary-dark)}
.brand-sidebar .sidebar-footer button.danger{border-color:#fecaca;color:#dc2626}
.brand-sidebar .sidebar-footer button.danger:hover{background:#fef2f2}

/* ===== Main content offset ===== */
.brand-main{margin-left:var(--brand-sidebar-w);min-height:100vh}

/* ===== Mobile toggle ===== */
.brand-toggle{
  display:none;position:fixed;top:12px;left:12px;z-index:60;
  width:40px;height:40px;border:1px solid var(--brand-border);background:#fff;
  border-radius:9px;cursor:pointer;font-size:18px;
  align-items:center;justify-content:center;color:var(--brand-ink);
}
.brand-overlay{
  display:none;position:fixed;inset:0;z-index:45;
  background:rgba(15,23,42,.3);
}
@media(max-width:768px){
  .brand-sidebar{transform:translateX(-100%)}
  .brand-sidebar.open{transform:translateX(0)}
  .brand-main{margin-left:0}
  .brand-toggle{display:flex}
  .brand-overlay.show{display:block}
}

/* ===== Footer ===== */
.brand-footer{
  margin-top:40px;padding:24px;text-align:center;
  color:var(--brand-muted);font-size:12px;border-top:1px solid var(--brand-border);
  font-family:var(--brand-font);
}
.brand-footer .brand-divider{margin:0 8px;color:var(--brand-border)}

/* ===== Login modal (unchanged) ===== */
.modal-overlay{
  position:fixed;inset:0;z-index:200;
  display:flex;align-items:center;justify-content:center;
  background:rgba(15,23,42,.45);backdrop-filter:blur(4px);
  opacity:0;transition:opacity .2s ease;
}
.modal-overlay.show{opacity:1}
.modal-overlay[hidden]{display:none}
.modal-box{
  width:380px;max-width:calc(100vw - 32px);
  background:#fff;border-radius:20px;box-shadow:0 25px 60px rgba(15,23,42,.18);
  padding:32px 28px;transform:translateY(16px);transition:transform .2s ease;
}
.modal-overlay.show .modal-box{transform:translateY(0)}
.modal-close{
  float:right;width:32px;height:32px;border:none;background:#f1f5f9;border-radius:8px;
  cursor:pointer;font-size:18px;line-height:1;color:#64748b;transition:.15s;
}
.modal-close:hover{background:#e2e8f0;color:#1e293b}
.modal-title{margin:0 0 4px;font-size:22px;font-weight:800;color:var(--brand-ink)}
.modal-sub{margin:0 0 24px;font-size:13px;color:var(--brand-muted);line-height:1.6}
.modal-form{display:grid;gap:16px}
.modal-form label{display:grid;gap:7px;font-size:13px;font-weight:600;color:var(--brand-ink)}
.modal-form input{
  width:100%;border:1.5px solid var(--brand-border);border-radius:10px;
  padding:11px 14px;font-size:14px;background:#fff;color:var(--brand-ink);
  transition:border-color .15s,box-shadow .15s;
}
.modal-form input:focus{outline:none;border-color:var(--brand-primary);box-shadow:0 0 0 3px var(--brand-primary-soft)}
.modal-btn{
  width:100%;height:44px;border:none;border-radius:10px;
  background:var(--brand-primary);color:#fff;font-size:15px;font-weight:700;cursor:pointer;
  transition:background .15s;
}
.modal-btn:hover{background:var(--brand-primary-dark)}
.modal-btn:disabled{opacity:.6;cursor:wait}
.modal-error{
  display:none;padding:10px 14px;border-radius:9px;
  background:#fef2f2;color:#b91c1c;font-size:13px;line-height:1.5;
}
.modal-error.show{display:block}
