/* SPIMS - Professional Inventory System - Style 4.0 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');
:root{
  --bg:#f8fafc; --bg-card:#ffffff; --bg-sidebar:#0f172a; --bg-sidebar-hover:#1e293b;
  --text:#0f172a; --text-muted:#64748b; --text-sidebar:#cbd5e1;
  --border:#e2e8f0; --primary:#0ea5e9; --primary-dark:#0284c7; --primary-light:#e0f2fe;
  --success:#10b981; --warning:#f59e0b; --danger:#ef4444; --info:#6366f1;
  --shadow:0 1px 3px rgba(0,0,0,.08),0 4px 12px rgba(0,0,0,.05);
  --radius:12px; --radius-sm:8px;
}
[data-theme="dark"]{
  --bg:#0b1220; --bg-card:#151e32; --bg-sidebar:#020617; --bg-sidebar-hover:#0f172a;
  --text:#e2e8f0; --text-muted:#94a3b8; --border:#1e293b; --primary-light:#0c4a6e;
  --shadow:0 1px 3px rgba(0,0,0,.3);
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  margin:0; font-family:Inter,system-ui,-apple-system,sans-serif;
  background:var(--bg); color:var(--text); line-height:1.5; font-size:14px;
}
a{color:var(--primary-dark); text-decoration:none}
a:hover{text-decoration:underline}
.mono{font-family:'JetBrains Mono',monospace}
.app{display:flex; min-height:100vh}
.sidebar{
  width:270px; background:var(--bg-sidebar); color:var(--text-sidebar);
  display:flex; flex-direction:column; position:fixed; inset:0 auto 0 0; z-index:40; overflow-y:auto;
  transition:transform .25s;
}
.sidebar-header{padding:20px 18px 16px; border-bottom:1px solid rgba(255,255,255,.08); display:flex; align-items:center; gap:12px}
.sidebar-header img{width:42px;height:42px;object-fit:contain;background:#fff;border-radius:10px;padding:4px}
.sidebar-header .title{font-weight:800; font-size:15px; color:#fff; line-height:1.2}
.sidebar-header .subtitle{font-size:11px; color:#94a3b8; letter-spacing:.04em; text-transform:uppercase}
.nav{padding:12px 10px; flex:1}
.nav-section{font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:#64748b; padding:14px 10px 6px}
.nav a{
  display:flex; align-items:center; gap:10px; padding:9px 12px; border-radius:10px;
  color:var(--text-sidebar); font-weight:500; font-size:13.5px; transition:.15s; text-decoration:none;
}
.nav a:hover{background:var(--bg-sidebar-hover); color:#fff}
.nav a.active{background:#0ea5e9; color:#fff; box-shadow:0 4px 12px rgba(14,165,233,.35)}
.nav a i, .nav a svg{width:18px;height:18px; opacity:.9}
.main{flex:1; margin-left:270px; min-width:0}
.topbar{
  height:64px; background:var(--bg-card); border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; padding:0 24px; position:sticky; top:0; z-index:20;
  backdrop-filter:blur(8px);
}
.topbar h1{font-size:18px; font-weight:700; margin:0}
.topbar .actions{display:flex; align-items:center; gap:10px}
.btn{
  display:inline-flex; align-items:center; gap:8px; justify-content:center;
  padding:9px 16px; border-radius:10px; border:1px solid transparent; font-weight:600; font-size:13.5px;
  cursor:pointer; transition:.15s; line-height:1; white-space:nowrap;
}
.btn-primary{background:var(--primary); color:#fff; border-color:var(--primary)}
.btn-primary:hover{background:var(--primary-dark)}
.btn-ghost{background:transparent; border-color:var(--border); color:var(--text)}
.btn-ghost:hover{background:var(--bg)}
.btn-danger{background:var(--danger); color:#fff}
.btn-success{background:var(--success); color:#fff}
.btn-sm{padding:7px 12px; font-size:13px}
.btn-icon{width:36px;height:36px;padding:0;border-radius:10px}
.badge{display:inline-flex; align-items:center; padding:3px 9px; border-radius:999px; font-size:11px; font-weight:700; letter-spacing:.03em; text-transform:uppercase}
.badge-success{background:#dcfce7; color:#166534}
.badge-warning{background:#fef3c7; color:#92400e}
.badge-danger{background:#fee2e2; color:#991b1b}
.badge-info{background:#e0e7ff; color:#4338ca}
[data-theme="dark"] .badge-success{background:#14532d; color:#bbf7d0}
[data-theme="dark"] .badge-warning{background:#78350f; color:#fde68a}
[data-theme="dark"] .badge-danger{background:#7f1d1d; color:#fecaca}
.content{padding:22px 24px 32px; max-width:1400px; margin:0 auto; width:100%}
.cards{display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:18px}
.card{
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius);
  padding:16px; box-shadow:var(--shadow);
}
.card h3{font-size:12px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--text-muted); margin:0 0 8px}
.card .value{font-size:26px; font-weight:800; line-height:1}
.card .sub{font-size:12px; color:var(--text-muted); margin-top:4px}
.card-primary{border-left:4px solid var(--primary)}
.card-success{border-left:4px solid var(--success)}
.card-warning{border-left:4px solid var(--warning)}
.card-danger{border-left:4px solid var(--danger)}
.grid-2{display:grid; grid-template-columns:1fr 1fr; gap:16px}
.grid-3{display:grid; grid-template-columns:repeat(3,1fr); gap:16px}
.panel{
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); overflow:hidden;
}
.panel-header{padding:14px 16px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between}
.panel-header h2{font-size:14px; font-weight:700; margin:0}
.panel-body{padding:16px}
.table-wrap{overflow:auto; border:1px solid var(--border); border-radius:var(--radius-sm)}
table{width:100%; border-collapse:collapse; font-size:13.5px}
thead th{
  background:#f8fafc; color:#475569; font-weight:700; font-size:11.5px; letter-spacing:.06em; text-transform:uppercase;
  padding:10px 12px; text-align:left; white-space:nowrap; border-bottom:1px solid var(--border);
}
[data-theme="dark"] thead th{background:#0f172a; color:#94a3b8}
tbody td{padding:9px 12px; border-bottom:1px solid var(--border); vertical-align:middle}
tbody tr:hover{background:rgba(14,165,233,.04)}
tbody tr:last-child td{border-bottom:none}
.form-grid{display:grid; grid-template-columns:repeat(2,1fr); gap:14px}
.form-group{display:flex; flex-direction:column; gap:6px}
.form-group.full{grid-column:1/-1}
.form-group label{font-weight:600; font-size:13px}
.form-control, .form-select{
  width:100%; padding:10px 12px; border:1px solid var(--border); border-radius:10px;
  background:var(--bg-card); color:var(--text); font-size:14px; outline:none; transition:.15s;
}
.form-control:focus, .form-select:focus{border-color:var(--primary); box-shadow:0 0 0 3px rgba(14,165,233,.15)}
.form-control[readonly]{background:#f1f5f9}
[data-theme="dark"] .form-control[readonly]{background:#1e293b}
.qty-input{max-width:120px}
.item-row{display:grid; grid-template-columns:1.2fr .8fr .7fr auto; gap:10px; align-items:end; padding:10px; border:1px dashed var(--border); border-radius:10px; margin-bottom:10px; background:rgba(241,245,249,.5)}
[data-theme="dark"] .item-row{background:rgba(15,23,42,.5)}
.filters{display:flex; flex-wrap:wrap; gap:10px; align-items:end; padding:12px; background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-sm); margin-bottom:14px}
.filters .form-group{flex:1 1 160px}
.alert{padding:12px 14px; border-radius:10px; border:1px solid; font-weight:500; margin-bottom:14px; display:flex; align-items:center; gap:10px}
.alert-success{background:#f0fdf4; border-color:#bbf7d0; color:#166534}
.alert-danger{background:#fef2f2; border-color:#fecaca; color:#991b1b}
.alert-warning{background:#fffbeb; border-color:#fde68a; color:#92400e}
.alert-info{background:#eff6ff; border-color:#bfdbfe; color:#1e40af}
[data-theme="dark"] .alert-success{background:#052e14; border-color:#14532d; color:#bbf7d0}
[data-theme="dark"] .alert-danger{background:#450a0a; border-color:#7f1d1d; color:#fecaca}
.login-wrap{min-height:100vh; display:grid; place-items:center; padding:24px; background:radial-gradient(900px 500px at 20% 0%, #e0f2fe 0%, transparent 60%), radial-gradient(800px 400px at 100% 20%, #f0fdf4 0%, transparent 50%), #f1f5f9}
.login-card{width:100%; max-width:420px; background:#fff; border:1px solid #e2e8f0; border-radius:16px; padding:28px; box-shadow:0 20px 40px rgba(0,0,0,.08)}
.login-card .logo{width:64px;height:64px; object-fit:contain; background:#f8fafc; border:1px solid #e2e8f0; border-radius:14px; padding:6px}
.pill{display:inline-flex; padding:2px 8px; border-radius:999px; background:var(--primary-light); color:var(--primary-dark); font-weight:700; font-size:11px}
.kbd{font-family:'JetBrains Mono',monospace; font-size:12px; background:#f1f5f9; border:1px solid #e2e8f0; border-bottom-width:2px; padding:2px 6px; border-radius:6px}
.stat-mini{font-size:11px; color:var(--text-muted)}
.divider{height:1px; background:var(--border); margin:16px 0}
.scroll-x{overflow:auto}
.actions-row{display:flex; gap:8px; flex-wrap:wrap}
.quick-actions{display:grid; grid-template-columns:repeat(4,1fr); gap:10px}
.quick-btn{
  display:flex; flex-direction:column; align-items:center; gap:8px; padding:16px 10px;
  background:var(--bg-card); border:1px solid var(--border); border-radius:12px; text-align:center;
  font-weight:600; font-size:13px; color:var(--text); transition:.15s; cursor:pointer;
}
.quick-btn:hover{border-color:var(--primary); transform:translateY(-1px); box-shadow:var(--shadow)}
.quick-btn span.icon{width:38px;height:38px; display:grid; place-items:center; border-radius:10px; background:var(--primary-light); color:var(--primary-dark); font-size:18px}
.empty{padding:28px; text-align:center; color:var(--text-muted)}
.empty .icon{font-size:28px; margin-bottom:8px}
.pagination{display:flex; gap:6px; align-items:center; justify-content:flex-end; padding:12px 0}
.pagination a, .pagination span{padding:7px 12px; border:1px solid var(--border); border-radius:8px; background:var(--bg-card); font-weight:600; font-size:13px}
.pagination .active{background:var(--primary); color:#fff; border-color:var(--primary)}
.theme-toggle{width:36px;height:36px; border-radius:10px; border:1px solid var(--border); background:var(--bg-card); display:grid; place-items:center; cursor:pointer}
.mobile-toggle{display:none; width:40px;height:40px; border-radius:10px; border:1px solid var(--border); background:var(--bg-card); font-size:18px}
@media (max-width:1100px){
  .cards{grid-template-columns:repeat(2,1fr)}
  .grid-2{grid-template-columns:1fr}
  .quick-actions{grid-template-columns:repeat(2,1fr)}
}
@media (max-width:760px){
  .sidebar{transform:translateX(-100%)}
  .sidebar.open{transform:translateX(0)}
  .main{margin-left:0}
  .mobile-toggle{display:grid; place-items:center}
  .form-grid{grid-template-columns:1fr}
  .cards{grid-template-columns:1fr}
  .content{padding:14px}
  .topbar{padding:0 14px}
  .item-row{grid-template-columns:1fr; gap:8px}
}
/* Print */
@media print{
  .sidebar, .topbar, .btn, .filters, .pagination, .no-print{display:none !important}
  .main{margin:0}
  .content{padding:0; max-width:none}
  .card, .panel{box-shadow:none; border:1px solid #ddd}
  body{background:#fff}
}
/* Authority Letter Print Specific */
.letter-paper{
  background:#fff; color:#000; font-family:'Times New Roman', Times, serif; line-height:1.3;
  width:210mm; min-height:297mm; margin:0 auto; padding:12mm 14mm; box-sizing:border-box; border:1px solid #ddd;
}
@media print{ .letter-paper{border:none; width:auto; min-height:auto; margin:0; padding:10mm} }
.letter-header{display:flex; justify-content:space-between; align-items:flex-start; border-bottom:2px solid #000; padding-bottom:8px; margin-bottom:10px}
.letter-header .left img{height:54px}
.letter-header .center{flex:1; text-align:center; padding:0 10px}
.letter-header .center h1{margin:0; font-size:13px; letter-spacing:.04em; font-weight:800}
.letter-header .center h2{margin:2px 0 0; font-size:10px; font-weight:700; line-height:1.3; color:#222}
.letter-header .right{font-size:10px; font-weight:700; text-align:right; min-width:140px; line-height:1.4}
.letter-to{margin:10px 0 6px; font-size:12px}
.letter-subject{font-weight:800; font-size:12px; margin:8px 0; text-align:left; text-decoration:underline}
.letter-table{width:100%; border-collapse:collapse; font-size:11px; margin:8px 0}
.letter-table th, .letter-table td{border:1px solid #000; padding:5px 6px; text-align:left}
.letter-table th{background:#f1f5f9; font-weight:700; font-size:10px; text-transform:uppercase}
.letter-note{font-size:11px; margin:8px 0}
.letter-sign-grid{display:grid; grid-template-columns:120px 1fr; gap:10px; margin:12px 0; font-size:11px}
.letter-sign-grid .box{border:1px solid #000; height:72px}
.letter-footer{margin-top:24px; display:flex; justify-content:space-between; font-size:11px; font-weight:700}
