:root {
    --primary: #1e293b;
    --primary-light: #334155;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.05);
    --radius: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }
.app-header {
    background: var(--primary); color: white; padding: 12px 24px;
    /* FIX (screenshot Firman, 25 Sep): di WebView Android dgn viewport-fit=cover,
       header nempel di y=0 termasuk kolong status bar (jam/sinyal/baterai) --
       tombol ID/⚙️/☰ ketiban ikon status bar & susah disentuh. env() jadi 0px
       otomatis kalau browser gak support/gak butuh (mis. preview desktop). */
    padding-top: calc(12px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 3px solid var(--accent); position: sticky; top: 0; z-index: 500;
}
.app-header h1 { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 8px; letter-spacing: -0.5px; }
.btn {
    padding: 8px 14px; border-radius: var(--radius); border: none; font-weight: 600;
    font-size: 0.8rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
    transition: 0.2s ease; white-space: nowrap;
}
.btn-header { background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.25); }
.btn-header:hover { background: rgba(255,255,255,0.25); }
.btn-accent { background: var(--accent); color: white; box-shadow: 0 2px 4px rgba(249,115,22,0.2); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-accent:disabled { background: #cbd5e1; color: #94a3b8; box-shadow: none; cursor: not-allowed; }
.btn-optimizing { position: relative; overflow: hidden; cursor: not-allowed; color: white !important; background: var(--primary) !important; box-shadow: none !important; }
.btn-optimizing::before { content: ''; position: absolute; inset: 0; width: var(--progress, 0%); background: var(--accent); transition: width 0.3s ease; z-index: 0; }
.btn-optimizing::after { content: ''; position: absolute; top: 0; left: -80px; width: 60px; height: 100%; background: linear-gradient(to right, transparent, rgba(255,255,255,0.22), transparent); animation: btn-shimmer 1.4s ease-in-out infinite; z-index: 1; }
.btn-optimizing span, .btn-optimizing .spinner { position: relative; z-index: 2; }
@keyframes btn-shimmer { to { left: 110%; } }
.btn-primary { background: #f1f5f9; color: var(--primary); border: 1px solid var(--border); }
.btn-primary:hover { background: #e2e8f0; }

/* TABS ADVANCE */
.advance-tabs-bar {
    display: flex;
    gap: 0;
    padding: 0;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
}
.advance-tab {
    flex: 1;
    padding: 9px 14px;
    border: none;
    background: transparent;
    color: #cbd5e1;   /* tab tidak aktif: kontras dinaikkan supaya tab Advanced tidak terlihat redup */
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    margin-top: 0;
    text-align: center;
}
.advance-tab:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}
.advance-tab.active {
    background: var(--bg);
    color: var(--primary);
    border-top: 2px solid var(--accent);
}
/* Titik oranye di tab Advanced untuk user yang belum pernah membukanya (dilepas oleh onboarding.js) */
.advance-tab.has-dot::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f97316;
    margin-left: 6px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}
@media (max-width: 900px) {
    .advance-tabs-bar { padding: 0; }
}
@media print {
    .advance-tabs-bar { display: none !important; }
}

.main-layout { display: flex; gap: 24px; padding: 24px; max-width: 1500px; margin: 0 auto; width: 100%; align-items: flex-start; }
.panel { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 24px; }
.left-panel { width: 460px; flex-shrink: 0; display: flex; flex-direction: column; gap: 24px; }
.right-panel { flex: 1; display: flex; flex-direction: column; gap: 24px; }
.section-title {
    font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.75px;
    color: var(--text-secondary); font-weight: 800; margin-bottom: 12px;
    display: flex; align-items: center; justify-content: space-between;
    border-left: 3px solid var(--accent); padding-left: 10px;
}
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 0.7rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.input-group input, .input-group select {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.9rem; background: #fff; outline: none; color: var(--text);
}
.input-group input:focus, .input-group select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249,115,22,0.1); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.85rem; }
#itemsTable { table-layout: fixed; }
#itemsTable td:first-child, #itemsTable th:first-child { width: 22px; padding: 4px 2px; }
#itemsTable td:nth-child(2), #itemsTable th:nth-child(2),
#itemsTable td:nth-child(3), #itemsTable th:nth-child(3) { width: 23%; }
#itemsTable td:nth-child(4), #itemsTable th:nth-child(4) { width: 88px; }
#itemsTable td:nth-child(5), #itemsTable th:nth-child(5) { width: 28px; text-align:center; }
#itemsTable td:last-child, #itemsTable th:last-child { width: 22px; }
#stockTable { table-layout: fixed; }
#stockTable td:first-child, #stockTable th:first-child { width: 26px; padding: 4px 2px; }
#stockTable td:nth-child(2), #stockTable th:nth-child(2),
#stockTable td:nth-child(3), #stockTable th:nth-child(3) { width: 23%; }
#stockTable td:nth-child(4), #stockTable th:nth-child(4) { width: 88px; }
#stockTable td:nth-child(5), #stockTable th:nth-child(5) { width: 28px; text-align:center; }
#stockTable td:last-child, #stockTable th:last-child { width: 22px; }
/* ── Tabel 1D: kolom panjang dilebarkan (no. urut tetap sama dgn 2D) ─────────────
   Struktur baris 1D: [no] [panjang (colspan 2)] [qty] [hapus (colspan 2)].
   Aturan nth-child di atas dibuat utk 2D (no, w, h, qty, grain, hapus), jadi di 1D
   lebar kolomnya salah sasaran (panjang cuma ~23%, qty ikut 23%). Override di sini. */
