  :root{
    --navy:#0b1730;
    --navy-2:#132140;
    --blue:#1d5fd6;
    --blue-dark:#123a8c;
    --blue-light:#eaf1ff;
    --bg:#f4f6fb;
    --card:#ffffff;
    --border:#e4e8f1;
    --text:#182238;
    --muted:#6b7690;
    --green:#1f9d55;
    --green-bg:#e8f8ee;
    --red:#d64545;
    --red-bg:#fdecec;
    --amber:#c9820f;
    --amber-bg:#fdf3e0;
    --radius:12px;
    font-family:'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  }
  *{box-sizing:border-box; margin:0; padding:0;}
  body{background:var(--bg); color:var(--text); font-size:14px; -webkit-font-smoothing:antialiased;}
  button{font-family:inherit; cursor:pointer;}
  input, select{font-family:inherit;}
  a{color:inherit;}

  /* LOGIN */
  #login-screen{
    min-height:100vh; display:flex; align-items:stretch;
  }
  .login-left{
    flex:1.3; background:linear-gradient(135deg,#081226 0%, #0d2050 55%, #1548a8 100%);
    color:#fff; padding:56px 60px; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center;
    position:relative; overflow:hidden;
  }
  .login-left::before{
    content:""; position:absolute; inset:0;
    background:
      radial-gradient(circle at 15% 20%, rgba(255,255,255,0.06), transparent 40%),
      radial-gradient(circle at 85% 80%, rgba(29,95,214,0.35), transparent 45%);
  }
  .subject-pills{display:flex; flex-wrap:wrap; gap:10px; justify-content:center; max-width:520px; margin-bottom:36px; position:relative;}
  .pill{
    background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.15);
    padding:7px 14px; border-radius:20px; font-size:12.5px; display:flex; align-items:center; gap:6px;
    backdrop-filter:blur(4px);
  }
  .brand-icon{
    width:64px; height:64px; border-radius:16px; background:rgba(255,255,255,0.12);
    display:flex; align-items:center; justify-content:center; margin-bottom:22px; position:relative;
    border:1px solid rgba(255,255,255,0.2);
  }
  .brand-icon svg{width:32px; height:32px;}
  .login-left h1{font-size:34px; font-weight:700; line-height:1.25; position:relative;}
  .login-left p.sub{margin-top:12px; color:#c3d3f5; max-width:460px; font-size:15px; position:relative; line-height:1.5;}
  .feature-grid{
    display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:34px; max-width:460px; width:100%; position:relative;
  }
  .feature-card{
    background:rgba(255,255,255,0.07); border:1px solid rgba(255,255,255,0.14); border-radius:10px;
    padding:12px 14px; text-align:left;
  }
  .feature-card b{display:block; font-size:13px; margin-bottom:2px;}
  .feature-card span{font-size:11.5px; color:#b7c6ea;}

  .login-right{
    flex:1; background:#fff; display:flex; align-items:center; justify-content:center; padding:40px;
  }
  .login-box{width:100%; max-width:340px;}
  .school-head{display:flex; flex-direction:column; align-items:center; text-align:center; margin-bottom:26px;}
  .school-logo{
    width:52px; height:52px; border-radius:12px; background:var(--blue); color:#fff;
    display:flex; align-items:center; justify-content:center; margin-bottom:10px;
  }
  .school-logo svg{width:26px; height:26px;}
  .school-head h2{font-size:16px; font-weight:700;}
  .school-head span{font-size:12px; color:var(--muted);}
  .login-card{
    border:1px solid var(--border); border-radius:var(--radius); padding:26px 24px; box-shadow:0 10px 30px rgba(20,40,90,0.06);
  }
  .login-card h3{font-size:17px; margin-bottom:2px;}
  .login-card p{font-size:12.5px; color:var(--muted); margin-bottom:18px;}
  .field{margin-bottom:14px;}
  .field label{display:block; font-size:12.5px; font-weight:600; margin-bottom:6px;}
  .input-wrap{position:relative;}
  .input-wrap svg{position:absolute; left:11px; top:50%; transform:translateY(-50%); width:15px; height:15px; color:#9aa4bb;}
  .input-wrap input{
    width:100%; padding:10px 12px 10px 34px; border:1px solid var(--border); border-radius:8px; font-size:13.5px; outline:none;
  }
  .input-wrap input:focus{border-color:var(--blue); box-shadow:0 0 0 3px rgba(29,95,214,0.12);}
  .toggle-eye{left:auto !important; right:11px; cursor:pointer;}
  .btn-signin{
    width:100%; padding:11px; background:var(--blue); color:#fff; border:none; border-radius:8px; font-weight:600; font-size:14px;
    margin-top:4px; transition:background .15s;
  }
  .btn-signin:hover{background:var(--blue-dark);}
  .demo-hint{
    margin-top:14px; background:var(--blue-light); border-radius:8px; padding:9px 12px; font-size:11.5px; color:#1e3a70; text-align:center;
  }
  .login-error{
    display:none; background:var(--red-bg); color:var(--red); border-radius:8px; padding:8px 12px; font-size:12px; margin-bottom:12px; text-align:center;
  }
  .login-footer{text-align:center; font-size:11px; color:var(--muted); margin-top:20px;}

  /* ============ APP SHELL ============ */
  #app-shell{display:block; min-height:100vh;}
  .app-layout{display:flex; min-height:100vh;}

  .sidebar{
    width:250px; background:var(--navy); color:#cdd8f0; display:flex; flex-direction:column; flex-shrink:0;
    position:sticky; top:0; height:100vh;
  }
  .sidebar-brand{
    display:flex; align-items:center; gap:10px; padding:20px 18px; border-bottom:1px solid rgba(255,255,255,0.08);
  }
  .sidebar-brand .school-logo{width:38px; height:38px; border-radius:9px;}
  .sidebar-brand .school-logo svg{width:20px; height:20px;}
  .sidebar-brand-text b{display:block; font-size:13px; color:#fff;}
  .sidebar-brand-text span{font-size:10.5px; color:#8ea0c9;}

  .nav-label{font-size:10px; letter-spacing:0.08em; color:#5f6f95; padding:16px 18px 6px; text-transform:uppercase;}
  .nav-list{list-style:none; flex:1; overflow-y:auto;}
  .nav-item{
    display:flex; align-items:center; gap:11px; padding:10px 18px; font-size:13.5px; color:#b9c5e6; cursor:pointer;
    border-left:3px solid transparent; transition:background .12s;
  }
  .nav-item svg{width:17px; height:17px; flex-shrink:0;}
  .nav-item:hover{background:rgba(255,255,255,0.04); color:#fff;}
  .nav-item.active{background:rgba(29,95,214,0.18); color:#fff; border-left-color:var(--blue); font-weight:600;}
  .sidebar-bottom{border-top:1px solid rgba(255,255,255,0.08); padding:6px 0;}
  .sidebar-bottom .nav-item.logout{color:#e07070;}
  .sidebar-bottom .nav-item.logout:hover{background:rgba(214,69,69,0.1); color:#ff8a8a;}

  .main-col{flex:1; display:flex; flex-direction:column; min-width:0;}
  .topbar{
    background:#fff; border-bottom:1px solid var(--border); padding:14px 28px;
    display:flex; align-items:center; justify-content:space-between;
  }
  .topbar h1{font-size:19px; font-weight:700;}
  .topbar .page-sub{font-size:12px; color:var(--muted); margin-top:1px;}
  .topbar-right{display:flex; align-items:center; gap:16px;}
  .topbar-date{font-size:12.5px; color:var(--muted);}
  .topbar-user{display:flex; align-items:center; gap:9px;}
  .avatar{width:34px; height:34px; border-radius:50%; background:var(--blue); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:12px;}
  .topbar-user b{display:block; font-size:12.5px;}
  .topbar-user span{font-size:11px; color:var(--muted);}
  .icon-btn{width:34px; height:34px; border-radius:50%; border:1px solid var(--border); background:#fff; display:flex; align-items:center; justify-content:center;}
  .icon-btn svg{width:15px; height:15px; color:var(--muted);}

  .content{padding:24px 28px 60px; flex:1;}
  .page{display:none;}
  .page.active{display:block;}

  /* Shared components */
  .panel-header{
    background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:16px 20px;
    display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; gap:16px; flex-wrap:wrap;
  }
  .panel-header-left{display:flex; align-items:center; gap:12px;}
  .panel-icon{width:38px; height:38px; border-radius:9px; background:var(--blue-light); color:var(--blue); display:flex; align-items:center; justify-content:center;}
  .panel-icon svg{width:19px; height:19px;}
  .panel-header h2{font-size:16px;}
  .panel-header p{font-size:12px; color:var(--muted);}
  .btn-primary{
    background:var(--blue); color:#fff; border:none; padding:9px 16px; border-radius:8px; font-size:13px; font-weight:600;
    display:inline-flex; align-items:center; gap:6px; transition:background .15s;
  }
  .btn-primary:hover{background:var(--blue-dark);}
  .btn-primary svg{width:14px; height:14px;}
  .btn-danger{background:var(--red);} .btn-danger:hover{background:#b83636;}

  .stat-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:20px;}
  .stat-card{
    background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:16px 18px;
  }
  .stat-top{display:flex; align-items:center; justify-content:space-between; margin-bottom:12px;}
  .stat-icon{width:36px; height:36px; border-radius:9px; display:flex; align-items:center; justify-content:center;}
  .stat-icon svg{width:18px; height:18px;}
  .stat-trend{font-size:11px; font-weight:700; display:flex; align-items:center; gap:3px;}
  .stat-value{font-size:24px; font-weight:800;}
  .stat-label{font-size:12px; color:var(--muted); margin-top:2px;}

  .grid-2{display:grid; grid-template-columns:2fr 1fr; gap:18px; margin-bottom:18px;}
  .card{background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:18px 20px;}
  .card-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:14px;}
  .card-head h3{font-size:14.5px;}
  .card-head span.sub{font-size:11.5px; color:var(--muted); font-weight:400; display:block; margin-top:1px;}
  .link-view{font-size:12px; color:var(--blue); font-weight:600;}

  table{width:100%; border-collapse:collapse; font-size:13px;}
  thead th{
    text-align:left; font-size:10.5px; letter-spacing:.04em; text-transform:uppercase; color:var(--muted);
    padding:10px 12px; border-bottom:1px solid var(--border);
  }
  tbody td{padding:11px 12px; border-bottom:1px solid #f0f2f7; vertical-align:middle;}
  tbody tr:hover{background:#fafbfe;}
  .cell-sub{display:block; font-size:11px; color:var(--muted); margin-top:1px;}
  .txn-id, .row-link{color:var(--blue); font-weight:600; cursor:pointer;}

  .badge{
    display:inline-block; padding:3px 10px; border-radius:20px; font-size:11px; font-weight:600;
  }
  .badge-blue{background:#e6effe; color:var(--blue-dark);}
  .badge-green{background:var(--green-bg); color:var(--green);}
  .badge-red{background:var(--red-bg); color:var(--red);}
  .badge-amber{background:var(--amber-bg); color:var(--amber);}
  .badge-grey{background:#eef0f5; color:#697086;}

  .action-btn{
    border:1px solid var(--border); background:#fff; padding:5px 11px; border-radius:6px; font-size:11.5px; font-weight:600; margin-right:6px;
    display:inline-flex; align-items:center; gap:4px;
  }
  .action-btn svg{width:12px; height:12px;}
  .action-btn.edit{color:var(--blue); border-color:#cfe0fb;}
  .action-btn.del{color:var(--red); border-color:#f6cccc;}
  .action-btn.ret{color:var(--green); border-color:#c3ecd3;}

  .toolbar{
    display:flex; align-items:center; gap:10px; background:#fff; border:1px solid var(--border); border-radius:var(--radius);
    padding:12px 16px; margin-bottom:16px; flex-wrap:wrap;
  }
  .search-wrap{flex:1; min-width:220px; position:relative;}
  .search-wrap svg{position:absolute; left:11px; top:50%; transform:translateY(-50%); width:14px; height:14px; color:#9aa4bb;}
  .search-wrap input{width:100%; padding:9px 12px 9px 32px; border:1px solid var(--border); border-radius:8px; font-size:13px; outline:none;}
  .search-wrap input:focus{border-color:var(--blue);}
  select.filter-select{padding:9px 12px; border:1px solid var(--border); border-radius:8px; font-size:13px; background:#fff; outline:none;}
  .toolbar .result-count{font-size:11.5px; color:var(--muted); white-space:nowrap;}

  .filter-tabs{display:flex; gap:8px; margin-bottom:2px;}
  .ftab{
    padding:7px 14px; border-radius:8px; font-size:12.5px; font-weight:600; border:1px solid var(--border); background:#fff; color:var(--muted);
  }
  .ftab.active{background:var(--blue); color:#fff; border-color:var(--blue);}

  .table-card{background:#fff; border:1px solid var(--border); border-radius:var(--radius); overflow:hidden;}
  .table-scroll{overflow-x:auto;}
  .table-foot{padding:12px 16px; font-size:11.5px; color:var(--muted); border-top:1px solid var(--border);}

  /* Dashboard banner */
  .banner{
    background:linear-gradient(120deg,#0e2a63,#155ed4); color:#fff; border-radius:var(--radius);
    padding:22px 26px; display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; flex-wrap:wrap; gap:14px;
  }
  .banner h2{font-size:18px; margin-bottom:4px;}
  .banner p{font-size:12.5px; color:#cfe0ff;}
  .banner-actions{display:flex; gap:10px;}
  .btn-ghost-light{background:rgba(255,255,255,0.14); border:1px solid rgba(255,255,255,0.3); color:#fff; padding:9px 15px; border-radius:8px; font-size:12.5px; font-weight:600; display:inline-flex; align-items:center; gap:6px;}
  .btn-white{background:#fff; color:var(--blue-dark); padding:9px 15px; border-radius:8px; font-size:12.5px; font-weight:700; border:none; display:inline-flex; align-items:center; gap:6px;}

  .alert-item{display:flex; gap:9px; padding:10px 11px; border-radius:8px; font-size:12px; margin-bottom:8px; align-items:flex-start;}
  .alert-item svg{width:15px; height:15px; flex-shrink:0; margin-top:1px;}
  .alert-red{background:var(--red-bg); color:#a23a3a;}
  .alert-amber{background:var(--amber-bg); color:#96690a;}
  .alert-blue{background:var(--blue-light); color:#1e3a70;}
  .qa-btn{
    display:flex; align-items:center; gap:9px; width:100%; padding:10px 12px; border-radius:9px; border:1px solid var(--border);
    background:#fbfcfe; margin-bottom:9px; font-size:12.5px; font-weight:600; text-align:left;
  }
  .qa-btn svg{width:16px; height:16px;}
  .qa-blue{color:var(--blue);} .qa-green{color:var(--green);} .qa-amber{color:#b8790c;} .qa-purple{color:#7c4fd6;}

  .progress-row{margin-bottom:12px;}
  .progress-row-top{display:flex; justify-content:space-between; font-size:12.5px; margin-bottom:5px;}
  .progress-bar-bg{height:6px; background:#eef1f7; border-radius:6px; overflow:hidden;}
  .progress-bar-fill{height:100%; background:var(--blue); border-radius:6px;}

  /* QR scanner */
  .qr-layout{display:grid; grid-template-columns:2fr 1fr; gap:18px;}
  .scan-tabs{display:flex; margin-bottom:14px; border:1px solid var(--border); border-radius:9px; overflow:hidden;}
  .scan-tab{flex:1; padding:10px; text-align:center; font-size:13px; font-weight:600; color:var(--muted); background:#fff;}
  .scan-tab.active{background:var(--blue); color:#fff;}
  .camera-box{
    background:#0b1730; border-radius:10px; height:280px; display:flex; flex-direction:column; align-items:center; justify-content:center;
    color:#8ea0c9; margin-bottom:14px;
  }
  .camera-box svg{width:46px; height:46px; margin-bottom:10px; opacity:.7;}
  .camera-box .cam-sub{font-size:12px; margin-top:4px;}
  .manual-row{display:flex; gap:10px;}
  .manual-row input{flex:1; padding:10px 12px; border:1px solid var(--border); border-radius:8px; font-size:13px;}
  .how-list{list-style:none; counter-reset:step;}
  .how-list li{counter-increment:step; display:flex; gap:9px; font-size:12.5px; margin-bottom:9px; color:#1e3a70;}
  .how-list li::before{
    content:counter(step); width:18px; height:18px; border-radius:50%; background:var(--blue); color:#fff; font-size:10.5px;
    display:flex; align-items:center; justify-content:center; flex-shrink:0;
  }
  .scan-result-empty{text-align:center; padding:28px 10px; color:var(--muted);}
  .scan-result-empty svg{width:36px; height:36px; opacity:.4; margin-bottom:8px;}
  .scan-result-found{display:none;}
  .result-row{display:flex; justify-content:space-between; padding:7px 0; font-size:12.5px; border-bottom:1px dashed var(--border);}
  .result-row span:first-child{color:var(--muted);}
  .result-row span:last-child{font-weight:600;}

  .reports-tabs{display:flex; gap:6px; background:#eef1f7; padding:4px; border-radius:9px; width:fit-content; margin-bottom:18px;}
  .rtab{padding:8px 16px; border-radius:7px; font-size:12.5px; font-weight:600; color:var(--muted); background:transparent;}
  .rtab.active{background:#fff; color:var(--blue); box-shadow:0 1px 3px rgba(0,0,0,0.08);}

  .most-borrowed li{list-style:none;}

  @media (max-width: 1100px){
    .stat-grid{grid-template-columns:repeat(2,1fr);}
    .grid-2{grid-template-columns:1fr;}
    .qr-layout{grid-template-columns:1fr;}
  }
  @media (max-width: 760px){
    .sidebar{display:none;}
    .login-left{display:none;}
    .stat-grid{grid-template-columns:1fr;}
  }