:root {
  --primary: #534AB7; --primary-light: #EEEDFE; --primary-mid: #AFA9EC;
  --success: #1D9E75; --success-light: #E1F5EE;
  --danger: #E24B4A; --danger-light: #FCEBEB;
  --warning: #BA7517; --warning-light: #FAEEDA;
  --bg: #f5f4f0; --surface: #ffffff; --border: rgba(0,0,0,0.1);
  --text: #1a1a1a; --text-muted: #666; --text-hint: #999;
  --radius: 10px; --radius-sm: 6px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
input, select, textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { height: 60px; resize: vertical; }
button { cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; border: none; padding: 7px 16px; border-radius: var(--radius-sm); font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
.btn-primary:hover { background: #3C3489; }
.btn-secondary { background: #f0f0f0; color: var(--text-muted); border: 1px solid var(--border); padding: 7px 16px; border-radius: var(--radius-sm); font-size: 13px; }
.btn-danger { background: none; color: #A32D2D; border: 1px solid #F7C1C1; padding: 7px 16px; border-radius: var(--radius-sm); font-size: 13px; }
.full { width: 100%; justify-content: center; padding: 10px; }
.err-msg { color: #A32D2D; font-size: 12px; background: var(--danger-light); padding: 7px 10px; border-radius: var(--radius-sm); margin-bottom: 8px; }

/* LOGIN */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-box { background: var(--surface); border-radius: var(--radius); padding: 2rem; width: 340px; border: 1px solid var(--border); }
.login-logo { font-size: 24px; font-weight: 700; color: var(--primary); text-align: center; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 1.5rem; }

/* LAYOUT */
#page-main { display: flex; min-height: 100vh; }
.sidebar { width: 200px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1rem 0; flex-shrink: 0; }
.sidebar-logo { font-size: 18px; font-weight: 700; color: var(--primary); padding: 0 1rem 1rem; border-bottom: 1px solid var(--border); }
.sidebar-user { font-size: 12px; color: var(--text-muted); padding: .75rem 1rem; border-bottom: 1px solid var(--border); margin-bottom: .5rem; }
.sidebar-menu { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 .5rem; }
.menu-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm); background: none; border: none; color: var(--text-muted); font-size: 13px; width: 100%; text-align: left; }
.menu-item:hover { background: var(--primary-light); color: var(--primary); }
.menu-item.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.menu-item i { font-size: 16px; }
.logout-btn { margin: .5rem .5rem 0; color: var(--danger) !important; }
.logout-btn:hover { background: var(--danger-light) !important; }
.main-content { flex: 1; padding: 1.5rem; overflow-y: auto; min-width: 0; }

/* PAGE HEADER */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; flex-wrap: wrap; gap: 8px; }
.page-header h1 { font-size: 20px; font-weight: 600; }
.notif-bar { margin-top: 4px; font-size: 12px; color: #A32D2D; font-weight: 500; }

/* STATS */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 10px; margin-bottom: 1rem; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: .75rem 1rem; border: 1px solid var(--border); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.stat-val { font-size: 22px; font-weight: 600; }

/* FILTERS */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-btn { font-size: 12px; padding: 4px 12px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); }
.filter-btn.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary-mid); font-weight: 500; }

/* ===== DASHBOARD ERP MODERN ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 12px; margin-bottom: 1.25rem; }
.kpi-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.kpi-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.kpi-card.k-green::before { background: var(--success); }
.kpi-card.k-red::before { background: var(--danger); }
.kpi-card.k-amber::before { background: var(--warning); }
.kpi-card.clickable { cursor: pointer; }
.kpi-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); border-color: var(--primary-mid); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kpi-label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; background: var(--primary-light); color: var(--primary); flex-shrink: 0; }
.kpi-icon.k-green { background: var(--success-light); color: var(--success); }
.kpi-icon.k-red { background: var(--danger-light); color: var(--danger); }
.kpi-icon.k-amber { background: var(--warning-light); color: var(--warning); }
.kpi-val { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.15; }
.kpi-sub { font-size: 11px; color: var(--text-hint); margin-top: 4px; }

.dash-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.dash-section-title { font-size: 13px; font-weight: 600; margin-bottom: .85rem; display: flex; align-items: center; gap: 6px; }
.dash-section-title i { font-size: 16px; color: var(--primary); }
.dash-row { display: grid; gap: 1rem; margin-bottom: 1rem; }
.dash-row.r-2-1 { grid-template-columns: 2fr 1fr; }
.dash-row.r-1-1 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .dash-row.r-2-1, .dash-row.r-1-1 { grid-template-columns: 1fr; } }

/* Gauge skor risiko */
.gauge-wrap { position: relative; width: 100%; max-width: 240px; margin: 0 auto; }
.gauge-score { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; }
.gauge-num { font-size: 32px; font-weight: 800; line-height: 1; }
.gauge-cap { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

/* Insight & peringatan */
.insight { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border-radius: 8px; margin-bottom: 8px; font-size: 12.5px; line-height: 1.45; }
.insight:last-child { margin-bottom: 0; }
.insight i { font-size: 16px; margin-top: 1px; flex-shrink: 0; }
.insight b { font-weight: 700; }
.insight-red { background: var(--danger-light); color: #791F1F; }
.insight-amber { background: var(--warning-light); color: #633806; }
.insight-green { background: var(--success-light); color: #085041; }
.insight-blue { background: var(--primary-light); color: #3C3489; }

/* ===== GANTT JADWAL PRODUKSI ===== */
.gantt-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 11px; color: var(--text-muted); margin-bottom: .75rem; }
.gantt-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.gantt-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.gantt-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); min-height: 34px; }
.gantt-row:last-child { border-bottom: none; }
.gantt-head { background: var(--bg); font-weight: 600; position: sticky; top: 0; z-index: 2; }
.gantt-label { width: 165px; flex-shrink: 0; padding: 5px 10px; border-right: 1px solid var(--border); font-size: 11px; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.gantt-label .gl-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-label .gl-sub { font-size: 10px; color: var(--text-hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-track { position: relative; flex: 1; min-width: 460px; }
.gantt-head .gantt-track { display: flex; }
.gantt-col { flex: 1; text-align: center; font-size: 10px; color: var(--text-muted); padding: 4px 0; border-right: 1px solid rgba(0,0,0,.04); line-height: 1.25; }
.gantt-col.wknd { background: rgba(0,0,0,.03); }
.gantt-col.tdy { background: var(--primary-light); color: var(--primary); font-weight: 700; }
.gantt-bar { position: absolute; top: 6px; height: 21px; border-radius: 4px; display: flex; align-items: center; padding: 0 7px; font-size: 10px; color: #fff; white-space: nowrap; overflow: hidden; cursor: pointer; transition: filter .12s; }
.gantt-bar:hover { filter: brightness(1.1); }
.gantt-bar.telat { outline: 2px solid var(--danger); outline-offset: -2px; }
.gantt-today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); opacity: .5; z-index: 1; }
.gantt-empty { padding: 2rem; text-align: center; color: var(--text-hint); font-size: 13px; }

/* ORDER CARDS */
.order-grid { display: flex; flex-direction: column; gap: 8px; }
.order-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.order-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(83,74,183,.1); }
.order-card.urgent { border-left: 3px solid var(--danger); }
.order-card.done-card { opacity: .8; border-left: 3px solid var(--success); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.card-name { font-size: 14px; font-weight: 600; }
.card-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 20px; font-weight: 500; white-space: nowrap; }
.b-Hijab { background: var(--success-light); color: #085041; }
.b-Jersey { background: #E6F1FB; color: #0C447C; }
.b-Batik { background: var(--warning-light); color: #633806; }
.b-PrintOnly { background: #FBEAF0; color: #72243E; }
.b-PrintPress { background: var(--primary-light); color: #3C3489; }
.b-Campuran { background: #F0F4F8; color: #2D3748; }
.b-admin { background: var(--primary-light); color: #3C3489; }
.b-desainer { background: var(--success-light); color: #085041; }
.b-operator { background: var(--warning-light); color: #633806; }
.b-owner { background: #FCEBEB; color: #791F1F; }
.card-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.meta-item { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 3px; }
.meta-item i { font-size: 13px; }
.meta-urgent { color: #A32D2D !important; }
.steps { display: flex; gap: 3px; margin-bottom: 4px; }
.step { flex: 1; height: 5px; border-radius: 3px; }
.s-done { background: var(--success); }
.s-active { background: var(--primary); }
.s-pending { background: #e0e0e0; }
.cur-stage { font-size: 11px; font-weight: 500; color: var(--primary); }
.cur-done { font-size: 11px; font-weight: 500; color: var(--success); }

/* MODAL */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto; }
.modal-bg.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 1.25rem; width: 100%; max-width: 480px; margin: auto; border: 1px solid var(--border); }
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 1rem; }
.fg { margin-bottom: .85rem; }
.fg label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 3px; }
.fr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1rem; }
.add-item-btn { font-size: 12px; color: var(--primary); border: 1px dashed var(--primary-mid); background: none; padding: 5px 12px; border-radius: var(--radius-sm); width: 100%; margin-top: 2px; }

/* ITEM ROW */
.item-row { display: grid; grid-template-columns: 2fr 110px 60px 100px 26px 26px; gap: 4px; align-items: end; margin-bottom: 5px; }
.rm-btn { padding: 4px 6px; border-radius: var(--radius-sm); border: 1px solid #F7C1C1; background: none; color: #A32D2D; font-size: 12px; }
.dup-btn { padding: 4px 6px; border-radius: var(--radius-sm); border: 1px solid var(--primary-mid); background: var(--primary-light); color: var(--primary); font-size: 12px; }
@media (max-width: 640px) {
  .item-row { grid-template-columns: 1fr; gap: 4px; }
  .item-row input, .item-row select { width: 100%; }
}

/* SUMMARY */
.summary-box { background: var(--bg); border-radius: var(--radius-sm); padding: .75rem 1rem; margin-top: .75rem; }
.s-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.s-row.total { font-weight: 600; font-size: 15px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; }

/* DETAIL MODAL */
.di-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: .75rem; }
.di-label { font-size: 10px; color: var(--text-muted); margin-bottom: 1px; }
.di-val { font-size: 13px; font-weight: 600; }
.stage-list { display: flex; flex-direction: column; gap: 5px; margin: .5rem 0; }
.stage-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.stage-row.done-r { background: var(--success-light); border-color: #9FE1CB; }
.stage-row.active-r { background: var(--primary-light); border-color: var(--primary-mid); }
.stage-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot-d { background: var(--success); } .dot-a { background: var(--primary); } .dot-p { background: #ccc; }
.stage-name { flex: 1; font-size: 12px; }
.ss { font-size: 10px; padding: 2px 8px; border-radius: 20px; }
.ss-done { background: var(--success-light); color: #085041; }
.ss-active { background: var(--primary-light); color: #3C3489; }
.ss-pending { color: var(--text-hint); }
.adv-btn { font-size: 11px; padding: 3px 10px; border-radius: var(--radius-sm); border: 1px solid var(--primary-mid); background: var(--primary-light); color: #3C3489; }
.adv-btn:hover { background: #CECBF6; }
.nota-link-btn { width: 100%; padding: 8px; border-radius: var(--radius-sm); border: 1px solid var(--primary-mid); background: var(--primary-light); color: #3C3489; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: .5rem; }
.nota-link-btn:hover { background: #CECBF6; }
.section-lbl { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: .75rem 0 .4rem; }

/* NOTA VIEW */
.nota-view { font-size: 13px; }
.nv-header { display: flex; justify-content: space-between; margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--border); }
.nv-company { font-size: 16px; font-weight: 700; }
.nv-addr { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin-top: 3px; }
.nv-title { font-size: 14px; font-weight: 600; color: var(--primary); }
.nv-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: .75rem; }
.nv-ml { font-size: 10px; color: var(--text-muted); margin-bottom: 1px; }
.nv-mv { font-size: 13px; font-weight: 600; }
.nv-table { width: 100%; border-collapse: collapse; margin-bottom: .75rem; }
.nv-table th { background: var(--bg); padding: 6px 8px; font-size: 11px; border-bottom: 1px solid var(--border); text-align: left; }
.nv-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.nv-table tr:last-child td { border-bottom: none; }
.nv-summary { margin-left: auto; width: 200px; }
.nv-s-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; border-bottom: 1px solid var(--border); }
.nv-s-row:last-child { border-bottom: none; font-weight: 700; font-size: 14px; }
.pay-badge { font-size: 11px; padding: 3px 10px; border-radius: 20px; }
.pay-lunas { background: var(--success-light); color: #085041; }
.pay-belum { background: var(--danger-light); color: #791F1F; }
.pay-dp { background: var(--warning-light); color: #633806; }

/* NOTA CARD */
.nota-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1.1rem; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.nota-card:hover { border-color: var(--primary); }

/* USER CARD */
.user-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1.1rem; display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: var(--primary); flex-shrink: 0; }

/* RESPONSIVE */
@media (max-width: 640px) {
  .sidebar { width: 56px; }
  .sidebar span, .sidebar-logo, .sidebar-user { display: none; }
  .menu-item { justify-content: center; padding: 10px; }
  .main-content { padding: 1rem; }
  .fr { grid-template-columns: 1fr; }
}
