/* ============================================================
   RESET & ROOT VARIABLES
   ============================================================ */
*{margin:0;padding:0;box-sizing:border-box}

:root{
  /* Gradients */
  --grad-primary: linear-gradient(135deg,#6366f1 0%,#8b5cf6 45%,#ec4899 100%);
  --grad-blue:    linear-gradient(135deg,#3b82f6 0%,#6366f1 100%);
  --grad-green:   linear-gradient(135deg,#10b981 0%,#34d399 100%);
  --grad-amber:   linear-gradient(135deg,#f59e0b 0%,#fbbf24 100%);
  --grad-rose:    linear-gradient(135deg,#f43f5e 0%,#ec4899 100%);
  --grad-soft:    linear-gradient(135deg,#eef2ff 0%,#faf5ff 50%,#fdf2f8 100%);

  /* Colors */
  --primary:#6366f1;
  --primary-dark:#4f46e5;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e2e8f0;
  --bg:#f6f7fb;
  --card:#fff;

  /* Shape */
  --radius:16px;
  --radius-sm:10px;

  /* Shadows */
  --shadow:0 10px 30px -12px rgba(79,70,229,.22);
  --shadow-sm:0 4px 14px -8px rgba(15,23,42,.15);

  /* Fluid spacing */
  --pad-page-x: clamp(12px, 2.6vw, 28px);
  --pad-page-y: clamp(14px, 2.6vw, 26px);
  --pad-card:   clamp(14px, 2.2vw, 22px);
  --gap:        clamp(10px, 1.4vw, 16px);
  --gap-lg:     clamp(14px, 2vw, 24px);

  /* Sidebar */
  --sidebar-w: 260px;

  /* Mobile topbar */
  --topbar-h: 60px;
}

/* ============================================================
   BASE
   ============================================================ */
html{height:100%;-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{
  font-family:'Inter','Segoe UI',system-ui,-apple-system,sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  font-size:14px;
  line-height:1.5;
  min-height:100vh;
  min-height:100dvh;
  overflow-wrap:break-word;
}
a{color:inherit;text-decoration:none}
button{
  font-family:inherit;cursor:pointer;border:none;background:none;color:inherit;
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
}
input,select,textarea{font-family:inherit;font-size:14px;color:var(--text)}
img{max-width:100%;height:auto;display:block}
svg{display:block;max-width:100%}

/* ============================================================
   ACCESSIBILITY — Focus visible (keyboard navigation)
   ============================================================ */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.nav-item:focus-visible,
.tab:focus-visible,
.color-item:focus-visible{
  outline:2px solid var(--primary);
  outline-offset:2px;
  border-radius:8px;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page{
  min-height:100vh;
  min-height:100dvh;
  display:grid;
  place-items:center;
  background:var(--grad-primary);
  padding:clamp(14px,3vw,24px);
  position:relative;
  overflow:hidden;
}
.login-page::before,.login-page::after{
  content:'';position:absolute;border-radius:50%;background:rgba(255,255,255,.08);
  pointer-events:none;
}
.login-page::before{width:clamp(280px,60vw,500px);height:clamp(280px,60vw,500px);top:-30%;left:-30%}
.login-page::after{width:clamp(220px,48vw,400px);height:clamp(220px,48vw,400px);bottom:-30%;right:-30%}
.login-card{
  background:#fff;
  border-radius:24px;
  padding:clamp(24px,5vw,40px) clamp(20px,4.5vw,36px);
  width:100%;
  max-width:420px;
  box-shadow:0 40px 80px -20px rgba(15,23,42,.5);
  position:relative;
  z-index:1;
}
.login-logo{text-align:center;margin-bottom:clamp(18px,3vw,24px)}
.login-logo img{height:clamp(48px,10vw,60px);width:auto;margin:0 auto}
.login-card h1{font-size:clamp(18px,4vw,22px);font-weight:800;text-align:center;margin-bottom:6px;letter-spacing:-.02em}
.login-card .sub{text-align:center;color:var(--muted);font-size:13px;margin-bottom:clamp(20px,4vw,28px)}

/* ============================================================
   LAYOUT
   ============================================================ */
.app{display:flex;min-height:100vh;min-height:100dvh}

/* -------- SIDEBAR (desktop) -------- */
.sidebar{
  width:var(--sidebar-w);
  flex-shrink:0;
  background:#fff;
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  position:sticky;
  top:0;
  height:100vh;
  height:100dvh;
  box-shadow:2px 0 20px -12px rgba(15,23,42,.08);
  z-index:50;
}
.sidebar-brand{
  padding:clamp(16px,2vw,22px) 20px clamp(14px,2vw,18px);
  display:flex;align-items:center;justify-content:center;
  border-bottom:1px solid var(--border);
  flex-shrink:0;
}
.sidebar-brand img{height:clamp(36px,7vw,44px);width:auto;max-width:100%;object-fit:contain}
.sidebar-nav{padding:14px 12px;overflow-y:auto;flex:1;-webkit-overflow-scrolling:touch}

.nav-section{
  font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;
  color:#94a3b8;padding:14px 12px 8px;
}
.nav-item{
  display:flex;align-items:center;gap:12px;
  padding:11px 14px;border-radius:12px;
  color:#475569;font-weight:500;margin-bottom:2px;
  transition:background .18s,color .18s;
  min-height:44px;
}
.nav-item:hover{background:#f1f5f9;color:var(--primary-dark)}
.nav-item.active{
  background:var(--grad-primary);color:#fff;
  box-shadow:0 8px 22px -10px rgba(99,102,241,.7);
}
.nav-item .icon{width:20px;display:inline-flex;justify-content:center;flex-shrink:0}

/* -------- MAIN -------- */
.main{flex:1;display:flex;flex-direction:column;min-width:0}

/* -------- TOPBAR (desktop) -------- */
.topbar{
  background:rgba(255,255,255,.9);
  -webkit-backdrop-filter:blur(10px);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);
  padding:clamp(10px,1.6vw,14px) var(--pad-page-x);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  position:sticky;
  top:0;
  z-index:40;
}
.topbar h1{
  font-size:clamp(15px,1.5vw,18px);
  font-weight:700;
  letter-spacing:-.01em;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.topbar h1 span{
  background:var(--grad-primary);
  -webkit-background-clip:text;background-clip:text;color:transparent;
}
.user-chip{
  display:flex;align-items:center;gap:10px;
  padding:5px 12px 5px 5px;
  background:#f8fafc;
  border:1px solid var(--border);
  border-radius:999px;
  flex-shrink:0;
}
.user-chip .avatar{
  width:30px;height:30px;border-radius:50%;
  background:var(--grad-primary);color:#fff;
  display:grid;place-items:center;font-weight:700;font-size:12px;
  flex-shrink:0;
}

.content{
  padding:var(--pad-page-y) var(--pad-page-x) 60px;
  flex:1;
  max-width:1600px;
  width:100%;
  min-width:0;
}

.page-head{
  display:flex;flex-wrap:wrap;gap:var(--gap);
  align-items:center;justify-content:space-between;
  margin-bottom:clamp(14px,2.4vw,22px);
}
.page-head h2{font-size:clamp(18px,3vw,24px);font-weight:800;letter-spacing:-.02em}
.page-head p{color:var(--muted);font-size:13px;margin-top:2px}

/* ============================================================
   CARDS
   ============================================================ */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:var(--pad-card);
  box-shadow:var(--shadow-sm);
}
.card-head{
  display:flex;align-items:center;justify-content:space-between;
  margin-bottom:16px;gap:12px;flex-wrap:wrap;
}
.card-head h3{font-size:16px;font-weight:700}
.card-head .sub{font-size:12px;color:var(--muted)}

/* ============================================================
   STATS
   ============================================================ */
.stats{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr));
  gap:var(--gap);
  margin-bottom:clamp(14px,2.4vw,22px);
}
.stat{
  position:relative;overflow:hidden;
  border-radius:var(--radius);
  padding:clamp(14px,2vw,20px);
  color:#fff;
  box-shadow:var(--shadow);
  background:var(--grad-primary);
}
.stat.blue{background:var(--grad-blue)}
.stat.green{background:var(--grad-green)}
.stat.amber{background:var(--grad-amber)}
.stat.rose{background:var(--grad-rose)}
.stat::after{
  content:'';position:absolute;right:-30px;top:-30px;
  width:120px;height:120px;background:rgba(255,255,255,.14);border-radius:50%;
  pointer-events:none;
}
.stat .label{
  font-size:11.5px;opacity:.92;font-weight:600;
  letter-spacing:.04em;text-transform:uppercase;
}
.stat .value{
  font-size:clamp(20px,3.4vw,28px);
  font-weight:800;margin-top:6px;letter-spacing:-.02em;
  line-height:1.15;
}
.stat .sub{font-size:12px;opacity:.9;margin-top:4px}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  padding:clamp(8px,1.2vw,10px) clamp(14px,2vw,18px);
  border-radius:12px;
  font-weight:600;font-size:clamp(12.5px,1.3vw,13px);
  transition:transform .18s,box-shadow .18s,background .18s,border-color .18s,color .18s;
  white-space:nowrap;
  border:1px solid transparent;
  min-height:40px;
  text-align:center;
}
.btn-primary{background:var(--grad-primary);color:#fff;box-shadow:0 8px 22px -10px rgba(99,102,241,.75)}
.btn-primary:hover{transform:translateY(-1px)}
.btn-primary:active{transform:translateY(0)}
.btn-outline{background:#fff;border:1px solid var(--border);color:var(--text)}
.btn-outline:hover{border-color:var(--primary);color:var(--primary)}
.btn-ghost{color:var(--muted)}
.btn-ghost:hover{color:var(--primary)}
.btn-danger{background:#fee2e2;color:#b91c1c}
.btn-danger:hover{background:#fecaca}
.btn-success{background:var(--grad-green);color:#fff}
.btn-sm{padding:6px 12px;font-size:12px;border-radius:9px;min-height:34px}
.btn:disabled{opacity:.6;cursor:not-allowed;transform:none!important}

/* ============================================================
   FORMS
   ============================================================ */
.form-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(min(240px,100%),1fr));
  gap:var(--gap);
}
.form-group{display:flex;flex-direction:column;gap:6px;min-width:0}
.form-group.full{grid-column:1/-1}
label{font-size:12.5px;font-weight:600;color:#334155}
label .req{color:#ef4444}

input[type=text],input[type=number],input[type=email],input[type=date],input[type=password],
select,textarea{
  width:100%;
  padding:11px 14px;
  border:1.5px solid var(--border);
  border-radius:12px;
  background:#fff;
  transition:border-color .15s,box-shadow .15s;
  outline:none;
  color:var(--text);
  min-height:42px;
}
input:focus,select:focus,textarea:focus{
  border-color:var(--primary);
  box-shadow:0 0 0 4px rgba(99,102,241,.12);
}
textarea{resize:vertical;min-height:80px}

.help{font-size:11.5px;color:var(--muted)}

.section-title{
  font-size:14px;font-weight:700;
  margin:26px 0 14px;
  display:flex;align-items:center;gap:10px;
  padding-bottom:10px;
  border-bottom:2px solid var(--border);
}
.section-title .num{
  width:26px;height:26px;border-radius:8px;
  background:var(--grad-primary);color:#fff;
  display:grid;place-items:center;font-size:12px;font-weight:700;
  flex-shrink:0;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap{
  overflow-x:auto;
  overflow-y:hidden;
  border-radius:var(--radius);
  border:1px solid var(--border);
  background:#fff;
  -webkit-overflow-scrolling:touch;
}
table{width:100%;border-collapse:collapse;font-size:13px;min-width:max-content}
thead{background:#f8fafc}
th{
  text-align:left;
  padding:12px 14px;
  font-weight:700;font-size:11.5px;
  letter-spacing:.04em;text-transform:uppercase;
  color:#475569;
  border-bottom:1px solid var(--border);
  white-space:nowrap;
}
td{padding:12px 14px;border-bottom:1px solid #f1f5f9;vertical-align:middle}
tbody tr:hover{background:#fafbff}
tbody tr:last-child td{border-bottom:none}

/* ============================================================
   BADGES
   ============================================================ */
.badge{
  display:inline-flex;align-items:center;gap:6px;
  padding:4px 11px;border-radius:999px;
  font-size:11.5px;font-weight:700;
  white-space:nowrap;
}
.badge.gray{background:#f1f5f9;color:#475569}
.badge.blue{background:#e0e7ff;color:#4338ca}
.badge.green{background:#d1fae5;color:#047857}
.badge.amber{background:#fef3c7;color:#b45309}
.badge.rose{background:#ffe4e6;color:#be123c}
.badge.purple{background:#ede9fe;color:#6d28d9}

/* ============================================================
   PO CARD
   ============================================================ */
.po-card{
  border:1.5px solid var(--border);
  border-radius:var(--radius);
  padding:clamp(14px,2vw,20px);
  margin-bottom:18px;
  background:#fff;
  position:relative;
  min-width:0;
}
.po-card::before{
  content:'';position:absolute;left:0;top:0;bottom:0;width:4px;
  border-radius:16px 0 0 16px;
  background:var(--grad-primary);
}
.po-head{
  display:flex;justify-content:space-between;align-items:center;
  margin-bottom:16px;gap:12px;flex-wrap:wrap;
}
.po-head h4{font-size:14px;font-weight:700}
.idpo{
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
  font-size:12px;background:#eef2ff;color:#4338ca;
  padding:4px 10px;border-radius:8px;font-weight:600;
  overflow:hidden;text-overflow:ellipsis;max-width:100%;
}

/* ============================================================
   UPLOAD BOX
   ============================================================ */
.upload-box{
  border:2px dashed #cbd5e1;
  border-radius:14px;
  padding:clamp(12px,2vw,18px);
  text-align:center;
  cursor:pointer;
  transition:border-color .18s,background .18s;
  background:#fafbff;
  min-height:180px;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
}
.upload-box:hover{border-color:var(--primary);background:#eef2ff}
.upload-box img{max-width:100%;max-height:clamp(160px,30vw,220px);border-radius:10px;object-fit:contain}
.upload-box .placeholder{color:var(--muted);font-size:12.5px}
.upload-box .placeholder .big{font-size:clamp(26px,5vw,32px);display:block;margin-bottom:8px}

/* ============================================================
   SIZE & COLOR GRID
   ============================================================ */
.size-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(min(72px,100%),1fr));
  gap:clamp(6px,1vw,10px);
}
.size-item{
  border:1.5px solid var(--border);
  border-radius:12px;
  padding:10px 6px;
  background:#fff;text-align:center;
  transition:border-color .15s,box-shadow .15s;
}
.size-item:focus-within{border-color:var(--primary);box-shadow:0 0 0 4px rgba(99,102,241,.12)}
.size-item .lbl{font-size:12px;font-weight:700;color:#334155}
.size-item .extra{font-size:10px;color:var(--muted);margin-bottom:6px;min-height:14px}
.size-item input{
  text-align:center;padding:6px;font-weight:600;border-radius:8px;
  min-height:38px;font-size:14px;
}

.color-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(min(110px,100%),1fr));
  gap:clamp(6px,1vw,10px);
}
.color-item{
  display:flex;align-items:center;gap:8px;
  padding:8px 10px;
  border:1.5px solid var(--border);
  border-radius:10px;
  cursor:pointer;
  transition:border-color .15s,background .15s,box-shadow .15s;
  background:#fff;min-width:0;
}
.color-item:hover{border-color:var(--primary)}
.color-item.selected{
  border-color:var(--primary);background:#eef2ff;
  box-shadow:0 0 0 3px rgba(99,102,241,.12);
}
.color-item .sw{
  width:22px;height:22px;border-radius:50%;
  border:2px solid #fff;box-shadow:0 0 0 1px var(--border);
  flex-shrink:0;
}
.color-item .nm{
  font-size:11.5px;font-weight:600;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}

/* ============================================================
   TOTAL PANEL
   ============================================================ */
.total-panel{
  background:var(--grad-soft);
  border:1.5px solid var(--border);
  border-radius:var(--radius);
  padding:clamp(14px,2vw,22px);
}
.total-row{
  display:flex;justify-content:space-between;
  padding:9px 0;font-size:13.5px;gap:12px;
}
.total-row.grand{
  border-top:2px dashed #c7d2fe;
  margin-top:10px;padding-top:16px;
  font-size:clamp(16px,2vw,18px);font-weight:800;
}
.total-row.grand .v{
  background:var(--grad-primary);
  -webkit-background-clip:text;background-clip:text;color:transparent;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop{
  position:fixed;inset:0;
  background:rgba(15,23,42,.55);
  -webkit-backdrop-filter:blur(4px);
  backdrop-filter:blur(4px);
  display:none;align-items:center;justify-content:center;
  z-index:1000;padding:20px;
}
.modal-backdrop.open{display:flex;animation:fadeIn .2s}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}

.modal{
  background:#fff;
  border-radius:20px;
  max-width:760px;
  width:100%;
  max-height:90vh;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  /* Polish: cegah scroll chaining ke halaman di belakang */
  overscroll-behavior:contain;
  box-shadow:0 30px 80px -20px rgba(15,23,42,.4);
  animation:slideUp .25s;
}
@keyframes slideUp{from{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}
.modal.wide{max-width:1000px}

.modal-head{
  padding:20px 24px;
  border-bottom:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;
  position:sticky;top:0;background:#fff;z-index:2;
}
.modal-head h3{font-size:16px;font-weight:700}
.modal-body{padding:24px}
.modal-foot{
  padding:16px 24px;
  border-top:1px solid var(--border);
  display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap;
  position:sticky;bottom:0;background:#fff;
}
.x-btn{
  width:34px;height:34px;border-radius:10px;
  display:grid;place-items:center;
  background:#f1f5f9;color:#475569;font-size:18px;
  transition:background .15s;flex-shrink:0;
}
.x-btn:hover{background:#e2e8f0}

/* ============================================================
   TOAST
   ============================================================ */
#toast-wrap{
  position:fixed;top:20px;right:20px;z-index:2000;
  display:flex;flex-direction:column;gap:10px;
  pointer-events:none;max-width:calc(100vw - 40px);
}
.toast{
  padding:12px 18px;border-radius:12px;
  color:#fff;font-size:13px;font-weight:600;
  box-shadow:0 12px 30px -10px rgba(15,23,42,.4);
  animation:slideIn .25s;background:var(--grad-primary);
  min-width:220px;transition:opacity .3s,transform .3s;
  pointer-events:auto;
}
.toast.err{background:var(--grad-rose)}
.toast.ok{background:var(--grad-green)}
@keyframes slideIn{from{transform:translateX(20px);opacity:0}to{transform:translateX(0);opacity:1}}

/* ============================================================
   FINANCE CHART
   ============================================================ */
.fin-chart{
  display:flex;align-items:flex-end;gap:clamp(8px,1.6vw,14px);
  height:clamp(140px,22vw,180px);padding:16px 0;
}
.fin-bar-wrap{
  flex:1;display:flex;flex-direction:column;align-items:center;gap:6px;
  height:100%;justify-content:flex-end;min-width:0;
}
.fin-bars{
  display:flex;gap:4px;align-items:flex-end;
  height:100%;width:100%;justify-content:center;
}
.fin-bar{width:clamp(10px,2vw,16px);border-radius:6px 6px 0 0;transition:height .4s;min-height:4px}
.fin-bar.in{background:var(--grad-green)}
.fin-bar.out{background:var(--grad-rose)}
.fin-bar-wrap .lbl{font-size:11px;color:var(--muted);font-weight:600}

/* ============================================================
   TABS
   ============================================================ */
.tabs{
  display:flex;gap:4px;
  border-bottom:2px solid var(--border);
  margin-bottom:20px;
  flex-wrap:wrap;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
.tab{
  position:relative;
  display:inline-flex;align-items:center;gap:8px;
  padding:10px 18px;
  border-radius:10px 10px 0 0;
  font-weight:600;font-size:13px;
  color:var(--muted);
  cursor:pointer;
  transition:color .15s,background .15s,border-color .15s;
  margin-bottom:-2px;
  border-bottom:2px solid transparent;
  white-space:nowrap;
  min-height:42px;
}
.tab:hover{color:var(--primary)}
.tab.active{color:var(--primary-dark);border-bottom-color:var(--primary);background:#f5f3ff}
.tab .count{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:22px;height:20px;padding:0 7px;
  border-radius:10px;font-size:11px;font-weight:800;
  background:#e2e8f0;color:#475569;transition:.2s;
}
.tab.active .count{background:var(--primary);color:#fff}
.tab:hover .count{background:#c7d2fe;color:var(--primary-dark)}
.tab.active:hover .count{background:var(--primary-dark);color:#fff}

/* ============================================================
   DETAIL
   ============================================================ */
.detail-header{display:grid;grid-template-columns:1fr auto;gap:20px;align-items:start}
.info-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(180px,100%),1fr));gap:14px 24px}
.info-item .lbl{
  font-size:11px;color:var(--muted);text-transform:uppercase;
  font-weight:600;letter-spacing:.04em;
}
.info-item .val{font-weight:600;margin-top:2px;overflow-wrap:break-word}

.po-mini{
  display:grid;grid-template-columns:120px 1fr;gap:16px;
  padding:16px;border:1px solid var(--border);border-radius:14px;
  margin-bottom:14px;background:#fff;
}
.po-mini img{width:120px;height:120px;object-fit:cover;border-radius:10px;border:1px solid var(--border)}
.po-mini .no-img{
  width:120px;height:120px;border-radius:10px;background:#f1f5f9;
  display:grid;place-items:center;font-size:32px;color:#cbd5e1;
}

/* ============================================================
   SABLON PREVIEW (untuk Kode Sablon)
   ============================================================ */
.sablon-preview{
  margin-top:12px;
  padding:clamp(12px,2vw,16px);
  background:linear-gradient(135deg,#f8fafc 0%,#eef2ff 100%);
  border-radius:12px;
  border:1px dashed #c7d2fe;
}
.sablon-preview .preview-row{
  display:flex;gap:clamp(14px,3vw,24px);
  align-items:flex-start;justify-content:center;
  flex-wrap:wrap;margin-bottom:12px;
}
.sablon-side{
  display:flex;flex-direction:column;align-items:center;gap:8px;
}
.sablon-tshirt{
  position:relative;
  width:clamp(84px,22vw,130px);
  aspect-ratio:130/150;
  flex-shrink:0;
}
.sablon-tshirt svg{width:100%;height:100%;display:block}
.sablon-print{
  position:absolute;top:56%;left:50%;
  transform:translate(-50%,-50%);
  background:linear-gradient(135deg,#6366f1 0%,#ec4899 100%);
  border-radius:6px;
  display:flex;align-items:center;justify-content:center;
  color:#fff;font-weight:800;font-size:10px;letter-spacing:.02em;
  box-shadow:0 4px 12px rgba(99,102,241,.45);
  border:2px solid rgba(255,255,255,.7);
  transition:width .25s,height .25s;
}
.sablon-preview .sablon-desc{
  text-align:center;font-size:12px;font-weight:600;
  color:var(--text);padding:8px 14px;
  background:rgba(99,102,241,.08);
  border-radius:8px;
  border:1px solid rgba(99,102,241,.2);
}

/* ============================================================
   EMPTY & LOADER
   ============================================================ */
.empty{text-align:center;padding:40px 20px;color:var(--muted)}
.empty .big{font-size:44px;margin-bottom:10px;opacity:.5}
.loader{
  width:34px;height:34px;
  border:3px solid #e2e8f0;
  border-top-color:var(--primary);
  border-radius:50%;
  animation:spin .8s linear infinite;
  margin:36px auto;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* ============================================================
   MENU TOGGLE (desktop: hidden)
   ============================================================ */
.menu-toggle{
  display:none;
  background:#f1f5f9;
  padding:8px 10px;
  border-radius:10px;
  font-size:16px;
  flex-shrink:0;
  min-width:40px;min-height:40px;
  align-items:center;justify-content:center;
  position:relative;
  z-index:2;
}

/* ============================================================
   PRINT
   ============================================================ */
.print-area{display:none}
@media print{
  @page{size:A4;margin:12mm}
  body{background:#fff!important}
  body.printing > *:not(#printArea){display:none!important}
  body.printing #printArea{display:block!important;padding:0;margin:0;color:#000}
  .no-print{display:none!important}
  .print-doc{font-family:'Inter',Arial,sans-serif;color:#0f172a;font-size:12px;line-height:1.5}
  .print-doc .head{
    display:flex;justify-content:space-between;align-items:flex-start;
    padding-bottom:14px;border-bottom:3px solid #6366f1;margin-bottom:20px;
  }
  .print-doc .head img{height:52px}
  .print-doc h2{font-size:20px;margin-bottom:4px;letter-spacing:-.01em}
  .print-doc h3{font-size:14px;margin-bottom:8px;color:#4f46e5;text-transform:uppercase;letter-spacing:.04em}
  .print-doc .meta{font-size:11.5px;color:#475569;text-align:right}
  .print-doc .box{border:1px solid #cbd5e1;border-radius:10px;padding:14px;margin-bottom:14px}
  .print-doc .grid2{display:grid;grid-template-columns:1fr 1fr;gap:16px}
  .print-doc table{width:100%;border-collapse:collapse;margin:10px 0}
  .print-doc th,.print-doc td{border:1px solid #cbd5e1;padding:8px 10px;font-size:11.5px;text-align:left}
  .print-doc th{background:#eef2ff;color:#3730a3}
  .print-doc .right{text-align:right}
  .print-doc .grand{font-size:16px;font-weight:800;color:#4f46e5}
  .print-doc img.desain{max-width:220px;max-height:220px;border-radius:10px;border:1px solid #cbd5e1}
  .print-doc .page-break{page-break-after:always;height:0}
  .print-doc .sign{margin-top:40px;display:flex;justify-content:space-between}
  .print-doc .sign .col{text-align:center;width:180px}
  .print-doc .sign .line{margin-top:60px;border-top:1px solid #94a3b8;padding-top:4px;font-size:11px}
  .print-doc .badge-p{
    border:1px solid #4f46e5;color:#4f46e5;padding:3px 10px;
    border-radius:20px;font-size:10.5px;font-weight:700;display:inline-block;
  }
}

/* ============================================================
   RESPONSIVE — TABLET LANDSCAPE
   ============================================================ */
@media (max-width:1200px){
  :root{--sidebar-w:240px}
}

/* ============================================================
   RESPONSIVE — TABLET PORTRAIT & MOBILE (≤900px)
   ============================================================ */
@media (max-width:900px){

  .sidebar{
    position:fixed;
    top:0;
    left:calc(-1 * min(290px, 82vw) - 20px);
    bottom:0;
    width:min(290px, 82vw);
    height:100vh;
    height:100dvh;
    border-right:none;
    box-shadow:none;
    transition:left .3s cubic-bezier(.4,0,.2,1), box-shadow .3s;
    z-index:60;
    padding-top:env(safe-area-inset-top);
    padding-bottom:env(safe-area-inset-bottom);
  }
  .sidebar.open{
    left:0;
    box-shadow:
      0 0 0 100vmax rgba(15,23,42,.5),
      4px 0 30px -8px rgba(15,23,42,.35);
  }

  .sidebar-brand{padding:16px 16px 14px}
  .sidebar-brand img{height:40px}

  .topbar{
    position:relative;
    min-height:var(--topbar-h);
    padding:10px var(--pad-page-x);
    padding-top:calc(10px + env(safe-area-inset-top));
    gap:0;
  }

  .topbar h1{
    position:absolute;
    width:1px;height:1px;
    padding:0;margin:-1px;
    overflow:hidden;
    clip:rect(0,0,0,0);
    white-space:nowrap;
    border:0;
  }

  .topbar::before{
    content:'';
    position:absolute;
    left:50%;
    top:50%;
    transform:translate(-50%, -50%);
    width:clamp(96px, 32vw, 140px);
    height:clamp(28px, 8vw, 40px);
    background-image:url(assets/logo_web.png);
    background-repeat:no-repeat;
    background-position:center;
    background-size:contain;
    pointer-events:none;
    z-index:1;
    margin-top:calc(env(safe-area-inset-top) / 2);
  }

  .menu-toggle{
    display:inline-flex !important;
    min-width:44px;
    min-height:44px;
    font-size:18px;
    align-self:center;
  }

  .user-chip{
    padding:4px;
    gap:0;
    align-self:center;
  }
  .user-chip > div:last-child{
    display:none;
  }
  .user-chip .avatar{
    width:36px;
    height:36px;
    font-size:12px;
  }

  .content{padding-bottom:80px}

  #dashGrid{grid-template-columns:1fr !important}
  .detail-header{grid-template-columns:1fr}
  .po-mini{grid-template-columns:1fr}
  .po-mini img,.po-mini .no-img{width:100%;height:200px}

  .po-item > .form-grid{grid-template-columns:1fr !important}

  .modal{max-width:min(680px,100%)}
  .modal.wide{max-width:100%}
}

/* ============================================================
   RESPONSIVE — LARGE PHONES (≤640px)
   ============================================================ */
@media (max-width:640px){
  .page-head{flex-direction:column;align-items:stretch}
  .page-head > div:last-child{
    display:flex !important;
    flex-wrap:wrap;
    gap:6px;
  }
  .page-head > div:last-child .btn{
    flex:1 1 auto;
    min-width:0;
    padding-left:10px;padding-right:10px;
  }

  .card-head{gap:8px}
  .card-head h3{font-size:15px}
  .section-title{font-size:13px;margin:20px 0 12px}

  .stats{grid-template-columns:repeat(2,1fr)}
  .stat .label{font-size:10.5px}
  .stat .sub{font-size:11px}

  th{padding:9px 10px;font-size:10.5px}
  td{padding:9px 10px;font-size:12px}

  .modal-backdrop{padding:0;align-items:flex-end}
  .modal{
    border-radius:18px 18px 0 0;
    max-width:100%;
    max-height:92vh;
    max-height:92dvh;
    animation:slideUpSheet .28s cubic-bezier(.4,0,.2,1);
  }
  @keyframes slideUpSheet{
    from{transform:translateY(100%);opacity:.7}
    to{transform:translateY(0);opacity:1}
  }
  .modal-head,.modal-foot{padding:14px 16px}
  .modal-body{padding:16px}
  .modal-foot .btn{flex:1 1 auto;min-width:0}

  #toast-wrap{
    top:auto;bottom:12px;left:12px;right:12px;
    max-width:none;
  }
  .toast{min-width:0;width:100%}

  .tab{padding:8px 12px;font-size:12px;min-height:38px}
  .tab .count{min-width:20px;height:18px;font-size:10.5px}

  .po-card::before{width:3px}

  .upload-box{min-height:150px}

  input[type=text],input[type=number],input[type=email],input[type=date],input[type=password],
  select,textarea{
    padding:11px 12px;
    font-size:16px;
  }

  .total-row{font-size:13px}
}

/* ============================================================
   RESPONSIVE — SMALL PHONES (≤480px)
   ============================================================ */
@media (max-width:480px){
  :root{--topbar-h:56px}

  .topbar::before{
    width:clamp(88px, 34vw, 118px);
    height:clamp(26px, 8vw, 34px);
  }

  .stats{grid-template-columns:1fr}
  .stat .value{font-size:22px}

  .page-head h2{font-size:17px}
  .page-head p{font-size:11.5px}

  .btn{padding:8px 12px;font-size:12px;min-height:38px}
  .btn-sm{padding:6px 10px;font-size:11.5px;min-height:32px}

  .sablon-tshirt{width:clamp(76px,26vw,100px)}

  .login-card{padding:24px 20px;border-radius:20px}
  .login-logo img{height:46px}

  .modal{border-radius:16px 16px 0 0}
}

/* ============================================================
   RESPONSIVE — VERY SMALL PHONES (≤380px)
   ============================================================ */
@media (max-width:380px){
  :root{--pad-card:12px;--topbar-h:54px}

  .card{border-radius:14px}

  .topbar::before{
    width:clamp(80px, 36vw, 104px);
    height:clamp(24px, 7vw, 30px);
  }

  .menu-toggle{min-width:40px;min-height:40px;font-size:16px}
  .user-chip .avatar{width:32px;height:32px;font-size:11px}

  .tab{padding:7px 10px;font-size:11.5px}
  .tab .count{min-width:18px;height:16px;font-size:10px;padding:0 5px}
  .btn{padding:7px 10px;font-size:11.5px}
  .form-group label{font-size:11.5px}
  .stat .value{font-size:20px}
  .idpo{font-size:11px;padding:3px 8px}
}

/* ============================================================
   TOUCH DEVICES — hapus efek hover yang tidak relevan
   ============================================================ */
@media (hover:none){
  .btn-primary:hover{transform:none}
  .color-item:hover{border-color:var(--border)}
  .color-item.selected:hover{border-color:var(--primary)}
  .nav-item:hover{background:transparent;color:inherit}
  .nav-item.active:hover{background:var(--grad-primary);color:#fff}
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.01ms!important;
    animation-iteration-count:1!important;
    transition-duration:.01ms!important;
  }
}

/* ============================================================
   GLOBAL LOADING OVERLAY
   ============================================================ */
.global-loading-overlay{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.35);
  -webkit-backdrop-filter:blur(6px);
  backdrop-filter:blur(6px);
  z-index:99999;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease;
}
.global-loading-overlay.show{
  opacity:1;
  pointer-events:auto;
}

.global-loading-card{
  background:#fff;
  border-radius:18px;
  padding:28px 36px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:14px;
  min-width:220px;
  box-shadow:0 24px 60px -20px rgba(15,23,42,.5);
  animation:globalLoadPop .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes globalLoadPop{
  from{transform:scale(.9);opacity:0}
  to{transform:scale(1);opacity:1}
}

.global-loading-spinner{
  width:44px;
  height:44px;
  border-radius:50%;
  border:4px solid #e2e8f0;
  border-top-color:#6366f1;
  animation:globalLoadSpin .8s linear infinite;
}
@keyframes globalLoadSpin{
  to{transform:rotate(360deg)}
}

.global-loading-msg{
  font-size:13.5px;
  font-weight:600;
  color:#0f172a;
  text-align:center;
  max-width:280px;
  line-height:1.4;
}

/* Mobile */
@media (max-width:480px){
  .global-loading-card{
    padding:24px 28px;
    min-width:180px;
  }
  .global-loading-spinner{
    width:38px;
    height:38px;
    border-width:3px;
  }
  .global-loading-msg{
    font-size:12.5px;
  }
}


/* ============================================================
   MOBILE REDESIGN — Dashboard & Finance
   Compact KPI strip · hemat scroll · tahan nominal besar
   ============================================================ */
@media (max-width:640px){

  /* ===== DASHBOARD: 4 stat cards → 2×2 compact ===== */
  .stats:not(#bucketRow){
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
  }
  .stats:not(#bucketRow) .stat{
    padding: 12px 14px !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 16px -8px rgba(15,23,42,.3) !important;
  }
  .stats:not(#bucketRow) .stat .label{
    font-size: 10px !important;
    letter-spacing: 0 !important;
    opacity: .95;
    line-height: 1.3;
  }
  .stats:not(#bucketRow) .stat .value{
    font-size: 17px !important;
    margin-top: 3px !important;
    line-height: 1.15 !important;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
    word-break: break-word;
  }
  .stats:not(#bucketRow) .stat .sub{
    font-size: 10px !important;
    margin-top: 2px !important;
    opacity: .85;
    line-height: 1.25;
  }
  .stats:not(#bucketRow) .stat::after{
    width: 70px !important;
    height: 70px !important;
    right: -20px !important;
    top: -20px !important;
    opacity: .8;
  }

  /* ===== DASHBOARD: 3 bucket → 3-across strip ===== */
  #bucketRow{
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    margin-bottom: 12px !important;
  }
  #bucketRow .stat{
    padding: 10px 8px !important;
    border-radius: 10px !important;
    box-shadow: 0 3px 12px -6px rgba(15,23,42,.3) !important;
    min-width: 0;
  }
  #bucketRow .stat .label{
    font-size: 8.5px !important;
    letter-spacing: 0 !important;
    line-height: 1.25 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: .95;
  }
  #bucketRow .stat .value{
    font-size: 11.5px !important;
    margin-top: 4px !important;
    line-height: 1.2 !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.03em;
    word-break: break-word;
  }
  #bucketRow .stat .sub{
    display: none !important;
  }
  #bucketRow .stat::after{
    display: none !important;
  }

  /* ===== FINANCE: 3 stats-triple → 3-across strip ===== */
  .stats-triple{
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    margin-bottom: 12px !important;
  }
  .stats-triple .stat{
    padding: 10px 8px !important;
    border-radius: 10px !important;
    box-shadow: 0 3px 12px -6px rgba(15,23,42,.3) !important;
    min-width: 0;
  }
  .stats-triple .stat .label{
    font-size: 8.5px !important;
    letter-spacing: 0 !important;
    line-height: 1.25 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: .95;
  }
  .stats-triple .stat .value{
    font-size: 11.5px !important;
    margin-top: 4px !important;
    line-height: 1.2 !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.03em;
    word-break: break-word;
  }
  .stats-triple .stat .sub{
    display: none !important;
  }
  .stats-triple .stat::after{
    display: none !important;
  }

  /* ===== FINANCE: bucket-grid → 3-across strip ===== */
  .bucket-grid{
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    margin-bottom: 12px !important;
  }
  .bucket-grid .bucket-card{
    padding: 10px 8px !important;
    border-radius: 10px !important;
    box-shadow: 0 3px 12px -6px rgba(15,23,42,.3) !important;
    min-width: 0;
  }
  .bucket-grid .bucket-card .label{
    font-size: 8.5px !important;
    letter-spacing: 0 !important;
    line-height: 1.25 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: .95;
  }
  .bucket-grid .bucket-card .value{
    font-size: 11.5px !important;
    margin-top: 4px !important;
    line-height: 1.2 !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.03em;
    word-break: break-word;
  }
  .bucket-grid .bucket-card .sub{
    display: none !important;
  }
  .bucket-grid .bucket-card::after{
    display: none !important;
  }

  /* ===== CHART: kecilkan tinggi ===== */
  .fin-chart{
    height: 130px !important;
    gap: 6px !important;
    padding: 8px 0 !important;
  }
  .fin-bar-wrap .lbl{
    font-size: 9.5px !important;
  }

  /* ===== CONTENT, CARD, PAGE HEAD ===== */
  .content{
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
  .card{
    padding: 12px !important;
    border-radius: 12px !important;
  }
  .card-head{
    margin-bottom: 10px !important;
    gap: 8px !important;
  }
  .card-head h3{
    font-size: 14px !important;
  }
  .card-head .sub{
    font-size: 10.5px !important;
  }

  .page-head{
    margin-bottom: 12px !important;
  }
  .page-head h2{
    font-size: 17px !important;
  }
  .page-head p{
    font-size: 11.5px !important;
  }

  #dashGrid{
    gap: 12px !important;
    margin-bottom: 14px !important;
  }
  .stats{
    margin-bottom: 12px !important;
  }

  /* ===== FINANCE: alokasi, tab, month nav ===== */
  .alokasi-box{
    padding: 12px !important;
    margin-top: 10px !important;
  }
  .alokasi-box h4{
    font-size: 10.5px !important;
    margin-bottom: 8px !important;
  }
  .alokasi-line{
    font-size: 12px !important;
    padding: 4px 0 !important;
  }
  .alokasi-line .val{
    font-size: 12.5px !important;
    font-variant-numeric: tabular-nums;
  }

  .fin-tabs{
    margin-bottom: 12px !important;
  }
  .fin-tab{
    padding: 10px 14px !important;
    font-size: 12.5px !important;
  }
  .fin-tab .badge-icon{
    font-size: 15px !important;
  }

  .month-nav{
    margin-bottom: 10px !important;
    gap: 6px !important;
  }
  .month-nav input[type="month"]{
    padding: 8px 10px !important;
    font-size: 12.5px !important;
  }
  .month-nav .nav-btn{
    padding: 8px 10px !important;
    min-width: 34px !important;
  }
  .month-nav .btn-ghost{
    font-size: 11.5px !important;
    padding: 6px 8px !important;
  }
}

/* ============================================================
   HP KECIL (≤380px) — perkecil lagi agar "Rp 99.999.999" muat
   ============================================================ */
@media (max-width:380px){
  #bucketRow .stat .value,
  .stats-triple .stat .value,
  .bucket-grid .bucket-card .value{
    font-size: 10.5px !important;
    letter-spacing: -.04em !important;
  }
  #bucketRow .stat .label,
  .stats-triple .stat .label,
  .bucket-grid .bucket-card .label{
    font-size: 8px !important;
  }
  .stats:not(#bucketRow) .stat .value{
    font-size: 15px !important;
  }
  .stats:not(#bucketRow) .stat{
    padding: 10px 12px !important;
  }
}