:root{
  --bg:#ffffff;
  --card:#ffffff;
  --muted:#6b7280;
  --muted-2:#374151;
  --text:#111827;
  --accent:#0ea5e9;
  --accent-2:#22d3ee;
  --good:#16a34a;
  --warn:#f59e0b;
  --danger:#ef4444;
  --border:#e5e7eb;
}

/* === BASE === */
html,body{height:100%}
body{
  margin:0;
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,"Helvetica Neue",Arial;
  background:var(--bg);
  color:var(--text);
}
.pema-ce .container{max-width:1200px;margin:24px auto;padding:16px}
.pema-ce .card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:0 10px 30px rgba(0,0,0,.06);
}

/* === HEADER === */
header{
  display:block;
  padding:18px 20px;
  border-bottom:1px solid var(--border);
}
header .hdr-title{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-bottom:14px;
  align-items:center;
  text-align:center;
}
header h1{
  margin:0;
  font-size:20px;
  letter-spacing:.2px;
  line-height:1.25;
}
.badge{
  font-size:12px;
  color:#001018;
  background:linear-gradient(90deg,var(--accent),var(--accent-2));
  padding:6px 10px;
  border-radius:999px;
  font-weight:700;
  width:max-content;
  align-self:center;
}
.sub{
  font-size:12px;
  color:var(--muted);
  text-align:center;
}
header .hdr-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:center;
}

/* === FORM CONTROLS === */
.grid{display:grid;gap:12px}
.grid.cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid.cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.grid.cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}
@media (max-width:900px){
  .grid.cols-3{grid-template-columns:repeat(2,minmax(0,1fr))}
  .grid.cols-4{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:640px){
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4{grid-template-columns:1fr}
}
.row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
label{
  font-size:12px;
  color:var(--muted);
}
input,
select,
textarea,
button{
  background:#fff;
  color:var(--text);
  border:1px solid var(--border);
  border-radius:10px;
  padding:9px 11px;
  font-size:14px;
  outline:none;
  transition:.15s ease;
}
input:focus,
select:focus,
textarea:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(14,165,233,.15);
}
.btn{
  cursor:pointer;
  transition:filter .15s ease;
}
.btn.primary{
  background:linear-gradient(90deg,var(--accent),var(--accent-2));
  color:#001727;
  border:none;
  font-weight:700;
}
.btn.ghost{background:#fff}
.btn:hover{filter:brightness(0.97)}
.btn:disabled{opacity:.55;cursor:not-allowed}

/* === TOOLBAR & TABS === */
.toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  align-items:center;
}
.tabs{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}
.tab{
  padding:8px 12px;
  border-radius:10px;
  border:1px solid var(--border);
  cursor:pointer;
  color:var(--muted-2);
  background:#fff;
  transition:.15s ease;
}
.tab.active{
  background:linear-gradient(90deg,rgba(14,165,233,.08),rgba(34,211,238,.08));
  color:#0b3a53;
  border-color:rgba(14,165,233,.4);
  box-shadow:0 1px 0 rgba(14,165,233,.25);
}

/* === TABLES === */
table{
  width:100%;
  border-collapse:collapse;
  table-layout:fixed;
}
thead th{
  position:sticky;
  top:0;
  background:#f9fafb;
  border-bottom:1px solid var(--border);
  text-align:left;
  padding:10px;
  font-size:12px;
  color:#374151;
  z-index:1;
}
tbody td{
  padding:8px 10px;
  border-bottom:1px dashed #e5e7eb;
  vertical-align:top;
  font-size:12px;
}
tfoot td{
  padding:10px;
  border-top:1px solid var(--border);
  background:#fcfcfc;
  font-size:12px;
}
.right{text-align:right}
.center{text-align:center}
.small{font-size:12px;color:var(--muted)}
.pill{
  display:inline-block;
  padding:2px 6px;
  border-radius:999px;
  background:#eef6ff;
  border:1px solid #dbeafe;
  color:#1e3a8a;
  font-size:12px;
}
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.section-title{
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  font-weight:700;
  letter-spacing:.2px;
  background:#fff;
}