/* No. urut 1D disamakan dgn 2D. Di 2D kolom no "melar" ke ~35px (stok) / ~30px (potongan) di layar HP
   karena sisa lebar tabel dibagi ke semua kolom; di 1D kolom panjang auto jadi no tinggal 24/20px.
   Pakai persen (dari lebar tabel) supaya proporsinya ikut layar seperti 2D. !important utk
   menimpa style="width:..px" inline di <th> header. */
#stockTable.tbl-1d td:first-child, #stockTable.tbl-1d th:first-child { width: 9.6% !important; }
#itemsTable.tbl-1d td:first-child, #itemsTable.tbl-1d th:first-child { width: 8.2% !important; }
/* Stepper qty rata tengah di kolomnya (2D & 1D) supaya sejajar dgn judul "JML". */
#stockTable .qty-stepper, #itemsTable .qty-stepper { justify-content: center; }
#stockTable.tbl-1d td:nth-child(2), #stockTable.tbl-1d th:nth-child(2),
#itemsTable.tbl-1d td:nth-child(2), #itemsTable.tbl-1d th:nth-child(2) { width: auto; }
#stockTable.tbl-1d td:nth-child(3), #stockTable.tbl-1d th:nth-child(3),
#itemsTable.tbl-1d td:nth-child(3), #itemsTable.tbl-1d th:nth-child(3) { width: 92px; }
#stockTable.tbl-1d td:nth-child(4), #stockTable.tbl-1d th:nth-child(4),
#itemsTable.tbl-1d td:nth-child(4), #itemsTable.tbl-1d th:nth-child(4) { width: 32px; }
#stockTable.tbl-1d td:nth-child(2) input, #itemsTable.tbl-1d td:nth-child(2) input { font-size: 0.9rem; padding: 6px 4px; }
#stockTable.tbl-1d .qty-stepper input, #itemsTable.tbl-1d .qty-stepper input { width: 38px !important; }
.stock-drag-handle { cursor: grab; user-select: none; -webkit-user-select: none; background: #f1f5f9; border-radius: 6px; }
.stock-row-dragging { position: relative; z-index: 5; background: #fff7ed !important; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.stock-row-dragging .stock-drag-handle { cursor: grabbing; }
th { background: #f8fafc; padding: 10px 8px; text-align: center; font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); border-bottom: 2px solid var(--border); }
th:first-child { text-align: left; }
td { padding: 6px 4px; border-bottom: 1px solid var(--border); text-align: center; }
td input[type="number"], td input[type="text"] { width: 100%; padding: 5px 2px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.8rem; background: #fff; text-align: center; color: var(--text); }
.qty-stepper { display: flex; align-items: center; gap: 2px; }
.grain-col { display: none; }
.grain-active .grain-col { display: table-cell; }
th.grain-col { color: var(--text-secondary); }
/* ── Kolom Material (Standard 2D) — tampil hanya saat toggle Material ON ── */
.mat-col { display: none; }
.material-active .mat-col { display: table-cell; width: auto; }
#stockTable.tbl-1d .mat-col, #itemsTable.tbl-1d .mat-col { display: none !important; }
#stockTable.material-active td:nth-child(2), #stockTable.material-active th:nth-child(2),
#stockTable.material-active td:nth-child(3), #stockTable.material-active th:nth-child(3),
#itemsTable.material-active td:nth-child(2), #itemsTable.material-active th:nth-child(2),
#itemsTable.material-active td:nth-child(3), #itemsTable.material-active th:nth-child(3) { width: auto; }
#stockTable.material-active td:nth-child(4), #stockTable.material-active th:nth-child(4),
#itemsTable.material-active td:nth-child(4), #itemsTable.material-active th:nth-child(4) { width: 76px; }
/* Kolom Material dikunci lebar tetap (kecil) supaya sisa lebar tabel dipakai kolom Ukuran 1 & 2
   (table-layout: fixed membagi sisa lebar rata ke kolom width:auto) -> input ukuran lebih lega. */
#stockTable.material-active th.mat-col, #stockTable.material-active td.mat-col,
#itemsTable.material-active th.mat-col, #itemsTable.material-active td.mat-col { width: 92px; }
.material-active .qty-stepper { gap: 1px; }
.material-active .qty-stepper button { width: 20px; }
.material-active .qty-stepper input { width: 26px !important; }
/* Kolom Serat saat Material aktif: cukup lebar untuk tombol 28px agar tidak menabrak kolom Material */
#stockTable.material-active td:nth-child(5), #stockTable.material-active th:nth-child(5),
#itemsTable.material-active td:nth-child(5), #itemsTable.material-active th:nth-child(5) { width: 34px; padding-left: 1px; padding-right: 1px; }
.material-active .grain-col .grain-cycle-btn { width: 28px !important; height: 28px !important; }
.material-active .mat-arrow { width: 18px; }
.material-active .mat-wrap { gap: 1px; }
.material-active td.mat-col { padding-left: 2px; padding-right: 2px; overflow: hidden; }
input.mat-inp { font-size: 0.75rem !important; }
tr.ghost-row .mat-col { opacity: 0.5; }
tr.ghost-row:focus-within .mat-col { opacity: 1; }
.btn-grain-toggle { font-size: 0.72rem; padding: 3px 8px; border: 1px solid var(--border); border-radius: 12px; background: #f1f5f9; color: var(--text-secondary); cursor: pointer; margin-left: 8px; }
.btn-grain-toggle.active { background: var(--primary); color: white; border-color: var(--primary); }
.qty-stepper input { width: 32px !important; text-align: center; padding: 4px 1px !important; font-size:0.8rem; }
.qty-stepper button { width: 22px; height: 28px; border: 1px solid var(--border); border-radius: 4px; background: #f1f5f9; color: var(--text); font-size: 0.9rem; font-weight: 700; cursor: pointer; flex-shrink: 0; line-height: 1; }
.qty-stepper button:active { background: var(--primary); color: white; }
td input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(249,115,22,0.1); }
td input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.delete-icon { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 1.1rem; padding: 6px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.delete-icon:hover { color: #ef4444; background: #fee2e2; }

.preset-material { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.preset-btn { background: #fff; border: 1px solid var(--border); padding: 6px 12px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; cursor: pointer; color: var(--text-secondary); transition: 0.2s; }
.preset-btn:hover { background: #e2e8f0; border-color: var(--accent); color: var(--accent); }

.canvas-viewport { overflow-x: auto; overflow-y: visible; position: relative; }
.canvas-wrapper { width: 100%; padding: 8px 4px; box-sizing: border-box; }
#canvasContainer { display: flex; flex-direction: column; gap: 0; align-items: flex-start; }
#canvasContainer canvas { display: block; background: white; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }

.summary-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-card { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; flex: 1; min-width: 110px; text-align: center; }
.stat-card .number { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.stat-card .label { font-size: 0.65rem; text-transform: uppercase; font-weight: 700; color: var(--text-secondary); margin-top: 4px; letter-spacing: 0.5px; }
.unplaced-warning { background: #fff7ed; border: 1px solid #fed7aa; border-left: 4px solid var(--accent); padding: 10px 16px; border-radius: var(--radius); font-size: 0.85rem; font-weight: 600; color: #c2410c; }
.progress-bar { width: 100%; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.2s linear; }
.toggle-btn { background: #f1f5f9; border: 1px solid #cbd5e1; padding: 8px 16px; border-radius: 20px; cursor: pointer; font-size: 0.8rem; font-weight: 600; color: #475569; }
.toggle-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.floating-optimize { position: fixed; bottom: calc(20px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))); left: 50%; transform: translateX(-50%); z-index: 100; display: none; width: calc(100% - 32px); max-width: 400px; }
.btn-floating { width: 100%; padding: 14px; font-size: 1rem; font-weight: 700; border-radius: 30px; box-shadow: 0 8px 20px rgba(249,115,22,0.3); }

.rec-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; font-size: 1.2rem; padding: 0; border-radius: 8px;
    cursor: pointer; transition: 0.2s; background: #f8fafc; border: 1px solid #e2e8f0;
}
.rec-icon-btn.perfect { background: #dcfce7; border-color: #86efac; }
.rec-icon-btn.imperfect { background: #fef9c3; border-color: #fde047; }
.rec-icon-btn.active { outline: 2px solid #1e293b; outline-offset: 2px; }

.dimension-panel {
    background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--radius);
    padding: 10px 14px; font-size: 0.85rem; font-weight: 600;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.dimension-panel .dim-label { color: #166534; }
.dimension-panel .dim-value {
    background: #fff; border: 1px solid #86efac; border-radius: 6px;
    padding: 4px 10px; font-weight: 700; color: #0f172a;
}

@media (max-width: 900px) {
    .main-layout { flex-direction: column; padding: 12px; gap: 16px; }
    .left-panel { width: 100%; padding: 16px; }
    .right-panel { padding: 16px; }
    /* Standard & Advanced (HP): tabel / kartu material & potongan dilebarkan ke tepi layar
       (ruang utk kolom tambahan). Dibatasi ke dua panel itu saja. */
    #standardPanel.main-layout, #advancePanel.main-layout { padding: 6px; }
    #standardPanel .left-panel, #advancePanel .left-panel { padding: 10px; }
    #standardPanel #stockTable, #standardPanel #itemsTable { margin-left: -4px; margin-right: -4px; width: calc(100% + 8px); }
    #adv-matHeadWrap, #adv-matBody, #adv-potHeadWrap, #adv-potBody { margin-left: -4px; margin-right: -4px; }
    .canvas-viewport { flex: none; }
    /* FIX 26 Okt 2026: shorthand 'padding' di bawah ini dulu MENIMPA padding-top safe-area di atas,
       jadi di HP header tertutup status bar. Inset ditulis ulang di sini. */
    .app-header { padding: 10px 16px; padding-top: calc(10px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px))); }
    .app-header h1 { font-size: 1rem; }
    .btn { padding: 8px 12px; font-size: 0.75rem; }
    .floating-optimize { display: block; }
    /* Ruang di bawah halaman supaya konten paling bawah (mis. panah lipat Urutan Potong)
       bisa di-scroll ke atas tombol Optimalkan yang mengambang, dan tidak tertutup. */
    body { padding-bottom: calc(96px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))); }
    .desktop-optimize { display: none; }
}
@media (min-width: 901px) {
    .floating-optimize { display: none; }
    .desktop-optimize { display: block; }
}
@media print {
    body * { visibility: hidden; }
    .right-panel, .right-panel * { visibility: visible; }
    .right-panel { position: absolute; left: 0; top: 0; width: 100%; }
    .left-panel, .app-header, .floating-optimize { display: none; }
}
.spinner {
    display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.5);
    border-radius: 50%; border-top-color: white; animation: spin 0.8s linear infinite; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.small-note { font-size: 0.7rem; color: var(--text-secondary); margin-top: 4px; }
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes popupIn {
    from { opacity: 0; transform: scale(0.8) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.ga-status {
    background: #ede9fe; border: 1px solid #c4b5fd; border-radius: var(--radius);
    padding: 10px 16px; font-size: 0.8rem; font-weight: 600; color: #6b21a8;
    display: flex; align-items: center; gap: 8px; margin-top: 8px;
}

/* Advance Material Card Layout - Compact */
.adv-mat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid #94a3b8;
    border-radius: var(--radius);
    padding: 6px 8px;
    margin-bottom: 4px;
    box-shadow: var(--shadow);
}
/* Palette warna strip kiri per material */
.adv-mat-card[data-color="0"] { border-left-color: #3b82f6; }
.adv-mat-card[data-color="1"] { border-left-color: #10b981; }
.adv-mat-card[data-color="2"] { border-left-color: #f59e0b; }
.adv-mat-card[data-color="3"] { border-left-color: #8b5cf6; }
.adv-mat-card[data-color="4"] { border-left-color: #ef4444; }
.adv-mat-card[data-color="5"] { border-left-color: #06b6d4; }
.adv-mat-card[data-color="6"] { border-left-color: #ec4899; }
.adv-mat-card[data-color="7"] { border-left-color: #84cc16; }
.adv-mat-card-header {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
    padding-bottom: 3px;
    border-bottom: 1px dashed #e2e8f0;
    flex-wrap: wrap;
}
.adv-mat-card-name {
    flex: 1;
    min-width: 100px;
}
.adv-mat-card-name input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    background: #fff;
}
.adv-mat-card-name input:focus {
    border-color: var(--accent);
    outline: none;
}
.am-harga-inline {
    width: 90px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    background: #fff;
    text-align: right;
}
.am-harga-inline:focus {
    border-color: var(--accent);
    outline: none;
}
.adv-mat-card-num {
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.adv-mat-card-tipe {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    border: 1px solid var(--border);
    background: #f1f5f9;
    color: var(--text-secondary);
    cursor: pointer;
}
.adv-mat-card-del {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.adv-mat-card-del:hover {
    color: #ef4444;
    background: #fee2e2;
}
.adv-mat-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 4px 6px;
    align-items: end;
}
.adv-mat-field {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.adv-mat-field label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.adv-mat-field input {
    padding: 4px 4px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.78rem;
    text-align: center;
    color: var(--text);
    background: #fff;
    width: 100%;
    height: 32px;
}
.adv-mat-field input:focus {
    border-color: var(--accent);
    outline: none;
}
.adv-mat-field input:disabled {
    opacity: 0.35;
    background: #f8fafc;
}
.adv-mat-field .qty-stepper {
    justify-content: center;
    gap: 1px;
}
.adv-mat-field .qty-stepper button {
    width: 20px;
    height: 26px;
    font-size: 0.8rem;
}
.adv-mat-field .qty-stepper input {
    width: 32px !important;
    height: 26px;
    padding: 2px 1px;
}
/* end advance material card layout */
/* Per-material canvas selector tabs */
.adv-mat-tab {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border);
    background: #fff; cursor: pointer; font-size: 0.72rem; font-weight: 700;
    color: var(--text-secondary); transition: all 0.18s ease; white-space: nowrap;
}
.adv-mat-tab:hover { border-color: var(--accent); color: var(--accent); background: #fff7ed; }
.adv-mat-tab.active {
    background: var(--primary); color: #fff; border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(30,41,59,0.18);
}
.adv-mat-tab .adv-mat-tab-util {
    font-size: 0.62rem; padding: 1px 6px; border-radius: 8px;
    background: rgba(0,0,0,0.08); font-weight: 800;
}
.adv-mat-tab.active .adv-mat-tab-util { background: rgba(255,255,255,0.2); }
.adv-mat-tab .adv-mat-tab-warn { color: #f97316; }
.adv-mat-tab.active .adv-mat-tab-warn { color: #fbbf24; }
/* end per-material selector */
/* Advance Potongan Card Layout - Compact */
.adv-pot-card {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid #94a3b8;
    border-radius: var(--radius);
    padding: 6px 8px;
    margin-bottom: 4px;
    box-shadow: var(--shadow);
}
/* Warna strip pot-card mengikuti material */
.adv-pot-card[data-color="0"] { border-left-color: #3b82f6; }
.adv-pot-card[data-color="1"] { border-left-color: #10b981; }
.adv-pot-card[data-color="2"] { border-left-color: #f59e0b; }
.adv-pot-card[data-color="3"] { border-left-color: #8b5cf6; }
.adv-pot-card[data-color="4"] { border-left-color: #ef4444; }
.adv-pot-card[data-color="5"] { border-left-color: #06b6d4; }
.adv-pot-card[data-color="6"] { border-left-color: #ec4899; }
.adv-pot-card[data-color="7"] { border-left-color: #84cc16; }
.adv-pot-card-header {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
    padding-bottom: 3px;
    border-bottom: 1px dashed #e2e8f0;
}
.adv-pot-card-num {
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.adv-pot-card-mat {
    flex: 1;
}
.adv-pot-card-mat select {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    background: #fff;
    outline: none;
}
.adv-pot-card-mat select:focus {
    border-color: var(--accent);
}
.adv-pot-card-del {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.adv-pot-card-del:hover {
    color: #ef4444;
    background: #fee2e2;
}
.adv-pot-card-body {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr 1fr;
    gap: 4px 6px;
    align-items: end;
}
.adv-pot-field {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.adv-pot-field label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.adv-pot-field input {
    padding: 2px 3px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
    color: var(--text);
    background: #fff;
    width: 100%;
    height: 32px;
}
.adv-pot-field input:focus {
    border-color: var(--accent);
    outline: none;
}
.adv-pot-field input:disabled {
    opacity: 0.35;
    background: #f8fafc;
}
.adv-pot-field .qty-stepper {
    justify-content: center;
    gap: 1px;
}
.adv-pot-field .qty-stepper button {
    width: 20px;
    height: 30px;
    font-size: 0.78rem;
}
.adv-pot-field .qty-stepper input {
    width: 30px !important;
    height: 30px;
    padding: 1px;
    font-weight: 600;
}
/* end advance potongan card layout */
            
/* Advance Ukuran Row - Shared */
.adv-ukuran-list {
    margin-top: 3px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
/* Lebarkan daftar Stock Size & Cut Part (+ baris tombol Tambah/Tempel & garis pemisah) agar
   hampir selebar tabel Standard: "bleed" -14px menembus padding .adv-v2-body (10px) + sebagian
   padding kartu (8px), sisa ~4px dari tepi dalam kartu. Field lain (Harga/Kerf) tidak ikut. */
.am-ukuran-list, .am-pot-list,
.am-ukuran-list + div, .am-pot-list + div,
.am-ukuran-list + div + div {
    margin-left: -14px !important;
    margin-right: -14px !important;
}
.adv-ukuran-row {
    display: flex;
    gap: 5px;
    align-items: center;
    background: #f8fafc;
    border-radius: 6px;
    padding: 5px 6px;
    flex-wrap: nowrap;
}
.adv-ukuran-row .adv-u-num {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}
.adv-ukuran-row input {
    flex: 0 1 70px;
    min-width: 52px;
    max-width: 90px;
    padding: 4px 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    color: var(--text);
    background: #fff;
    height: 36px;
}
.adv-ukuran-row .qty-stepper {
    flex-shrink: 0;
    justify-content: center;
    gap: 2px;
}
.adv-ukuran-row .adv-grain-wrap,
.adv-ukuran-header .adv-grain-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 2px;
}
.adv-ukuran-row .adv-u-del {
    margin-left: auto;
    flex-shrink: 0;
}

/* Nama potongan opsional (Cut Part Advance): tombol di samping tombol hapus. Kosong = ikon tag;
   terisi = chip singkatan (maks 4 huruf, otomatis). Lebar 28px & margin-left -3px supaya muat
   di layar 360px bahkan dengan Grain ON (sisa ruang baris setelah pelebaran ~33px). */
.adv-ukuran-row .adv-u-namebtn,
.adv-ukuran-header .adv-u-namebtn {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    margin-left: -3px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    color: #cbd5e1;
    cursor: pointer;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
/* Grup aksi di ujung kanan baris: [nama][hapus] rapat, ditempel ke kanan (margin-left:auto). */
.adv-ukuran-row .adv-u-actions,
.adv-ukuran-header .adv-u-actions {
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0;
}
.adv-u-actions .adv-u-namebtn,
.adv-u-actions .adv-u-del { margin-left: 0 !important; }
.adv-u-namebtn { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.adv-u-namebtn.has-name { background: rgba(249,115,22,0.14); border-color: rgba(249,115,22,0.45); color: #c2410c; }
.adv-u-nameline {
    background: #f8fafc;
    border-radius: 6px;
    padding: 0 6px 5px 29px; /* 6 + nomor 18 + gap 5 => sejajar dgn kolom ukuran */
    margin-top: -2px;
}
.adv-u-namebox { position: relative; }
.adv-u-nameline input {
    width: 100%;
    box-sizing: border-box;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text);
    background: #fff;
}
.adv-u-nameline input:focus { border-color: var(--accent); outline: none; }
.adv-u-nameline input { padding-right: 32px; }
.adv-u-nameclr {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 24px; height: 24px; padding: 0;
    border: none; border-radius: 50%;
    background: #e2e8f0; color: #475569;
    font-size: 1rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.adv-u-namepop {
    position: fixed; z-index: 100000;
    max-width: min(260px, calc(100vw - 16px));
    background: #1e293b; color: #fff;
    border-radius: 10px; padding: 8px 10px;
    box-shadow: 0 6px 20px rgba(15,23,42,0.35);
    font-size: 0.85rem;
}
.adv-u-namepop-text { font-weight: 700; word-break: break-word; line-height: 1.3; }
.adv-u-namepop-acts { display: flex; gap: 6px; margin-top: 7px; }
.adv-u-namepop-acts button {
    flex: 1; padding: 5px 8px; border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.12);
    color: #fff; font-size: 0.75rem; font-weight: 700; cursor: pointer;
}
.adv-u-namepop-acts button.is-danger { color: #fca5a5; border-color: rgba(252,165,165,0.5); }


.adv-ukuran-header {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 2px 6px 0;
}
.adv-ukuran-header .adv-u-num {
    flex-shrink: 0;
    width: 18px;
}
.adv-col-label {
    flex: 0 1 70px;
    font-size: 0.6rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    min-width: 52px;
    max-width: 90px;
}
.adv-col-label.col-qty {
    flex-shrink: 0;
    min-width: 82px;
    max-width: 82px;
}

.adv-ukuran-row input:focus {
    border-color: var(--accent);
    outline: none;
}
.adv-ukuran-row input:disabled {
    opacity: 0.35;
    background: #f1f5f9;
}
.adv-ukuran-row .qty-stepper {
    justify-content: center;
    gap: 2px;
}
.adv-ukuran-row .qty-stepper button {
    width: 24px;
    height: 34px;
    font-size: 0.82rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #f1f5f9;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}
.adv-ukuran-row .qty-stepper input {
    width: 30px !important;
    /* FIX-qty-overflow: aturan '.adv-ukuran-row input' (flex 0 1 70px; min-width 52px) ikut
       kena ke input qty, jadi lebarnya melar jadi 52px (bukan 30px) -> stepper 104px (header
       kolom Qty 82px) & baris overflow ~17px di layar 360px saat Grain ON (tombol hapus
       keluar dari baris). Kunci ke 30px sesuai desain. */
    flex: 0 0 30px;
    min-width: 0;
    height: 34px;
    padding: 2px;
    font-size: 0.82rem;
    font-weight: 600;
}

.adv-u-del:hover {
    color: #ef4444;
    background: #fee2e2;
}

.adv-add-u-btn {
    margin-top: 3px;
    width: 100%;
    padding: 3px 6px;
    border: 1px dashed #cbd5e1;
    border-radius: 5px;
    background: transparent;
    color: #94a3b8;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    letter-spacing: 0.3px;
    line-height: 1.4;
}
.adv-add-u-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #fff7ed;
}
/* Advance button hover */
#adv-btnOptimize:hover {
    background: #3b82f6 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(96,165,250,0.4) !important;
}
#btnOptimizeFloatAdv:hover {
    background: #3b82f6 !important;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(96,165,250,0.4) !important;
}
/* end advance ukuran row shared */
/* adv table shared */
#adv-matTable, #adv-potTable { table-layout: fixed; }
#adv-matTable td select, #adv-potTable td select {
    width: 100%; padding: 5px 2px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 0.78rem; background: #fff; color: var(--text); outline: none;
}
#adv-matTable td select:focus, #adv-potTable td select:focus { border-color: var(--accent); }
.adv-tipe-sel { font-size: 0.78rem; }

/* ── Subrow harga + kerf per material ───────────────────────── */
.adv-mat-card-subrow {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 5px 8px 7px;
    border-bottom: 1px solid #f1f5f9;
}
.adv-mat-subfield {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.adv-mat-sublabel {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #94a3b8;
}
.adv-mat-subfield .am-harga-inline {
    width: 130px;
}
.adv-mat-subfield .am-kerf {
    width: 62px;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    background: #fff;
    text-align: center;
}
.adv-mat-subfield .am-kerf:focus {
    border-color: var(--accent);
    outline: none;
}
/* Hapus border-bottom di header karena subrow yang jadi pemisah */
.adv-mat-card-header {
    border-bottom: none !important;
    margin-bottom: 0 !important;
    padding-bottom: 4px !important;
}

/* ── Pengaturan Lanjutan (details/summary) ───────────────────── */
.adv-lanjutan-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
    margin-top: 4px;
}
.adv-lanjutan-summary {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 8px 12px;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}
.adv-lanjutan-summary::-webkit-details-marker { display: none; }
.adv-lanjutan-summary::after {
    content: '▾';
    margin-left: auto;
    font-size: 0.8rem;
    color: #94a3b8;
    transition: transform 0.2s;
}
.adv-lanjutan-wrap[open] .adv-lanjutan-summary::after {
    transform: rotate(180deg);
}
.adv-lanjutan-body {
    padding: 4px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--border);
}

/* ── Card material collapse/expand ──────────────────────────── */
.adv-mat-expand-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: 0.15s;
    padding: 0;
}
.adv-mat-expand-btn:hover {
    background: #f1f5f9;
    border-color: var(--accent);
    color: var(--accent);
}
.adv-mat-card-body-collapsible {
    margin-top: 2px;
}
/* Subrow compact - harga dan kerf sejajar tanpa label besar */
.adv-mat-card-subrow {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 4px 8px 6px;
}
.adv-mat-subfield .am-kerf {
    width: 58px !important;
}

/* ── Library Material buttons ────────────────────────────── */
.adv-lib-pick-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.8rem;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: 0.15s;
}
.adv-lib-pick-btn:hover {
    background: #fffbeb;
    border-color: #fbbf24;
}
.adv-lib-save-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.8rem;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: 0.15s;
}
.adv-lib-save-btn:hover {
    background: #f0fdf4;
    border-color: #86efac;
}
/* Dropdown library */
.adv-lib-dropdown {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.adv-lib-dropdown > div:last-child {
    border-bottom: none !important;
}
.adv-lib-dropdown > div:hover {
    background: #f8fafc;
}


/* ==================== FIX: Input number - sembunyikan spinner & cegah scroll mengubah nilai ==================== */
/* Sembunyikan tombol panah atas/bawah di semua input number */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}
/* Khusus qty-stepper: tetap tampilkan tombol +/- manual, jangan blur saat klik stepper */
.qty-stepper input[type=number] {
    -moz-appearance: textfield;
}

/* ==================== ZOOM TOGGLE BUTTON (Competitor Style) ==================== */
.zoom-toggle-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Inter', system-ui, sans-serif;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    white-space: nowrap;
    letter-spacing: 0.3px;
}
.zoom-toggle-btn:hover {
    background: #2a2a4e;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    transform: translateX(-50%) translateY(-1px);
}
.zoom-toggle-btn:active {
    transform: translateX(-50%) translateY(0);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.zoom-toggle-btn svg {
    flex-shrink: 0;
    opacity: 0.9;
}

/* Hide old zoom controls if they exist */
#zoomLabel, .zoom-label { display: none !important; }

/* ── Grouping toggle button ─────────────────────────────────── */
#btnGroupSameSize.active,
#adv-btnGroupSameSize.active {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}

/* ── Library Material: form field fokus & error (konsisten, gak bergantung ke
   default browser focus-ring yang kadang tebal/hitam di sebagian device) ── */
.glib-field {
    font-weight: 600;
    color: #1e293b;
}
.glib-field:focus {
    outline: none;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.glib-field.glib-field-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
}


/* ── Serat + Kerf satu baris ─────────────────────────────────── */
.opt-row { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; }
/* FIX overflow: <input type=number> punya lebar bawaan (~150px) yang menolak mengecil di flex,
   sehingga kolom Kerf + "mm" keluar layar. min-width:0 membolehkan input menyusut. */
.opt-row .input-group { min-width: 0; }
.opt-row .input-group > div { min-width: 0; }
.opt-row .input-group input { min-width: 0; width: 100%; }
.opt-row #kerfUnitLabel { flex-shrink: 0; }
.opt-row .input-group label { font-size: 0.64rem; letter-spacing: 0.3px; }
.opt-row .btn-grain-toggle { font-size: 0.8rem !important; white-space: normal; }
/* ── Tombol Garis Potong di toolbar hasil ────────────────────── */
#toggleCutLines.active, #adv-toggleCutLines.active { background: var(--primary); color: #fff; }
#toggleCutLines:not(.active), #adv-toggleCutLines:not(.active) { opacity: 0.5; }

/* ── Form Standard lebih ringkas ─────────────────────────────── */
/* Jarak antar bagian: gap bawaan .left-panel 24px -> 16px untuk bagian pengaturan
   (Mode, Prioritas); pemisah antar seksi besar (Stok / Potongan / Serat+Kerf) tetap. */
.left-panel > .tight { margin-top: -8px; }
/* Dropdown Mode & Prioritas sedikit lebih kecil supaya teks panjang tidak mendesak panah */
#algoSelect, #stockPriorityMode, #adv-algoSelect, #adv-stockPriorityMode { font-size: 0.8rem; padding-top: 9px; padding-bottom: 9px; }

/* Keterangan di bawah dropdown Urutan Pakai Stok (Standard). Murni CSS: ikut berubah
   saat value diubah lewat kode (restore project) tanpa perlu event. */
.sp-hint { display: none; font-size: 0.72rem; line-height: 1.35; color: var(--text-secondary); font-style: italic; }
#stockPriorityMode:has(option[value="sequential"]:checked) ~ .sp-hint[data-for="sequential"],
#stockPriorityMode:has(option[value="one_per_stock"]:checked) ~ .sp-hint[data-for="one_per_stock"],
#stockPriorityMode:has(option[value="best_fit"]:checked) ~ .sp-hint[data-for="best_fit"] { display: block; }

/* ── Baris kosong otomatis (gaya Cutlist) ────────────────────── */
tr.ghost-row input, tr.ghost-row .qty-stepper, tr.ghost-row .grain-col { opacity: 0.5; }
tr.ghost-row:focus-within input, tr.ghost-row:focus-within .qty-stepper, tr.ghost-row:focus-within .grain-col { opacity: 1; }
tr.ghost-row .delete-icon { display: none; }   /* bukan visibility:hidden: itu tetap memakan tinggi baris */
tr.ghost-row > .ghost-num { pointer-events: none; font-size: 0 !important; }
tr.ghost-row > .ghost-num::before { content: '+'; font-size: 1.1rem; color: #94a3b8; font-weight: 700; }

/* ── Baris kosong TIPIS (membesar ke bawah saat disentuh) ───────────────
   Hanya padding yang dikurangi; tepi atas kotak tidak bergeser, jadi titik sentuh
   tetap berada di dalam kotak saat baris membesar. Stepper tetap bisa difokuskan (Enter). */
tr.ghost-row > td { padding-top: 2px; padding-bottom: 0; }
tr.ghost-row td input[type="text"], tr.ghost-row td input[type="number"] { height: 16px; padding-top: 0; padding-bottom: 0; font-size: 0.7rem; line-height: 1; }
tr.ghost-row .qty-stepper input { height: 16px; padding: 0 1px !important; font-size: 0.7rem; }
tr.ghost-row .qty-stepper button { height: 16px; font-size: 0.75rem; }
tr.ghost-row .grain-cycle-btn { height: 16px !important; width: 24px !important; font-size: 0.7rem !important; overflow: hidden; }   /* inline style 30px -> butuh !important */
tr.ghost-row > .ghost-num::before { font-size: 0.9rem; line-height: 1; }
tr.ghost-row:focus-within > td { padding-top: 6px; padding-bottom: 6px; }
tr.ghost-row:focus-within td input[type="text"], tr.ghost-row:focus-within td input[type="number"] { height: auto; padding-top: 5px; padding-bottom: 5px; font-size: 0.8rem; }
tr.ghost-row:focus-within .qty-stepper input { height: auto; padding: 4px 1px !important; font-size: 0.8rem; }
tr.ghost-row:focus-within .qty-stepper button { height: 28px; font-size: 0.9rem; }
tr.ghost-row:focus-within .grain-cycle-btn { height: 30px !important; width: 30px !important; font-size: 1rem !important; }

/* Kolom Material: input + panah dropdown */
.mat-wrap { display: flex; align-items: center; gap: 2px; }
.mat-wrap .mat-inp { flex: 1; min-width: 0; }
.mat-arrow { width: 20px; height: 28px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 4px; background: #f1f5f9; color: var(--text-secondary); font-size: 0.8rem; line-height: 1; padding: 0; cursor: pointer; }
input.mat-pick { cursor: pointer; }
tr.ghost-row .mat-arrow { height: 16px; font-size: 0.65rem; }
tr.ghost-row:focus-within .mat-arrow { height: 28px; font-size: 0.8rem; }

/* Label yang bisa ditekan untuk penjelasan (pengganti tombol "i" bulat): area tap lebih lebar, ikon ⓘ kecil sebagai petunjuk */
.help-label { cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; padding: 4px 2px; }
.help-label .help-i { display: inline-block; vertical-align: middle; margin-left: 3px; opacity: 0.6; flex-shrink: 0; }
.help-label:active { opacity: 0.6; }

/* Pengaturan (Standard) -- bisa dilipat, panah bawah di kanan */
.std-settings-wrap { margin-top: 6px; }
.std-settings-summary {
    font-size: 0.8rem; font-weight: 800; color: var(--text-secondary);
    padding: 8px 4px; cursor: pointer; list-style: none;
    display: flex; align-items: center; gap: 6px; user-select: none;
    text-transform: uppercase; letter-spacing: .03em;
}
.std-settings-summary::-webkit-details-marker { display: none; }
.std-settings-summary::after {
    content: ''; margin-left: auto; width: 8px; height: 8px;
    border-right: 2.5px solid #64748b; border-bottom: 2.5px solid #64748b;
    transform: rotate(45deg) translateY(-2px); transition: transform .2s;
}
.std-settings-wrap:not([open]) .std-settings-summary::after { transform: rotate(-45deg); }
/* Isi dibungkus <details>, jadi bukan lagi anak langsung .left-panel: tiru flex-column + gap 24px-nya
   supaya jarak antar bagian sama persis seperti sebelumnya (tanpa ini elemen saling menimpa). */
.std-settings-body { display: flex; flex-direction: column; gap: 24px; padding-top: 0; }
.std-settings-body > .tight { margin-top: -8px; }