/* === KOLUM REKAP === */
/* Struktur: 1 No | 2 Desc | 3 Kat | 4 Sub | 5 Profit% | 6 Profit Rp | 7 VAT% | 8 VAT Rp | 9 Grand | 10 ⋯ */
#rekapTable thead th:nth-child(1){width:46px}
#rekapTable thead th:nth-child(3){width:70px}
#rekapTable thead th:nth-child(4){width:120px}
#rekapTable thead th:nth-child(5){width:80px}
#rekapTable thead th:nth-child(6){width:110px}
#rekapTable thead th:nth-child(7){width:70px}
#rekapTable thead th:nth-child(8){width:110px}
#rekapTable thead th:nth-child(9){width:140px}
#rekapTable thead th:nth-child(10){width:100px}

/* === KOLUM DETAIL === */
/* Struktur:
   1 No | 2 Kat | 3 Elem | 4 Item | 5 Spec |
   6 A | 7 B | 8 C | 9 Vol | 10 Unit |
   11 Unit Price | 12 Total (Rp) | 13 Total (USD) |
   14 Remarks | 15 ⋯
*/
#detailTable thead th:nth-child(1){width:46px}
#detailTable thead th:nth-child(2){width:64px}
#detailTable thead th:nth-child(3){width:170px}
#detailTable thead th:nth-child(4){width:170px}
#detailTable thead th:nth-child(5){width:260px}
#detailTable thead th:nth-child(6),
#detailTable thead th:nth-child(7),
#detailTable thead th:nth-child(8){width:60px}
#detailTable thead th:nth-child(9){width:80px}
#detailTable thead th:nth-child(10){width:70px}
#detailTable thead th:nth-child(11){width:110px}
#detailTable thead th:nth-child(12){width:130px}
#detailTable thead th:nth-child(13){width:110px}
#detailTable thead th:nth-child(15){width:110px}

/* === KOLUM MARKET === */
/* Struktur:
   1 No | 2 Vendor | 3 Item | 4 Spec |
   5 A | 6 B | 7 C | 8 Vol | 9 Unit |
   10 Unit Price | 11 Total | 12 Lampiran | 13 ⋯
*/
#marketTable thead th:nth-child(1){width:46px}
#marketTable thead th:nth-child(5),
#marketTable thead th:nth-child(6),
#marketTable thead th:nth-child(7){width:60px}
#marketTable thead th:nth-child(8){width:80px}
#marketTable thead th:nth-child(9){width:70px}
#marketTable thead th:nth-child(10){width:110px}
#marketTable thead th:nth-child(11){width:130px}
#marketTable thead th:nth-child(12){width:110px}
#marketTable thead th:nth-child(13){width:110px}

/* === ELLIPSIS TEKS PANJANG === */
#rekapTable td:nth-child(2),
#detailTable td:nth-child(3),
#detailTable td:nth-child(4),
#detailTable td:nth-child(5),
#detailTable td:nth-child(14),
#marketTable td:nth-child(3),
#marketTable td:nth-child(4){
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* Tampilan angka USD kecil bila dipakai di dalam sel */
.small-usd{
  font-size:10px;
  color:var(--muted);
  white-space:nowrap;
}

/* === ANIMASI HIGHLIGHT === */
tr.highlighted{animation:flashRow 2s ease}
@keyframes flashRow{
  0%{background:rgba(34,211,238,.25)}
  100%{background:transparent}
}

/* === MODAL === */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.35);
  display:none;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:50;
  animation:fadeIn .2s ease;
}
.modal>.box{
  background:#fff;
  border:1px solid var(--border);
  border-radius:12px;
  max-width:640px;
  width:100%;
  padding:20px;
  box-shadow:0 8px 24px rgba(0,0,0,.1);
}
@keyframes fadeIn{
  from{opacity:0;transform:scale(.98)}
  to{opacity:1;transform:scale(1)}
}
.modal .row{
  justify-content:flex-end;
  margin-top:10px;
}

/* === PRINT === */
@media print{
  body{background:#fff;color:#111}
  header .hdr-actions,
  .toolbar,
  .tabs,
  .btn{display:none!important}
  .container{max-width:100%;margin:0;padding:0}
  .card{border:none;box-shadow:none}
  thead th{
    position:static;
    background:#f2f4f8;
    color:#111;
    border-bottom:1px solid #ddd;
  }
  tbody td{border-bottom:1px solid #eee}
}
