/* ============================================
   Quotation Generator - Style Override
   Accent: Microsoft Word Blue (#2B579A)
   ============================================ */

:root {
    --md-primary: #2B579A;
    --md-primary-light: #4a74b8;
    --md-primary-container: #dce6f4;
    --md-on-primary: #ffffff;
    --md-on-primary-container: #1a3a6b;
    --bg: #f3f6fb;
    --md-secondary: #2B579A;
}


body { background-color: var(--bg); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Hard guard: the page itself must never be wider than the viewport.
   (The product table still scrolls sideways inside its own .table-wrap card.) */
html, body { max-width: 100%; overflow-x: hidden; }

.top-bar { background: var(--surface); border-bottom: 1px solid var(--line); }
.footer { background: var(--surface); border-top: 1px solid var(--line); }
.form-field__input,
.item-harga, .item-satuan, .item-qty, .item-keterangan { background: var(--surface-soft); }
.form-field__input:focus,
.item-name-input:focus, .item-harga:focus, .item-satuan:focus,
.item-keterangan:focus, .item-qty:focus, .item-kota:focus,
.item-indopaket:focus, .item-indojaya:focus,
.item-sub-name-input:focus, .item-sub-qty:focus, .item-sub-satuan:focus { background: var(--surface-soft); box-shadow: 0 0 0 4px rgba(26,115,232,0.12); }
.top-bar__icon { font-size: 22px; color: var(--md-primary); margin-right: 4px; }
.top-bar__title { font-size: 1.25rem; font-weight: 800; }
/* REVERTABLE: hapus garis glass bawah top-bar (design-system:78) */
.top-bar { box-shadow: none; }
/* Toast variants yang tidak ada di design-system (warning/info). */
.toast--warning { background: #b26a00; color: #fff; border: none; }
.toast--info { background: #1a73e8; color: #fff; border: none; }
.main-content { animation: none; }
.card-pair { position: relative; z-index: 2; }
#cardItems { position: relative; z-index: 1; }
.card-pair--note-acuan { position: relative; z-index: 0; }

/* --- Dropdown (topbar Database) --- */
.dropdown { position: relative; }
.dropdown__menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    min-width: 220px;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: all 0.18s var(--md-motion-standard);
    padding: 6px;
}
.dropdown__menu.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.dropdown__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--ink);
    font-family: var(--md-font-family);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    border-radius: 12px;
    transition: background 0.1s;
}
.dropdown__item:hover { background: var(--surface-soft); }
.dropdown__item i { font-size: 0.95rem; color: var(--muted); width: 20px; text-align: center; }

/* --- Form Container --- */
.form-container {
    max-width: 920px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--md-shape-lg, 16px);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(43,87,154,0.06);
}

/* DESKTOP ONLY: every form card stretches edge-to-edge (5px gutter), both templates.
   Uses 100% (not 100vw) so it never exceeds the viewport / causes horizontal scroll. */
@media (min-width: 641px) {
    body { padding: 5px; }
    .form-container {
        max-width: none;
        width: 100%;
        margin: 0;
        padding: 5px;
    }
    .card { border-radius: var(--md-shape-lg, 16px); }
    /* Info Surat + Info Customer side-by-side, width adjusted (Surat narrower) */
    .card-pair { display: flex; gap: 14px; align-items: stretch; }
    #cardInfoSurat { flex: 0 0 46%; min-width: 0; }
    #cardInfoCustomer { flex: 1 1 54%; min-width: 0; }
    /* Harga + Note side-by-side (karpet only): Note kiri 40%, Harga kanan 60%, sejajar atas.
       DOM order = Harga lalu Note, jadi row-reverse biar Note di kiri. */
    .card-pair--note-acuan { align-items: flex-start; flex-direction: row-reverse; }
    .card-pair--note-acuan #cardNote { flex: 1 1 auto; }
    .card-pair--note-acuan:has(#acuanCard:not([style*="none"])) #cardNote { flex: 0 0 40%; }
    .card-pair--note-acuan #acuanCard { flex: 1 1 60%; }
    /* Info Surat: 2 equal columns (Company|No / Template|Tanggal) */
    #cardInfoSurat .card__grid { grid-template-columns: repeat(2, 1fr); }
    #cardInfoSurat .card__grid > * { max-width: none; }
    /* Info Customer: 3 columns (Nama | UP | Alamat1 / Email | Phone | Alamat2) */
    #cardInfoCustomer .card__grid { grid-template-columns: repeat(3, 1fr); }
    /* Suggestion card 2x lebih lebar dari textbox (textbox = 1/3 card -> card = 2/3). */
    #cardInfoCustomer .autocomplete-list {
        left: 0;
        right: auto;
        width: 200%;
    }
}
.card__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--md-primary);
    margin: 0 0 16px;
}
.card__title i { font-size: 1rem; }
.card__header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}
.card__header-row .card__title { margin: 0; }
.card__header-row--preview { justify-content: center; }
.header-actions { position: relative; min-width: 160px; min-height: 30px; }
.header-actions .tonal-button { position: absolute; top: 50%; right: 0; transform: translateY(-50%); }

/* Note card: switch + inline label, not wrapped in label click */
#cardNote .header-actions { display: flex; align-items: center; gap: 8px; min-width: auto; min-height: auto; }

/* Switch toggle for Tanda Tangan (FlyonUI-style) */
.switch-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    padding: 4px;
}
.switch-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background: #d1d5db;
    border-radius: 999px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}
.switch__icon {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 1;
    pointer-events: none;
}
.switch__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    z-index: 2;
}
.switch-input:checked + .switch {
    background: var(--md-primary, #2B579A);
}
.switch-input:checked + .switch .switch__thumb {
    transform: translateX(20px);
}
.switch-input:checked + .switch .switch__icon {
    opacity: 1;
}
.switch__label {
    font-size: 0.82rem;
    color: #334155;
    font-weight: 500;
    white-space: nowrap;
}


/* Action buttons horizontal (edit left, delete right) */
.data-table__actions { display: flex; align-items: center; justify-content: flex-start; gap: 6px; }

/* Compact search input for database toolbars (matches button size) */
.db-search {
    height: 42px;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    font-family: var(--md-font-family);
    font-size: 0.9rem;
    color: var(--ink);
    outline: none;
    min-width: 200px;
    transition: border-color var(--md-motion-duration-short) var(--md-motion-standard);
}
.db-search::placeholder { color: var(--muted); }
.db-search:focus { border-color: var(--md-primary); }

/* DB dialogs: tools moved into the header, aligned with title + exit */
.dialog__header--tools { flex-wrap: wrap; gap: 12px 16px; }
.dialog__header--tools .dialog__header-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}
.dialog__header--tools .window-dots { margin-left: auto; }

/* Draft dialog top bar: Export (left of search) | Search (centered, +50% wider) | Delete (right
   of search), grouped and centered; scoped to drafts so Customer/Barang keep their own layout. */
#dialogDatabaseDrafts .dialog__header-tools { justify-content: flex-start; gap: 10px; }
#dialogDatabaseDrafts #searchDrafts { flex: 0 1 420px; width: auto; max-width: 480px; min-width: 0; }
#dialogDatabaseDrafts .dialog__header-tools #btnExportSelectedDraftsPdf,
#dialogDatabaseDrafts .dialog__header-tools #btnDeleteSelectedDrafts { flex: 0 0 auto; }

.card__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.form-field--full { grid-column: 1 / -1; }

/* --- Customer search + autocomplete --- */
.customer-search { position: relative; margin-bottom: 12px; }
.card__grid .customer-search { margin-bottom: 0; }
.customer-search__row { display: flex; gap: 8px; align-items: stretch; }
.customer-search__row .form-field__input { flex: 1; }
.customer-field { min-width: 0; }
.autocomplete-list {
    list-style: none; margin: 4px 0 0; padding: 4px;
    position: absolute; left: 0; right: 0; top: 100%; z-index: 999;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 10px; box-shadow: 0 6px 20px rgba(43,87,154,0.14);
    max-height: 240px; overflow-y: auto; 
    scrollbar-width: none; -ms-overflow-style: none;
    -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
    
    /* Transition for appearance */
    display: block;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.autocomplete-list.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.autocomplete-list::-webkit-scrollbar { display: none; }
.autocomplete-item {
    padding: 9px 12px; border-radius: 7px; cursor: pointer;
    font-size: 0.88rem; color: var(--ink);
}
.autocomplete-item:hover, .autocomplete-item.is-active { background: var(--md-primary-container); color: var(--md-primary); }
.autocomplete-empty { padding: 9px 12px; font-size: 0.85rem; color: var(--muted); }

/* --- Custom Select (replaces native <select>) --- */
.custom-select { position: relative; }
.custom-select__trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    width: 100%; cursor: pointer;
    min-height: 0; padding: 6px 10px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--surface-soft);
    font-family: var(--md-font-family); font-size: 0.82rem; color: var(--ink);
    outline: none; transition: all var(--md-motion-duration-short) var(--md-motion-standard);
    box-sizing: border-box;
}
.custom-select__trigger:focus,
.custom-select.is-open .custom-select__trigger { border-color: var(--md-primary); box-shadow: 0 0 0 3px rgba(43,87,154,0.12); }
.custom-select__arrow { font-size: 0.65rem; color: var(--muted); transition: transform .2s ease; flex-shrink: 0; }
.custom-select.is-open .custom-select__arrow { transform: rotate(180deg); }
.custom-select__dropdown {
    list-style: none; margin: 4px 0 0; padding: 4px;
    position: absolute; left: 0; right: 0; top: 100%; z-index: 999;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 10px; box-shadow: 0 6px 20px rgba(43,87,154,0.14);
    max-height: 240px; overflow-y: auto;
    display: block;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    scrollbar-width: none;
}
.custom-select__dropdown.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.custom-select__dropdown.open-up {
    margin: 0 0 4px;
    transform: translateY(6px);
}
.custom-select__dropdown.open-up.open {
    transform: translateY(0);
}
.custom-select__dropdown::-webkit-scrollbar { display: none; }
.custom-select__option {
    padding: 9px 12px; border-radius: 7px; cursor: pointer;
    font-size: 0.88rem; color: var(--ink); position: relative;
}
.custom-select__option:hover { background: var(--md-primary-container); }
.custom-select__option.is-active { color: var(--md-primary); font-weight: 600; }
html[data-theme="dark"] .custom-select__dropdown { background: #1e1e1e; border-color: #333; }
html[data-theme="dark"] .custom-select__option:hover { background: var(--md-primary-container); }
html[data-theme="dark"] .custom-select__option.is-active { color: #8ab4f8; }
html[data-theme="dark"] .custom-select__trigger { background: #1e1e1e; border-color: #333; color: #e0e0e0; }
html[data-theme="dark"] .card__title { color: #8ab4f8; }
html[data-theme="dark"] .custom-select__trigger { background: #1e1e1e; border-color: #333; color: #e0e0e0; }

/* --- Form fields (override focus color) --- */
.form-field__input:focus { border-color: var(--md-primary); box-shadow: 0 0 0 3px rgba(43,87,154,0.12); }

/* Compact, precise inputs in the quotation form cards (remove default 24px inset)
   Scoped to .card so the dialog form fields keep their padding. */
.card .form-field { padding: 0; }
.form-field__input { width: 100%; max-width: 100%; box-shadow: none; } /* REVERTABLE: hapus glow glass (design-system:227) */
/* Match the compact textbox size used in Detil Barang */
.card .form-field__input {
    min-height: 0;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
}
.form-field__label { margin-bottom: 2px; }
.note-field { margin-top: 14px; }
.note-textarea { min-height: 0; padding: 8px 10px; border-radius: 8px; font-size: 0.82rem; font-family: var(--md-font-family); resize: vertical; }
/* Live bullet editor (contenteditable): each paragraph gets a real bullet */
.note-editor { min-height: 96px; line-height: 1.55; outline: none; cursor: text; white-space: pre-wrap; word-break: break-word; }
.note-editor:empty::before {
    content: attr(data-placeholder);
    color: #9aa0a6;
}
.note-editor > div, .note-editor > p,
.note-editor > font, .note-editor > span, .note-editor > b, .note-editor > i {
    position: relative; padding-left: 16px; margin: 0; display: block;
}
.note-editor > div::before, .note-editor > p::before,
.note-editor > font::before, .note-editor > span::before, .note-editor > b::before, .note-editor > i::before {
    content: "\2022";
    position: absolute; left: 2px; top: 0;
    color: var(--md-primary); font-weight: 700;
}
.dialog__body { padding: 20px; }

/* Note options: checkbox (on/off) reveals a sliding Include/Exclude toggle */
.note-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 6px 0 12px;
}
.note-option { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Custom checkbox */
.note-check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.note-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.note-check__box {
    width: 18px; height: 18px; border-radius: 6px;
    border: 1.5px solid var(--md-outline, #dadce0); background: var(--surface);
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.62rem; transition: all var(--md-motion-duration-short) var(--md-motion-standard);
}
.note-check__box i { opacity: 0; transform: scale(0.5); transition: all var(--md-motion-duration-short) var(--md-motion-standard); }
.note-check input:checked + .note-check__box {
    background: var(--md-primary); border-color: var(--md-primary);
    box-shadow: 0 1px 4px rgba(43,87,154,0.35);
}
.note-check input:checked + .note-check__box i { opacity: 1; transform: scale(1); }
.note-check__label {
    font-size: 0.82rem; font-weight: 700; color: var(--ink); letter-spacing: 0.2px;
}

/* Sliding Include/Exclude toggle (single accent color, smooth motion) */
.note-toggle {
    display: inline-flex; position: relative;
    background: var(--surface-soft); border: 0; border-radius: 999px; padding: 0; overflow: hidden;
    opacity: 0; transform: translateX(-6px); max-width: 0; pointer-events: none;
    transition: opacity 0.22s var(--md-motion-standard), transform 0.22s var(--md-motion-standard), max-width 0.28s var(--md-motion-standard);
}
.note-toggle.is-visible { opacity: 1; transform: translateX(0); max-width: 220px; pointer-events: auto; padding: 3px; border: 1px solid var(--line); }
.note-toggle__opt {
    position: relative; z-index: 1; border: none; background: transparent; cursor: pointer;
    font-family: var(--md-font-family); font-size: 0.72rem; font-weight: 700;
    color: var(--muted); padding: 4px 14px; border-radius: 999px; line-height: 1.2;
    transition: color 0.22s var(--md-motion-standard);
}
.note-toggle__opt.is-active { color: #fff; }
.note-toggle__slider {
    position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
    background: var(--md-primary); border-radius: 999px; z-index: 0;
    box-shadow: 0 1px 4px rgba(43,87,154,0.35);
    transition: transform 0.26s cubic-bezier(0.2,0,0,1);
}
.note-toggle[data-state="exclude"] .note-toggle__slider { transform: translateX(100%); }
/* Note editor + toggle locked until a Detil Produk row exists (mirrors customer guard) */
.note-editor.is-locked { background: var(--surface-soft); cursor: not-allowed; opacity: 0.6; }
.note-toggle.is-locked { cursor: not-allowed; }
/* Hierarki lock: Detil Produk + Harga + Note ikut state yang sama.
   Frame glow ditaruh di OUTLINE card form (bukan di tabel). */
#cardItems,
#acuanCard,
#cardNote { transition: opacity .15s ease, box-shadow .2s ease; }
#cardItems.is-locked,
#acuanCard.is-locked,
#cardNote.is-locked { pointer-events: none; opacity: 0.5; }
/* Exception: input Nama Barang + design blueprint karpet tetap aktif walau card locked */
#cardItems.is-locked .item-name-input,
#cardItems.is-locked [data-design-toggle],
#cardItems.is-locked [data-upload-blueprint],
#cardItems.is-locked .ket-thumb { pointer-events: auto; opacity: 1; }
/* Glow HANYA saat motion nyala (begitu unlock), habis animasi langsung hilang */

/* Truncate overly long text in database tables ("fog" effect) */
.cell-clip { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Proper width for the Add/Edit Customer dialog (its --small modifier wasn't matched) */
#dialogAddCustomer .dialog__container { width: min(92vw, 560px); }
#dialogAddCustomer .dialog__body { display: flex; flex-direction: column; gap: 14px; }

/* --- Item image source: Upload button + Galeri --- */
#dialogAddItem .dialog__container { width: min(94vw, 560px); }
.img-gallery-section { margin-top: 14px; }
.img-gallery__thumb {
    width: 100%; height: 72px; max-width: 100%; object-fit: contain;
    border-radius: 4px; background: #f7f9fc;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 1.4rem;
}
.img-gallery-searchbox {
    display: flex; align-items: center; gap: 8px;
    width: 100%; height: 34px; padding: 0 5px 0 14px; box-sizing: border-box;
    border: 1px solid var(--line); border-radius: 8px; background: #fff; outline: none;
}
.img-gallery-searchbox:focus-within { border-color: var(--md-primary); box-shadow: 0 0 0 3px rgba(43,87,154,0.12); }
.img-gallery-searchbox .img-gallery-search {
    flex: 1; min-width: 0; width: auto; height: 100%; padding: 0;
    border: none; border-radius: 0; background: transparent; outline: none;
    font-family: var(--md-font-family); font-size: 0.82rem; color: var(--ink);
}
.img-gallery-searchbox .img-gallery-search:focus { border: none; }
/* Disable table row hover indicator in light mode */
.data-table__body tr:hover td { background-color: transparent; }
/* Light mode table header glass */
.data-table__th {
    background: var(--surface-soft);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom-color: rgba(255,255,255,0.3);
}
.img-upload-pill {
    flex: none; display: inline-flex; align-items: center; gap: 6px;
    height: 26px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    font-family: var(--md-font-family); font-size: 0.78rem; font-weight: 600; cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    transition: background 0.25s var(--md-motion-standard), color 0.25s var(--md-motion-standard),
                border-color 0.25s var(--md-motion-standard), box-shadow 0.25s var(--md-motion-standard);
}
.img-upload-pill:hover { border-color: var(--md-primary); color: var(--md-primary); }
.img-upload-pill__icon { width: 13px; height: 13px; display: inline-flex; }
.img-upload-pill__check { width: 16px; height: 16px; display: none; }
.img-upload-pill__check .c { fill: none; stroke: currentColor; stroke-width: 2; stroke-dasharray: 63; stroke-dashoffset: 63; }
.img-upload-pill__check .t { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 20; stroke-dashoffset: 20; }
.img-upload-pill.is-uploaded {
    background: var(--md-primary); border-color: var(--md-primary); color: #fff;
    box-shadow: 0 1px 4px rgba(43,87,154,0.45);
}
.img-upload-pill.is-uploaded:hover { color: #fff; }
.img-upload-pill.is-uploaded .img-upload-pill__icon { display: none; }
.img-upload-pill.is-uploaded .img-upload-pill__check { display: inline-flex; }
.img-upload-pill.is-uploaded .img-upload-pill__check .c { animation: pillDraw 0.4s ease forwards; }
.img-upload-pill.is-uploaded .img-upload-pill__check .t { animation: pillDraw 0.45s 0.12s ease forwards; }
@keyframes pillDraw { to { stroke-dashoffset: 0; } }
.img-gallery {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    max-height: 220px; overflow-y: auto; overflow-x: hidden; margin-top: 8px; padding: 4px;
}
.img-gallery__item {
    display: flex; flex-direction: column; align-items: stretch; gap: 5px; padding: 6px; border-radius: 8px;
    border: 1px solid var(--line); background: #fff; cursor: pointer; text-align: center;
    min-width: 0;
    transition: border-color 0.15s var(--md-motion-standard), box-shadow 0.15s var(--md-motion-standard), background 0.15s var(--md-motion-standard), transform 0.1s var(--md-motion-standard);
}
.img-gallery__item:hover { border-color: var(--md-primary); background: var(--surface-soft); }
.img-gallery__item:active { transform: scale(0.97); }
.img-gallery__item img {
    width: 100%; height: 72px; max-width: 100%; object-fit: contain;
    border-radius: 4px; background: #f7f9fc;
}
.img-gallery__item.is-selected { border-color: var(--md-primary); box-shadow: 0 0 0 3px rgba(43,87,154,0.15); background: var(--md-primary-container); }
.img-gallery__caption {
    font-size: 0.68rem; color: var(--ink); line-height: 1.25;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; text-overflow: ellipsis;
}
/* Paste-from-clipboard: pending new image tile */
.img-gallery__item--pending {
    position: relative;
    border: 2px dashed var(--md-primary);
    background: var(--md-primary-container);
    cursor: default;
}
.img-gallery__item--pending:hover { background: var(--md-primary-container); }
.img-gallery__remove {
    position: absolute; top: 4px; right: 4px;
    width: 22px; height: 22px; border-radius: 50%;
    border: 0; background: rgba(0,0,0,0.68); color: #fff;
    font-size: 15px; line-height: 1; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
}
.img-gallery__remove:hover { background: rgba(0,0,0,0.85); }
.img-paste-hint {
    flex: none; font-size: 0.7rem; color: var(--muted); white-space: nowrap;
}
@media (hover: none), (pointer: coarse) {
    .img-paste-hint { display: none; }
}
.img-gallery-empty { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 12px 0; }

/* Livelier press feedback for the item dialog buttons (no stiff flip) */
#dialogAddItem .img-upload-btn:active { transform: scale(0.97); }
#dialogAddItem .filled-button:active,
#dialogAddItem .tonal-button:active { transform: scale(0.97); }

/* --- Customer DB: compact header so "Hapus Selected" fits the top bar --- */
#dialogDatabaseCustomers .dialog__header--tools { padding-top: 14px; padding-bottom: 12px; gap: 10px 12px; }
#dialogDatabaseCustomers .dialog__header--tools .dialog__title { font-size: 1.05rem; }
#dialogDatabaseCustomers .dialog__header--tools .filled-button,
#dialogDatabaseCustomers .dialog__header--tools .tonal-button {
    min-height: 34px; padding: 0 16px; font-size: 0.82rem; gap: 6px;
}
#dialogDatabaseCustomers .dialog__header--tools .filled-button i,
#dialogDatabaseCustomers .dialog__header--tools .tonal-button i { font-size: 0.8rem; }
#dialogDatabaseCustomers .dialog__header--tools .db-search { height: 34px; min-height: 34px; padding: 0 14px; font-size: 0.82rem; }
#dialogDatabaseCustomers .window-dot { width: 30px; height: 30px; font-size: 0.8rem; }
/* Keep the toolbar->Hapus->close order on desktop even though the delete button is now a
   direct header child (mobile reorders it via the media query below). */
#dialogDatabaseCustomers .dialog__header-tools { order: 1; flex: 1 1 auto; }
#dialogDatabaseCustomers #btnDeleteSelectedCustomers { order: 2; }
#dialogDatabaseCustomers .window-dots { order: 3; }

/* --- Items DB: same compact header treatment --- */
#dialogDatabaseItems .dialog__header--tools { padding-top: 14px; padding-bottom: 12px; gap: 10px 12px; }
#dialogDatabaseItems .dialog__header--tools .dialog__title { font-size: 1.05rem; }
#dialogDatabaseItems .dialog__header--tools .filled-button,
#dialogDatabaseItems .dialog__header--tools .tonal-button {
    min-height: 34px; padding: 0 16px; font-size: 0.82rem; gap: 6px;
}
#dialogDatabaseItems .dialog__header--tools .filled-button i,
#dialogDatabaseItems .dialog__header--tools .tonal-button i { font-size: 0.8rem; }
#dialogDatabaseItems .dialog__header--tools .db-search { height: 34px; min-height: 34px; padding: 0 14px; font-size: 0.82rem; }
#dialogDatabaseItems .window-dot { width: 30px; height: 30px; font-size: 0.8rem; }
/* Keep the toolbar->Hapus->close order on desktop even though the delete button is now a
   direct header child (mobile reorders it via the media query below). */
#dialogDatabaseItems .dialog__header-tools { order: 1; flex: 1 1 auto; }
#dialogDatabaseItems #btnDeleteSelectedItems { order: 2; }
#dialogDatabaseItems .window-dots { order: 3; }
/* Draft dialog: desktop order = title | toolbar(Export,Hapus) | search | close.
   Title shows "Draft Tersimpan" on desktop; mobile media query swaps to "Riwayat". */
#dialogDatabaseDrafts .title-desktop { display: inline; }
#dialogDatabaseDrafts .title-mobile { display: none; }
#dialogDatabaseDrafts .dialog__header-tools { order: 1; flex: 0 0 auto; }
#dialogDatabaseDrafts #searchDrafts { order: 2; }
#dialogDatabaseDrafts .window-dots { order: 3; }
.th--mobile { display: none; }

/* --- Database dialogs (desktop): equal dynamic gutters + force-fit columns ---
   Right-left uses the same dynamic method as top-bottom, so the gutter is 1:1 on all four
   sides: the vertical gap is (100vh - height)/2, and width = 100vw minus that same total
   gap -> horizontal gap equals vertical gap exactly, centered, at any viewport size.
   Columns are locked via table-layout:fixed + width:100% — cell content (long email /
   phone / name) can NEVER push a column wider, the trailing Aksi column always stays
   inside the card, and there is no horizontal scroll.
   Mobile (<641px) keeps its existing fullscreen layout untouched. */
@media (min-width: 641px) {
    .dialog__container--large {
        width: calc(100vw - (100vh - min(90vh, 750px)));
        max-width: none;
        height: min(90vh, 750px);
    }

    #tableCustomers,
    #tableItems,
    #tableDrafts { table-layout: fixed; width: 100%; }

    /* Customer: checkbox | Nama | U/P | Alamat1 | Alamat2 | Phone | Email | Aksi
       (U/P 11.2%, Alamat 1-2/Phone/Email 14%; Nama menampung kompensasi) */
    #tableCustomers th:nth-child(1) { width: 4.5%; }
    #tableCustomers th:nth-child(2) { width: 17.3%; }
    #tableCustomers th:nth-child(3) { width: 11.2%; }
    #tableCustomers th:nth-child(4) { width: 14%; }
    #tableCustomers th:nth-child(5) { width: 14%; }
    #tableCustomers th:nth-child(6) { width: 14%; }
    #tableCustomers th:nth-child(7) { width: 14%; }
    #tableCustomers th:nth-child(8) { width: 11%; }
    #tableCustomers td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #tableCustomers .cell-clip { max-width: none; }
    /* Nama & U/P: wrap maksimal 2 baris lewat wrap-element; sisanya ellipsis (...).
       (dibungkus span dari JS — line-clamp tidak bisa dipaksa pada td itu sendiri) */
    #tableCustomers .cell-clamp {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        white-space: normal;
        overflow: hidden;
    }

    /* Items: checkbox | Nama Item (73%, penampung sisa) | Gambar (11%, muat tombol Upload ~98px) | Aksi (11%) */
    #tableItems th:nth-child(1) { width: 5%; }
    #tableItems th:nth-child(2) { width: 73%; }
    #tableItems th:nth-child(3) { width: 11%; }
    #tableItems th:nth-child(4) { width: 11%; }
    #tableItems td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Drafts: checkbox | No. | Tanggal | Nama Customer | Aksi */
    #tableDrafts th:nth-child(1) { width: 5%; }
    #tableDrafts th:nth-child(2) { width: 14%; }
    #tableDrafts th:nth-child(3) { width: 10%; }
    #tableDrafts th:nth-child(4) { width: 56%; }
    #tableDrafts th:nth-child(5) { width: 15%; }
    #tableDrafts td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Slimmer action buttons inside DB dialogs so the Aksi column stays usable at every
       desktop width (two 32px buttons + 6px gap + 28px cell padding). */
    #dialogDatabaseCustomers .data-table__action-btn,
    #dialogDatabaseItems .data-table__action-btn,
    #dialogDatabaseDrafts .data-table__action-btn { width: 32px; height: 32px; }

    /* DB Barang (desktop only): center the "Gambar" header, hide the "Aksi" header text,
       and push the action buttons to the right edge of their column. */
    #tableItems th:nth-child(3) { text-align: center; }
    #tableItems .th-hide-desktop { display: none; }
    /* Draft Tersimpan (desktop only): hide the "Aksi" header text (row is fully clickable). */
    #tableDrafts .th-hide-desktop { display: none; }
    #dialogDatabaseCustomers td:last-child .data-table__actions,
    #dialogDatabaseItems td:last-child .data-table__actions,
    #dialogDatabaseDrafts td:last-child .data-table__actions { justify-content: flex-end; }
}

/* Daftar draft: seluruh baris bisa diklik untuk membuka quotation (konsep mobile→desktop).
   Indikator hover = soft color full row, transisi halus, adaptif light/dark. */
#tableDrafts tr.row-clickable { cursor: pointer; }
#tableDrafts tr.row-clickable td { transition: background-color 0.25s var(--md-motion-standard); }
#tableDrafts tr.row-clickable:hover td { background-color: #e8f0fe; }
html[data-theme="dark"] #tableDrafts tr.row-clickable:hover td { background-color: rgba(138,180,248,0.15); }

/* --- Pagination bar (Database Customer/Barang footer) --- */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.pagination__select {
    height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface-soft); color: var(--ink);
    font-family: var(--md-font-family); font-size: 0.8rem; font-weight: 600;
    outline: none; cursor: pointer;
}
.pagination__select:focus { border-color: var(--md-primary); }
.pagination__btn, .pagination__num {
    min-width: 32px; height: 32px; padding: 0 6px; border: 1px solid var(--line);
    border-radius: 8px; background: var(--surface); color: var(--muted);
    font-family: var(--md-font-family); font-size: 0.8rem; font-weight: 700;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.15s var(--md-motion-standard);
}
.pagination__btn:hover:not(:disabled), .pagination__num:hover { background: var(--surface-soft); color: var(--ink); }
.pagination__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination__num.is-active { background: var(--md-primary); border-color: var(--md-primary); color: #fff; }
.pagination__gap { color: var(--muted); padding: 0 2px; font-size: 0.8rem; }
#dialogDatabaseCustomers .dialog__footer, #dialogDatabaseItems .dialog__footer { gap: 12px; }

/* --- Buttons --- */
.fab-speed-dial { display: none; }
.filled-button--lg { padding: 12px 28px; font-size: 0.95rem; }
.tonal-button--danger { color: var(--md-error); }
.tonal-button--danger:hover { background: var(--md-error-container); }
.generate-row { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 6px 0 4px; }
.generate-row__actions,
.generate-row__primary { display: flex; align-items: center; }
.generate-row__actions { gap: 8px; }
.generate-btn-circle {
    width: 42px; height: 42px; border-radius: 50%; border: none;
    background: var(--md-primary); color: var(--md-on-primary);
    display: grid; place-items: center; cursor: pointer;
    font-size: 1rem; flex-shrink: 0;
    transition: box-shadow .2s, transform .15s;
    box-shadow: var(--shadow-soft);
}
.generate-btn-circle:hover { box-shadow: var(--md-elevation-2); transform: translateY(-1px); filter: brightness(1.05); }
.generate-btn-circle:disabled { background: var(--md-outline-variant); color: var(--muted); box-shadow: none; cursor: not-allowed; opacity: .55; transform: none; filter: none; }
.export-buttons { display: flex; gap: 8px; }

/* --- Table --- */
.table-wrap { overflow: visible; }
.empty-hint { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 16px 0; }

/* Detil Produk form table: force-fit, no side scroll */
#itemsTable { table-layout: fixed; width: 100%; }
#itemsTable td { vertical-align: middle; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret) th:nth-child(1) { width: 45%; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret) th:nth-child(2) { width: 20%; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret) th:nth-child(3) { width: 12%; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret) th:nth-child(4) { width: 13%; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret) th:nth-child(5) { width: 10%; }
/* Invoice Mode: 7 cols (Nama|Harga|Qty|Satuan|Subtotal|Gambar|Aksi) — jatah % tetap, tetap dalam form */
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(1) { width: 34%; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(2) { width: 15%; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(3) { width: 7%; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(4) { width: 9%; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(5) { width: 14%; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(6) { width: 11%; }
#itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(7) { width: 10%; }
#itemsTable .item-name-input { width: 100%; }
.item-name-input,
.item-harga,
.item-satuan,
.item-keterangan,
.item-qty,
.item-kota,
.item-indopaket,
.item-indojaya,
.item-sub-name-input,
.item-sub-qty,
.item-sub-satuan {
    width: 100%;
    min-height: 0;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    font-size: 0.82rem;
    line-height: 1.2;
    font-family: var(--md-font-family);
    color: var(--ink);
    outline: none;
    box-sizing: border-box;
    box-shadow: none; /* REVERTABLE: hapus glow glass, sebelumnya inset 0 1px 0 rgba(255,255,255,0.8) */
    transition: all var(--md-motion-duration-short) var(--md-motion-standard);
}
.item-name-input:focus,
.item-harga:focus,
.item-satuan:focus,
.item-keterangan:focus,
.item-qty:focus,
.item-kota:focus,
.item-indopaket:focus,
.item-indojaya:focus,
.item-sub-name-input:focus,
.item-sub-qty:focus,
.item-sub-satuan:focus {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(43,87,154,0.12);
    background: #fff;
}
.item-name-input { min-height: 0; }
.item-harga { text-align: left; }
.item-satuan { text-transform: none; }
.item-search { position: relative; }
.item-suggest-item { overflow: hidden; text-overflow: ellipsis; white-space: normal; word-break: break-word; }

/* Floating mode (front layer): JS adds .is-floating and positions it in document coordinates
   (appended to <body>) so it escapes the Detil Produk table's horizontal scroll container and
   is never clipped, and stays glued to the input when the mobile keyboard shifts the viewport. */
.item-suggest.is-floating {
    position: absolute; left: auto; right: auto; top: auto; z-index: 9999;
    box-shadow: 0 10px 30px rgba(43,87,154,0.22);
    font-size: 13px !important;
    max-width: calc(100vw - 16px); box-sizing: border-box;
    -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
.data-table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--md-primary); cursor: pointer; }
.cell-img {
    width: 44px; height: 44px; object-fit: contain; border-radius: 6px;
    border: 1px solid var(--line); background: #fff;
}
/* Uniform row height: every Detil Produk row stays the same height whether the
   gambar cell holds a 44px image or just the compact Upload button. */
#itemsTable tbody td { height: 52px; }
#itemsTable tbody td .item-new-gambar { min-height: 44px; align-items: center; }
#itemsTable tbody td .item-upload-btn { min-height: 30px; }
.cell-img--empty { color: var(--muted); font-size: 0.72rem; }
.item-gambar-cell { text-align: center; }
/* Karpet: gambar kolom disamakan 52px agar 1:1 dengan thumbnail di cell Keterangan */
.item-table--karpet .cell-img { width: 52px; height: 52px; }
.item-new-gambar { display: flex; align-items: center; gap: 6px; justify-content: center; }
.item-upload-btn { background: var(--md-primary-container); color: var(--md-primary); }
.item-upload-btn:hover { background: #dbe7f5; }
.tonal-button--compact {
    min-height: 30px; padding: 0 14px; font-size: 0.78rem; font-weight: 700;
    gap: 6px; border-radius: 999px;
}
.item-img-pick { position: relative; display: inline-flex; cursor: pointer; }
.item-img-pick .cell-img { display: block; }
.item-img-pick__overlay {
    position: absolute; inset: 0; display: none;
    align-items: center; justify-content: center;
    background: rgba(0,0,0,0.45); color: #fff; border-radius: 6px; font-size: 0.8rem;
}
.item-img-pick:hover .item-img-pick__overlay { display: flex; }
.data-table__action-btn--save { background: var(--md-primary-container); color: var(--md-primary); }
.data-table__action-btn--save:hover { background: #dbe7f5; }
#itemsTable .data-table__action-btn { width: 28px; height: 28px; font-size: 0.75rem; flex-shrink: 0; }
#itemsTable .item-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

.data-table__action-btn {
    width: 28px; height: 28px; border-radius: 6px; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s; font-size: 0.75rem;
}
.data-table__action-btn--delete { background: #fee2e2; color: #dc2626; }
.data-table__action-btn--delete:hover { background: #fecaca; }
.data-table__action-btn--pdf { background: #e0e7ff; color: #2B579A; }
.data-table__action-btn--pdf:hover { background: #c7d7f5; }

/* --- Preview --- */
.preview-card { border-color: rgba(43,87,154,0.25); }
.preview-frame {
    display: block;
    width: 100%;
    height: 82vh;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
}

/* pdf.js rendered page stack (mobile front-layer preview). Hidden by default so desktop
   keeps the original <iframe>. Only shown inside the mobile media query below. */
.preview-pages { display: none; }
.preview-pages .preview-page {
    display: block; width: 100%; height: auto; margin: 0 auto 10px;
    background: #fff; border: 1px solid var(--line); border-radius: 6px;
    box-shadow: 0 2px 10px rgba(43,87,154,0.12);
}
.preview-pages .preview-loading { padding: 16px; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* --- Image preview in dialog --- */
.img-preview { max-width: 120px; max-height: 120px; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; display: block; }

/* --- Dialog tab active --- */
.dialog__tab--active { background: var(--md-primary-container); color: var(--md-primary); }

/* --- Responsive --- */
/* ============================================================
   Mobile (phone) pass — main form + all dialogs
   ============================================================ */
@media (max-width: 640px) {
    /* Top bar: title overflow + mobile label + perfect-circle back button */
    .top-bar__leading { min-width: 0; }
    .top-bar__title {
        min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0;
    }
    .top-bar__title::after {
        content: "Penawaran"; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.2px; color: var(--ink);
    }
    .top-bar__icon { font-size: 26px; }
    .top-bar__trailing { flex-shrink: 0; }
    .theme-switch { transform: scale(0.8); transform-origin: right center; }
    .top-bar .icon-button { flex: 0 0 auto; width: 38px; height: 38px; padding: 0; }
    /* Database button: circle icon only, no label */
    #btnDatabase {
        width: 30px !important; height: 30px !important; min-height: 30px !important; padding: 0 !important;
        border-radius: 50% !important; font-size: 0;
        box-shadow: none !important; transform: none !important;
        display: flex !important; align-items: center !important; justify-content: center !important; gap: 0 !important;
    }
    #btnDatabase i { font-size: 0.8rem; }
    #btnDatabase .fa-caret-down { display: none; }

    /* Clear the fixed 64px top bar so the first card isn't tucked under it.
       design-system makes .main-content a flex ROW (justify-content:center) which lets the
       wide product table force the whole form past the viewport — switch to block + 100% so
       the form can never exceed the screen. */
    .main-content { display: block; width: 100%; max-width: 100%; min-width: 0; padding: 76px 12px 24px; overflow-x: hidden; animation: none; }

    /* Cards */
    .card__grid { grid-template-columns: 1fr; }
    /* Info Surat on mobile: Atas nama (full) / Template (full) / Nomor surat - Tanggal (2 col) */
    #cardInfoSurat .card__grid { grid-template-columns: repeat(2, 1fr); }
    #cardInfoSurat .card__grid > :nth-child(1) { grid-column: 1 / -1; order: 1; }
    #cardInfoSurat .card__grid > :nth-child(3) { grid-column: 1 / -1; order: 2; }
    #cardInfoSurat .card__grid > :nth-child(2) { order: 3; min-width: 0; }
    #cardInfoSurat .card__grid > :nth-child(4) { order: 4; }
    /* Info Customer on mobile: reorder to Nama / UP / Email / Phone / Alamat1 / Alamat2.
       DOM order = Nama(1) UP(2) Alamat1(3) Email(4) Phone(5) Alamat2(6). */
    #cardInfoCustomer .card__grid > :nth-child(1) { order: 1; }
    #cardInfoCustomer .card__grid > :nth-child(2) { order: 2; }
    #cardInfoCustomer .card__grid > :nth-child(3) { order: 5; }
    #cardInfoCustomer .card__grid > :nth-child(4) { order: 3; }
    #cardInfoCustomer .card__grid > :nth-child(5) { order: 4; }
    #cardInfoCustomer .card__grid > :nth-child(6) { order: 6; }
    /* Nomor surat on mobile: default font, forced to fit the column width */
    #cardInfoSurat #inputNoPenawaran {
        width: 100%; max-width: 100%; min-width: 0;
        box-sizing: border-box; overflow: hidden;
    }
    .card__header-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
    .header-actions { position: static; min-width: 0; min-height: 0; }
    .header-actions .tonal-button {
        position: static; top: auto; right: auto; transform: none;
        width: auto; justify-content: center;
    }
    /* card-pair stacks on mobile; reset the note-acuan flex so both go full width */
    .card-pair { display: flex; flex-direction: column; gap: 14px; }
    .card-pair--note-acuan #cardNote,
    .card-pair--note-acuan #acuanCard { flex: 1 1 auto; width: 100%; margin-top: 0; }
    /* Acuan table: strict px supaya bisa side-scroll (sama kayak Detil Barang) */
    #acuanCard .data-table { table-layout: fixed; width: fit-content; }
    #acuanCard .acuan-th-tipe,
    #acuanCard td:nth-child(1) { width: 193px; }
    #acuanCard .acuan-th-warna,
    #acuanCard td:nth-child(2) { width: 125px; }
    #acuanCard .acuan-th-harga,
    #acuanCard td:nth-child(3) { width: 150px; }
    #acuanCard .acuan-th-satuan,
    #acuanCard td:nth-child(4) { width: 125px; }
    #acuanCard .acuan-th-action,
    #acuanCard td:nth-child(5) { width: 80px; }
    #acuanCard td:nth-child(5) .data-table__actions { justify-content: flex-end; }
    #acuanCard .data-table td, #acuanCard .data-table th { box-sizing: border-box; }
    #acuanCard .table-wrap { -webkit-overflow-scrolling: auto; }
    #acuanCard { position: relative; z-index: 1; }
    /* override card's th padding to tighten */
    #acuanCard .data-table th, #acuanCard .data-table td { padding: 8px 6px; }
    /* hidden action buttons must not reserve a row (fixes the gap under the title) */
    .header-actions .tonal-button[style*="hidden"] { display: none; }

    /* Compact product table.
       .card{min-width:0} stops the wide table from stretching the card (and the whole
       form) to its width. .table-wrap swipes sideways only when content needs it, so the
       rest of the layout stays phone-width and data stays readable. */
    .form-container { width: 100%; max-width: 100%; min-width: 0; }
    .card { min-width: 0; max-width: 100%; }
    /* Mobile glass — disabled, back to solid */
    .card, .dialog__container, .preview-card,
    #acuanCard, .acuan-form-card, .dropdown__menu,
    .acuan-minicard, .acuan-form {
        background: var(--surface);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    /* Dark mode mobile — solid bg instead of glass */
    html[data-theme="dark"] .card,
    html[data-theme="dark"] .dialog__container,
    html[data-theme="dark"] .preview-card,
    html[data-theme="dark"] #acuanCard,
    html[data-theme="dark"] .acuan-form-card,
    html[data-theme="dark"] .dropdown__menu,
    html[data-theme="dark"] .acuan-minicard,
    html[data-theme="dark"] .acuan-form {
        background: var(--bg);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret) { table-layout: fixed; width: fit-content; font-size: 0.8rem; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret) th:nth-child(1) { width: 250px; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret) th:nth-child(2) { width: 150px; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret) th:nth-child(3) { width: 100px; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret) th:nth-child(4) { width: 120px; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret) th:nth-child(5) { width: 125px; }
    /* Invoice mode (7 cols) — mobile fixed px */
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(1) { width: 250px; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(2) { width: 150px; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(3) { width: 75px; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(4) { width: 100px; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(5) { width: 150px; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(6) { width: 120px; }
    #itemsTable:not(.item-table--karpet):not(.item-table--indomaret).invoice-on th:nth-child(7) { width: 125px; }
    .data-table__th, .data-table__td { padding: 8px 6px; }
    /* Mobile: biarkan cell auto-fit konten, hilangkan blank space kosong di trailing row */
    #itemsTable tbody td { height: auto; }
    .table-wrap { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; min-width: 0; }
    /* Suggestion: show ~4 items, scroll the rest */
    .item-suggest { max-height: 168px; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
    .item-suggest::-webkit-scrollbar { display: none; }
    /* Floating suggestion list is appended to <body>, so it would inherit the
       body font (16px) on the <ul>; lock the item font explicitly so every
       suggestion (regardless of how many matches / which letter) stays the
       same small size — the "huge first-letter" look was just a tall list of
       many matches, not a font bug. */
    .item-suggest .autocomplete-item,
    .item-suggest.is-floating .autocomplete-item {
        font-size: 13px !important;
        line-height: 1.35;
        padding: 8px 12px;
    }
    .item-suggest.is-floating { max-height: 150px; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
    .item-suggest.is-floating::-webkit-scrollbar { display: none; }
    .item-name-input { min-width: 0; width: 100%; }
    .item-harga { min-width: 0; width: 100%; }
    .item-satuan { min-width: 0; width: 100%; }
    /* Indomaret: kolom fixed px, relaksasi min-width agar input tidak menyempit */
    .item-row--indomaret .item-name-input,
    .item-row--indomaret .item-satuan,
    .item-row--indomaret .item-kota,
    .item-row--indomaret .item-indopaket,
    .item-row--indomaret .item-indojaya,
    .item-row--indomaret .item-qty { min-width: 0; width: 100%; }
    /* Karpet: fixed px widths via th:nth-child rules above; relax min-width so
       inline buttons don't get squeezed. */
    .item-row--karpet .item-name-input { min-width: 0; }
    .item-row--karpet .item-cell-karpet-ket { min-width: 0; }
    .item-row--karpet .btn-design { padding: 4px 7px; font-size: 0.68rem; }
    .item-row--karpet .item-blueprint-img { max-width: 150px; }
    /* Karpet gambar kolom: 80px, center */
    #itemsTable.item-table--karpet th:nth-child(5),
    #itemsTable.item-table--karpet td:nth-child(5) { width: 80px !important; text-align: center !important; }
    #itemsTable.item-table--karpet.invoice-on th:nth-child(7),
    #itemsTable.item-table--karpet.invoice-on td:nth-child(7) { width: 80px !important; text-align: center !important; }
    .item-table--karpet .cell-img { width: 50px !important; height: 50px !important; }

    /* Date input matches the other fields in Safari */
    input[type="date"] { width: 100%; box-sizing: border-box; -webkit-appearance: none; min-width: 0; }

    /* Preview: on mobile, hide the <iframe> (iOS can't scroll/paginate embedded PDFs) and
       show the pdf.js page stack instead. Card keeps its proper phone width; pages are
       sized to 100% of the card so nothing overflows. */
    .preview-frame { display: none; }
    .preview-pages { display: block; }

    /* Mobile: hide FAB */
    .fab-speed-dial { display: none; }

    /* Preview: center the compact export buttons */
    .preview-card .export-buttons { flex-wrap: wrap; justify-content: center; gap: 5px; }
    .preview-card .export-buttons .tonal-button {
        width: auto; min-height: 34px; padding: 0 10px; font-size: 0.78rem; gap: 5px; justify-content: center;
    }

    /* Dialogs: tighter body, stacked full-width footers */
    .dialog__body { padding: 16px; }
    .dialog__footer { flex-direction: column-reverse; gap: 10px; padding: 14px 16px; }
    .dialog__footer .tonal-button, .dialog__footer .filled-button { width: 100%; justify-content: center; }

    /* ===== Database dialogs: Customer / Barang / Draft ===== */
    /* Edge-to-edge on mobile so the data table gets maximum room */
    #dialogDatabaseCustomers .dialog__container--large,
    #dialogDatabaseItems .dialog__container--large,
    #dialogDatabaseDrafts .dialog__container--large {
        width: 100vw; height: 100vh; height: 100dvh; max-width: 100vw; border-radius: 0;
    }
    /* Header: title + close on the top line, toolbar (buttons + search) wraps below */
    .dialog__header--tools { align-items: stretch; }
    .dialog__header--tools .dialog__header-tools { flex: 1 1 100%; flex-wrap: wrap; gap: 8px; }
    .dialog__header--tools .window-dots { margin-left: auto; }
    /* Customer DB dialog: precise 3-row mobile header. The delete button is a direct header
       child (not nested in the toolbar), so flex ordering lays it out cleanly without display:contents.
       Row1 = title | Hapus (pill) ...... close ; Row2 = Tambah/Import/Export ; Row3 = search.
       Uniform 10px gaps between rows. */
    #dialogDatabaseCustomers .dialog__header--tools { flex-wrap: wrap; align-items: center; gap: 14px 10px; }
    #dialogDatabaseCustomers .dialog__title { order: 0; flex: 0 0 auto; }
    #dialogDatabaseCustomers #btnDeleteSelectedCustomers {
        order: 1; flex: 0 0 auto; border-radius: 999px; padding: 6px 16px;
    }
    #dialogDatabaseCustomers .window-dots { order: 2; margin-left: auto; }
    #dialogDatabaseCustomers .dialog__header-tools { order: 3; flex: 1 1 100%; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
    #dialogDatabaseCustomers #btnAddCustomer,
    #dialogDatabaseCustomers #btnImportCustomers,
    #dialogDatabaseCustomers #btnExportCustomers { flex: 0 1 auto; }
    #dialogDatabaseCustomers #searchCustomers { flex: 1 1 100%; min-width: 0; margin-top: 12px; }
    /* Items DB dialog: same precise 3-row mobile header as Customer.
       Row1 = title | Hapus (pill) ...... close ; Row2 = Tambah/Import/Export ; Row3 = search. */
    #dialogDatabaseItems .dialog__header--tools { flex-wrap: wrap; align-items: center; gap: 14px 10px; }
    #dialogDatabaseItems .dialog__title { order: 0; flex: 0 0 auto; }
    #dialogDatabaseItems #btnDeleteSelectedItems {
        order: 1; flex: 0 0 auto; border-radius: 999px; padding: 6px 16px;
    }
    #dialogDatabaseItems .window-dots { order: 2; margin-left: auto; }
    #dialogDatabaseItems .dialog__header-tools { order: 3; flex: 1 1 100%; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
    #dialogDatabaseItems #btnAddItemDb,
    #dialogDatabaseItems #btnImportItems,
    #dialogDatabaseItems #btnExportItems { flex: 0 1 auto; }
    #dialogDatabaseItems #searchItems { flex: 1 1 100%; min-width: 0; margin-top: 12px; }
    /* Draft dialog: mobile header. Row1 = title + Export PDF + Hapus + close (one compact line) ;
       Row2 = search (full width). Title shows "Riwayat" on mobile, "Draft Tersimpan" on desktop.
       Export/Hapus stay visibility-toggled so the layout never shifts when they appear. */
    #dialogDatabaseDrafts .dialog__header--tools { flex-wrap: wrap; align-items: center; gap: 10px; }
    #dialogDatabaseDrafts .title-desktop { display: none; }
    #dialogDatabaseDrafts .title-mobile { display: inline; }
    #dialogDatabaseDrafts .dialog__title { order: 0; flex: 0 0 auto; }
    #dialogDatabaseDrafts .window-dots { order: 2; margin-left: auto; }
    #dialogDatabaseDrafts .dialog__header-tools { order: 1; flex: 0 0 auto; gap: 8px; }
    #dialogDatabaseDrafts #btnExportSelectedDraftsPdf,
    #dialogDatabaseDrafts #btnDeleteSelectedDrafts {
        flex: 0 0 auto; padding: 3.5px 7px; font-size: 0.55rem; line-height: 1.2;
    }
    #dialogDatabaseDrafts #btnDeleteSelectedDrafts { border-radius: 999px; }
    #dialogDatabaseDrafts #searchDrafts { order: 3; flex: 1 1 100%; min-width: 0; margin-top: 12px; }
    #dialogDatabaseDrafts .window-dot { width: 32px; height: 32px; font-size: 0.84rem; }
    /* Tables: horizontal scroll, locked (sticky) header so data scrolls under it, uniform padding */
    #dialogDatabaseCustomers .dialog__table-container,
    #dialogDatabaseItems .dialog__table-container,
    #dialogDatabaseDrafts .dialog__table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0 12px 12px; }
    #dialogDatabaseCustomers .dialog__table-container .data-table thead th,
    #dialogDatabaseItems .dialog__table-container .data-table thead th,
    #dialogDatabaseDrafts .dialog__table-container .data-table thead th {
        position: sticky; top: 0; z-index: 2; background: var(--surface);
        box-shadow: inset 0 -1px 0 var(--line);
    }
    .data-table__th, .data-table__td { padding: 10px 8px; }
    .data-table__action-btn { width: 34px; height: 34px; }
    /* Drafts: compact 1-screen fit (override above sizes) */
    #dialogDatabaseDrafts .dialog__table-container { overflow-x: hidden; }
    #dialogDatabaseDrafts .th--desktop { display: none; }
    #dialogDatabaseDrafts .th--mobile { display: inline; }
    #dialogDatabaseDrafts .data-table { table-layout: fixed; }
    #dialogDatabaseDrafts .data-table th:nth-child(1),
    #dialogDatabaseDrafts .data-table td:nth-child(1) { width: 32px; padding: 8px 2px; text-align: center; }
    #dialogDatabaseDrafts .data-table th:nth-child(2) { width: 52px; }
    #dialogDatabaseDrafts .data-table td:nth-child(2) { width: 52px; }
    #dialogDatabaseDrafts .data-table th:nth-child(3) { width: 74px; }
    #dialogDatabaseDrafts .data-table td:nth-child(3) { width: 74px; }
    #dialogDatabaseDrafts .data-table td:nth-child(4) {
        overflow: hidden;
        -webkit-mask-image: linear-gradient(to bottom, black 85%, transparent 100%);
        mask-image: linear-gradient(to bottom, black 85%, transparent 100%);
    }
    #dialogDatabaseDrafts .data-table th:nth-child(5) { width: 70px !important; }
    #dialogDatabaseDrafts .data-table td:nth-child(5) { width: 70px; padding: 8px 2px; }
    #dialogDatabaseDrafts .data-table__action-btn { width: 29px; height: 29px; font-size: 0.7rem; }
    /* Gallery (item-add form): 2 columns, taller scroll area on mobile */
    #dialogAddItem .img-gallery { grid-template-columns: repeat(2, 1fr); max-height: 42vh; }

    /* Prevent iOS auto-zoom on input focus (keep view static) */
    input, textarea, select,
    .form-field__input, .db-search, .img-gallery-search,
    .item-name-input, .item-harga, .item-satuan, .item-keterangan, .item-qty,
    .custom-select__trigger, .custom-select__option { font-size: 16px !important; }
    /* iOS auto-zooms the whole page when a focused input is < 16px; the zoom looks
       like an oversized first character. Guarantee >=16px on every form input. */
    #itemsTable input, #itemsTable select, .form-field__input { font-size: 16px !important; }
    /* Kill the iOS text-insertion magnification callout (the oversized first
       character bubble). -webkit-appearance:none strips the iOS input chrome
       that triggers it; tap-highlight off removes the flash. */
    #itemsTable input, #itemsTable select {
        -webkit-appearance: none;
        -webkit-tap-highlight-color: transparent;
        border-radius: 8px;
    }
}

body.dialog-open { overscroll-behavior: none; touch-action: none; }

/* Mini-database Harga Karpet (grouped by Tipe) */
.acuan-db__tipe { padding: 12px 4px; border-bottom: 1px solid var(--line); }
.acuan-db__tipe:last-child { border-bottom: none; }
.acuan-db__tipe-name { font-weight: 700; font-size: 0.95rem; color: var(--md-primary); margin-bottom: 6px; }
.acuan-db__warnas { display: flex; flex-direction: column; gap: 4px; padding-left: 14px; }
.acuan-db__warna { display: flex; align-items: center; gap: 12px; font-size: 0.88rem; }
.acuan-db__warna-name { flex: 1; }
.acuan-db__warna-harga { color: var(--muted); white-space: nowrap; }
.acuan-db__warna .data-table__action-btn { width: 26px; height: 26px; font-size: 0.72rem; }

/* Acuan Karpet form + mini-database */
/* ===== Compact Database Harga Karpet (senior-compact) =====
   Override the jumbo global .form-field__input (min-height:52px, radius:16px)
   with explicit min-height + radius so textboxes shrink properly. */
#dialogAcuanDb .form-field__input,
#dialogAcuanDb input.form-field__input,
#dialogAcuanDb select.form-field__input {
    min-height: 32px;
    height: 32px;
    padding: 4px 10px;
    font-size: 0.82rem;
    border-radius: 8px;
    line-height: 1.2;
}
#dialogAcuanDb .dialog__header { padding: 10px 14px; }
#dialogAcuanDb .dialog__title { font-size: 0.95rem; }
#dialogAcuanDb .dialog__table-container { padding: 10px 14px; }
#dialogAcuanDb .acuan-form { padding: 10px; margin-bottom: 12px; }
#dialogAcuanDb .acuan-form .filled-button,
#dialogAcuanDb .acuan-form .tonal-button { min-height: 30px; padding: 0 12px; font-size: 0.78rem; }
#dialogAcuanDb #btnAcuanTambah { min-height: 30px; padding: 0 12px; font-size: 0.78rem; margin-bottom: 10px; }
#dialogAcuanDb #acuanFormAddWarna { min-height: 26px; padding: 0 10px; font-size: 0.74rem; margin-top: 4px; }
.acuan-satuan-row { display: flex; gap: 6px; flex-wrap: wrap; }
.acuan-satuan-row .form-field__input { flex: 1; min-width: 70px; }
.acuan-form .form-field__label { display: block; font-size: 0.72rem; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.acuan-warna-input { display: flex; gap: 5px; margin-bottom: 5px; }
.acuan-warna-input .acuan-warna-del { flex-shrink: 0; min-height: 32px; padding: 0 8px; align-self: stretch; }

/* mini-database Harga Karpet: compact 1-column list (mini popup) */
.acuan-minicard { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin-bottom: 5px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.acuan-minicard__main { flex: 1; min-width: 0; text-align: left; }
.acuan-minicard__tipe { font-weight: 700; font-size: 0.82rem; color: var(--md-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acuan-minicard__actions { flex-shrink: 0; display: flex; gap: 5px; align-items: center; }
.acuan-minicard__actions .tonal-button--compact { padding: 0 8px; min-height: 24px; font-size: 0.7rem; }
.acuan-minicard__actions .data-table__action-btn { width: 24px; height: 24px; font-size: 0.68rem; }

/* compact Harga Karpet form */
#acuanCard .card__header-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
#acuanCard .header-actions { position: static; min-width: 0; min-height: 0; display: flex; gap: 8px; }
#acuanCard .header-actions .tonal-button { position: static; top: auto; right: auto; transform: none; width: auto; justify-content: center; }
#acuanCard .table-wrap { font-size: 0.86rem; overflow-x: auto; overflow-y: hidden; }
#acuanCard .data-table { table-layout: fixed; width: 100%; }
#acuanCard .data-table tbody td { height: 52px; }
#acuanCard .data-table th, #acuanCard .data-table td { padding: 14px 14px; }
#acuanCard .form-field__input,
#acuanCard select.form-field__input { width: 100%; box-sizing: border-box; }
#acuanCard select.form-field__input:disabled { background: #f1f3f4; color: #9aa0a6; cursor: not-allowed; opacity: 0.7; }
@media (min-width: 641px) {
    #acuanCard .acuan-th-tipe { width: 154px; }
    #acuanCard .acuan-th-warna { width: 100px; }
    #acuanCard .acuan-th-satuan { width: 110px; }
    #acuanCard .acuan-th-harga { width: 130px; }
    #acuanCard .acuan-th-action { width: 70px; }
}
#acuanCard .item-actions-cell { display: flex; gap: 4px; justify-content: flex-end; }
#acuanCard .item-actions-cell .data-table__action-btn { width: 28px; height: 28px; font-size: 0.72rem; flex-shrink: 0; }

/* Mini popup dialog for Database Harga Karpet (1-column list) */
.dialog__container--acuan { width: 380px; max-width: 92vw; }
#dialogAcuanDb .dialog__header--tools {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: nowrap; gap: 12px;
}
#dialogAcuanDb .dialog__header--tools .dialog__title { margin: 0; flex: 0 0 auto; }
#dialogAcuanDb .dialog__header--tools .dialog__header-tools {
    flex: 0 0 auto; flex-wrap: nowrap; margin-left: auto;
    align-items: center; display: flex; gap: 8px;
}
#dialogAcuanDb .dialog__header--tools #btnAcuanTambah {
    height: 32px; margin: 0; align-self: center;
}
#dialogAcuanDb .dialog__header--tools .window-dot {
    width: 32px; height: 32px; align-self: center;
}
#dialogAcuanDb .dialog__table-container { max-height: 60vh; overflow-y: auto; }
#dialogAcuanDb .acuan-form { background: var(--bg); }

/* Form view = separate card frame for Tambah/Edit session */
.acuan-form-view { display: block; }
.acuan-form-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 14px; }
.acuan-form-card__title { font-weight: 700; font-size: 0.92rem; color: var(--md-primary); margin-bottom: 10px; }
.acuan-form-card__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* ===== KARPET DETIL PRODUK LAYOUT =====
   Karpet reuses the SAME row styling as standard (height:52px, vertical-align:middle
   from #itemsTable td). Only differences: side-scroll table + inline design button
   inside the name input + a Keterangan column. No custom cell heights. */
/* Auto-fit like standard: table-layout:fixed + width:100% + jatah % per kolom
   (ngikut lebar form). Scoped strictly to karpet, standard untouched. */
#itemsTable.item-table--karpet { table-layout: fixed; width: 100%; }
#itemsTable.item-table--karpet th,
#itemsTable.item-table--karpet td { box-sizing: border-box; }
/* Non-invoice (6 cols): Nama|Ket|Harga|Satuan|Gambar|Aksi */
#itemsTable.item-table--karpet th:nth-child(1) { width: 28%; }
#itemsTable.item-table--karpet th:nth-child(2) { width: 22%; }
#itemsTable.item-table--karpet th:nth-child(3) { width: 14%; }
#itemsTable.item-table--karpet th:nth-child(4) { width: 10%; }
#itemsTable.item-table--karpet th:nth-child(5) { width: 14%; }
#itemsTable.item-table--karpet th:nth-child(6) { width: 10%; }
/* Invoice (8 cols): Nama|Ket|Harga|Qty|Satuan|Subtotal|Gambar|Aksi */
#itemsTable.item-table--karpet.invoice-on th:nth-child(1) { width: 24%; }
#itemsTable.item-table--karpet.invoice-on th:nth-child(2) { width: 20%; }
#itemsTable.item-table--karpet.invoice-on th:nth-child(3) { width: 12%; }
#itemsTable.item-table--karpet.invoice-on th:nth-child(4) { width: 7%; }
#itemsTable.item-table--karpet.invoice-on th:nth-child(5) { width: 9%; }
#itemsTable.item-table--karpet.invoice-on th:nth-child(6) { width: 12%; }
#itemsTable.item-table--karpet.invoice-on th:nth-child(7) { width: 8%; }
#itemsTable.item-table--karpet.invoice-on th:nth-child(8) { width: 8%; }
@media (max-width: 640px) {
    #itemsTable.item-table--karpet { table-layout: fixed; width: fit-content; font-size: 0.8rem; }
    #itemsTable.item-table--karpet th:nth-child(1) { width: 250px; }
    #itemsTable.item-table--karpet th:nth-child(2) { width: 250px; }
    #itemsTable.item-table--karpet th:nth-child(3) { width: 150px; }
    #itemsTable.item-table--karpet th:nth-child(4) { width: 100px; }
    #itemsTable.item-table--karpet th:nth-child(5) { width: 120px; }
    #itemsTable.item-table--karpet th:nth-child(6) { width: 100px; }
    #itemsTable.item-table--karpet.invoice-on th:nth-child(1) { width: 250px; }
    #itemsTable.item-table--karpet.invoice-on th:nth-child(2) { width: 250px; }
    #itemsTable.item-table--karpet.invoice-on th:nth-child(3) { width: 150px; }
    #itemsTable.item-table--karpet.invoice-on th:nth-child(4) { width: 75px; }
    #itemsTable.item-table--karpet.invoice-on th:nth-child(5) { width: 100px; }
    #itemsTable.item-table--karpet.invoice-on th:nth-child(6) { width: 150px; }
    #itemsTable.item-table--karpet.invoice-on th:nth-child(7) { width: 120px; }
    #itemsTable.item-table--karpet.invoice-on th:nth-child(8) { width: 100px; }
}
/* Indomaret (7 cols): Nama|Qty|Satuan|Kota|Indopaket|Indojaya|Aksi */
#itemsTable.item-table--indomaret { table-layout: fixed; width: 100%; }
#itemsTable.item-table--indomaret th,
#itemsTable.item-table--indomaret td { box-sizing: border-box; }
#itemsTable.item-table--indomaret th:nth-child(1) { width: 28%; }
#itemsTable.item-table--indomaret th:nth-child(2) { width: 7%; }
#itemsTable.item-table--indomaret th:nth-child(3) { width: 8%; }
#itemsTable.item-table--indomaret th:nth-child(4) { width: 21%; }
#itemsTable.item-table--indomaret th:nth-child(5) { width: 15%; }
#itemsTable.item-table--indomaret th:nth-child(6) { width: 15%; }
#itemsTable.item-table--indomaret th:nth-child(7) { width: 6%; }
@media (max-width: 640px) {
    #itemsTable.item-table--indomaret { table-layout: fixed; width: fit-content; font-size: 0.8rem; }
    #itemsTable.item-table--indomaret th:nth-child(1) { width: 200px; }
    #itemsTable.item-table--indomaret th:nth-child(2) { width: 60px; }
    #itemsTable.item-table--indomaret th:nth-child(3) { width: 80px; }
    #itemsTable.item-table--indomaret th:nth-child(4) { width: 150px; }
    #itemsTable.item-table--indomaret th:nth-child(5) { width: 130px; }
    #itemsTable.item-table--indomaret th:nth-child(6) { width: 130px; }
    #itemsTable.item-table--indomaret th:nth-child(7) { width: 60px; }
}
/* Indomaret: tombol "+" (tambah item) di dalam textbox nama induk */
.item-name-wrap--indomaret { position: relative; }
.item-name-wrap--indomaret .item-search { flex: 1; min-width: 0; }
.item-name-wrap--indomaret .item-name-input { padding-right: 34px; }
.btn-add-sub {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    padding: 0; border: none; border-radius: 7px;
    background: transparent; color: var(--md-primary);
    font-size: 0.8rem; cursor: pointer;
    transition: background 0.2s ease;
}
.btn-add-sub:hover { background: var(--md-primary-container); }
.btn-add-sub:disabled { color: var(--muted); cursor: not-allowed; background: transparent; }
/* Tombol "-" hapus item di dalam textbox sub — design sama dengan "+" induk */
.btn-del-sub { color: var(--muted); }
.btn-del-sub:hover { background: var(--md-error-container); color: var(--md-error); }
/* Dark mode: tombol "+"/"-" di Detil Produk dibuat terang (pill berwarna) biar keliatan. */
html[data-theme="dark"] .btn-add-sub { color: #8ab4f8; background: rgba(138,180,248,0.14); }
html[data-theme="dark"] .btn-add-sub:hover { background: rgba(138,180,248,0.28); }
html[data-theme="dark"] .btn-del-sub { color: #f28b82; background: rgba(242,139,130,0.14); }
html[data-theme="dark"] .btn-del-sub:hover { background: rgba(242,139,130,0.28); }
/* Baris item tambahan (sub) indomaret: nama+qty+satuan, latar mengikuti induk (var --surface,
   putih di light / gelap di dark — bukan #fff kaku yang bikin konten tak terbaca di dark). */
.item-row--indomaret-sub { background: var(--surface); }
.item-row--indomaret-sub .item-sub-search { position: relative; }
.item-row--indomaret-sub .item-sub-name-input,
.item-row--indomaret-sub .item-sub-qty,
.item-row--indomaret-sub .item-sub-satuan { width: 100%; }
/* Garis pembatas = pembatas GRUP, bukan antar baris:
   - induk yang punya sub: tanpa border bawah (sub mengikutinya)
   - semua sub: tanpa border bawah
   - sub terakhir dalam grup (`.is-group-last`): border bawah sebagai pembatas grup */
.item-row--indomaret.has-sub > td { border-bottom: none; }
.item-row--indomaret-sub > td { border-bottom: none; }
.item-row--indomaret-sub.is-group-last > td,
.item-row--indomaret.is-group-last > td { border-bottom: 1px solid rgba(181, 189, 200, 0.8); }
@media (max-width: 640px) {
    .item-row--indomaret-sub .item-sub-name-input,
    .item-row--indomaret-sub .item-sub-qty,
    .item-row--indomaret-sub .item-sub-satuan { min-width: 0; }
}
/* Inline "Upload design" button sits inside the name textbox, right-aligned. */
.item-name-wrap { position: relative; display: flex; align-items: center; gap: 6px; }
.item-name-wrap .item-keterangan { flex: 1; min-width: 0; padding-right: 90px; }
/* Saat design sudah dimuat: tombol Upload/✓ disembunyikan, padding kanan normal,
   sehingga textbox menyusut & thumbnail muat di sampingnya tanpa menimpa. */
.item-name-wrap:has(.ket-thumb) .item-keterangan { padding-right: 8px; }
.item-name-wrap:has(.ket-thumb) .btn-group { display: none; }
/* Adjust padding when shape badge is shown (wider than icon buttons) */
.item-name-wrap:has(.shape-badge) .item-keterangan { padding-right: 130px; }
/* Button group — absolute right inside item-name-wrap */
.btn-group {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 3px;
}
/* Thumbnail of uploaded design, sits beside the keterangan textbox (same column).
   Width matches the Gambar column preview (1:1, 20% smaller). */
.ket-thumb {
    position: relative; flex: 0 0 auto;
    width: 52px; height: 52px; padding: 0; border: 1px solid var(--line);
    border-radius: 8px; overflow: hidden; background: #fff; cursor: pointer;
}
.ket-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ket-thumb__x {
    position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(20,20,20,0.55); backdrop-filter: none; -webkit-backdrop-filter: none;
    color: #fff; border-radius: 50%;
    font-size: 13px; line-height: 1; cursor: pointer;
}
.ket-thumb__x:hover { background: rgba(20,20,20,0.8); }
.btn-design {
    font-size: 0.72rem;
    padding: 4px 7px;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.btn-design:hover { border-color: var(--md-primary); }
.btn-design.is-loaded {
    background: #e6f4ea;
    border-color: #2e7d4f;
    color: #1f6b3f;
}
/* Shape button — icon only, next to upload */
.btn-shape {
    font-size: 0.72rem;
    padding: 4px 7px;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
    line-height: 1;
}
.btn-shape:hover { border-color: var(--md-primary); }
.btn-shape--active {
    border-color: #28a745;
    color: #28a745;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.btn-shape--active.animate-pop i {
    animation: iconPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes iconPop {
    0% { transform: scale(0) rotate(-90deg); opacity: 0; }
    60% { transform: scale(1.2) rotate(10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
/* Shape badge — replaces shape btn when active */
.shape-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    padding: 3px 7px;
    border-radius: 7px;
    border: 1px solid var(--md-primary);
    background: #e8f0fe;
    color: var(--md-primary);
    white-space: nowrap;
    cursor: default;
}
.shape-badge__x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px; height: 16px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    color: var(--md-primary);
    transition: background 0.2s;
}
.shape-badge__x:hover { background: rgba(0,0,0,0.1); }
/* ===== Shape Mini Popup Compact ===== */
/* Shared base styles (desktop + mobile) */
.shape-popup__body {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}
.shape-popup__row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    margin-bottom: 6px;
}
.shape-popup__row input[type="number"],
.shape-popup__row input[type="text"] {
    width: 35px;
    padding: 3px 4px;
    font-size: 0.7rem;
    border: 1px solid var(--line);
    border-radius: 5px;
    outline: none;
    background: #fafafa;
    transition: border-color 0.2s;
    text-align: center;
}
.shape-popup__row input[type="number"]:focus,
.shape-popup__row input[type="text"]:focus {
    border-color: var(--md-primary);
    background: #fff;
}
.shape-popup__row input[type="number"]::-webkit-inner-spin-button,
.shape-popup__row input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.shape-popup__row input[type="number"] {
    -moz-appearance: textfield;
}
.shape-popup__canvas-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
}
.shape-popup__canvas-wrap canvas {
    display: block;
    cursor: crosshair;
    background: #f9f9f9;
}
.shape-popup__actions {
    display: flex;
    gap: 3px;
    justify-content: center;
    padding-top: 4px;
    border-top: 1px solid var(--line);
}
.shape-popup__apply {
    padding: 3px 8px;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 5px;
    border: none;
    background: var(--md-primary);
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s;
}
.shape-popup__apply:hover { opacity: 0.85; }
.shape-popup__delete {
    padding: 3px 8px;
    font-size: 0.65rem;
    border-radius: 5px;
    border: 1px solid #dc3545;
    background: #fff;
    color: #dc3545;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.shape-popup__delete:hover { background: #dc3545; color: #fff; }
/* Close button hidden by default; shown on mobile */
.shape-popup__close { display: none; }

/* --- Desktop: mini popup near button --- */
@media (min-width: 641px) {
    #dialogShape.shape-popup-mode {
        opacity: 1;
        pointer-events: none;
        background: transparent;
        z-index: 1000;
    }
    #dialogShape.shape-popup-mode .dialog__container--shape {
        position: absolute;
        width: 156px;
        max-width: calc(100vw - 12px);
        max-height: 90vh;
        pointer-events: auto;
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
        transition: opacity 0.2s ease, transform 0.2s ease;
        box-shadow: 0 8px 30px rgba(0,0,0,0.15);
        border-radius: 8px;
        overflow-y: auto;
        padding: 6px;
        background: var(--surface);
    }
    #dialogShape.shape-popup-mode.shape-popup-visible .dialog__container--shape {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    #dialogShape.shape-popup-mode .dialog__scrim {
        display: none;
    }
}

/* --- Mobile: full overlay --- */
@media (max-width: 640px) {
    #dialogShape.shape-popup-mode {
        opacity: 1;
        pointer-events: auto;
        background: rgba(0,0,0,0.45);
        z-index: 1000;
    }
    #dialogShape.shape-popup-mode .dialog__scrim {
        display: none;
    }
    #dialogShape.shape-popup-mode .dialog__container--shape {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 90vw;
        max-width: 300px;
        pointer-events: auto;
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.93);
        transition: opacity 0.25s ease, transform 0.25s ease;
        background: var(--surface);
        border-radius: 14px;
        padding: 18px 16px;
        box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    }
    #dialogShape.shape-popup-mode.shape-popup-visible .dialog__container--shape {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    .shape-popup__close {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 4px;
        right: 4px;
        width: 28px;
        height: 28px;
        border: none;
        background: transparent;
        font-size: 1.35rem;
        line-height: 1;
        cursor: pointer;
        color: #666;
        border-radius: 50%;
        z-index: 2;
    }
    .shape-popup__close:active { background: #e0e0e0; }
    .shape-popup__row input[type="number"],
    .shape-popup__row input[type="text"] {
        width: 54px;
        padding: 7px 6px;
        font-size: 0.85rem;
    }
    .shape-popup__row { gap: 5px; margin-bottom: 10px; }
    .shape-popup__canvas-wrap canvas {
        width: 200px;
        height: 200px;
    }
    .shape-popup__actions { padding-top: 8px; gap: 6px; }
    .shape-popup__apply { padding: 6px 14px; font-size: 0.8rem; }
    .shape-popup__delete { padding: 6px 14px; font-size: 0.8rem; }
}
/* Hide btn-group when thumb shown (existing) */
.item-name-wrap:has(.ket-thumb) .btn-group { display: none; }
/* Adjust padding when shape badge is shown alongside upload btn */
.item-name-wrap:has(.shape-badge) .item-keterangan { padding-right: 120px; }
.item-qty { width: 100%; text-align: center; }
.item-sub-qty { width: 100%; text-align: center; }
.data-table__th--center { text-align: center; }
.data-table__th--right { text-align: right; }
.item-subtotal { text-align: right; white-space: nowrap; font-weight: 500; font-size: 0.99rem; line-height: 1.2; font-family: var(--md-font-family); }
/* Disabled fields when nama barang kosong */
#itemsTable .item-harga:disabled,
#itemsTable .item-satuan:disabled,
#itemsTable .item-qty:disabled,
#itemsTable .item-keterangan:disabled {
    opacity: 0.4;
    background: #f0f0f0;
    cursor: not-allowed;
}
#itemsTable .btn-shape:disabled,
#itemsTable .btn-design:disabled,
#itemsTable .item-upload-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
#itemsTable .item-img-pick.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}
/* ===== END KARPET LAYOUT ===== */

/* Smooth theme transition — only active during toggle (class added/removed by JS) */
@media (prefers-reduced-motion: no-preference) {
    
}

/* ===== LIGHT MODE GLASS ===== */
/* Ambient glow blobs behind glass cards in light mode */
      .form-container::before { display: none; }

/* Card base — all cards in light mode */
.card, .dialog__container, .preview-card,
#acuanCard, .acuan-form-card, .dropdown__menu,
.acuan-minicard, .acuan-form {
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1); /* REVERTABLE: hapus inset glow glass (sebelumnya + inset 0 1px 0 .5 / inset 0 -1px 0 .1) */
}
/* Restore absolute positioning for dropdown menus (needed for layout) */
.dropdown__menu { position: absolute; }

/* Positioned base */
.card, .dialog__container, .preview-card,
#acuanCard, .acuan-form-card,
.acuan-minicard, .acuan-form {
    position: relative;
}

/* Database & data-dialog containers: matte white, no glass */
#dialogDatabaseCustomers .dialog__container--large,
#dialogDatabaseItems .dialog__container--large,
#dialogDatabaseDrafts .dialog__container--large,
#dialogAcuanDb .dialog__container--acuan {
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--line);
}
html[data-theme="dark"] #dialogDatabaseCustomers .dialog__container--large,
html[data-theme="dark"] #dialogDatabaseItems .dialog__container--large,
html[data-theme="dark"] #dialogDatabaseDrafts .dialog__container--large,
html[data-theme="dark"] #dialogAcuanDb .dialog__container--acuan {
    background: var(--surface);
    border: 1px solid var(--line);
}
/* Light mode: item-table inputs base (cascade after line ~591) */
.item-name-input,
.item-harga,
.item-satuan,
.item-keterangan,
.item-qty {
    background: var(--surface-soft);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.item-name-input:focus,
.item-harga:focus,
.item-satuan:focus,
.item-keterangan:focus,
.item-qty:focus,
.item-kota:focus,
.item-indopaket:focus,
.item-indojaya:focus,
.item-sub-name-input:focus,
.item-sub-qty:focus,
.item-sub-satuan:focus {
    background: rgba(255,255,255,0.25);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
/* ============================================
   DARK MODE (quotation only)
   Toggle via [data-theme="dark"] on <html>
   ============================================ */
html[data-theme="dark"] {
    --bg: #0f0f16;
    --ink: #e8eaed;
    --muted: #9aa0a6;
    --line: rgba(255,255,255,0.08);
    --surface: #1a1a2e;
    --surface-soft: rgba(255,255,255,0.04);
    --md-surface: transparent;
    --md-surface-variant: rgba(255,255,255,0.03);
    --md-surface-container: rgba(255,255,255,0.02);
    --md-surface-container-low: rgba(255,255,255,0.04);
    --md-surface-container-high: rgba(255,255,255,0.06);
    --md-on-surface: #e8eaed;
    --md-on-surface-variant: #9aa0a6;
    --md-outline: rgba(255,255,255,0.1);
    --md-outline-variant: rgba(255,255,255,0.06);
    --md-primary-container: rgba(43,87,154,0.25);
    --md-on-primary-container: #8ab4f8;
    --md-error-container: rgba(217,48,37,0.2);
    --md-success-container: rgba(15,157,88,0.2);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-soft: 0 2px 6px rgba(0,0,0,0.2);
}

/* Ambient glow blobs behind glass cards in dark mode */
      html[data-theme="dark"] .form-container::before { display: none; }

/* Card base — all cards in dark mode */
html[data-theme="dark"] .card,
html[data-theme="dark"] .dialog__container,
html[data-theme="dark"] .preview-card,
html[data-theme="dark"] #acuanCard,
html[data-theme="dark"] .acuan-form-card,
html[data-theme="dark"] .dropdown__menu,
html[data-theme="dark"] .acuan-minicard,
html[data-theme="dark"] .acuan-form {
    background: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--line);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* Top bar dark mode */
html[data-theme="dark"] .top-bar {
    background: var(--surface) !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

html[data-theme="dark"] .top-bar__icon { color: #6b9bd2; }
html[data-theme="dark"] .top-bar__title { color: var(--ink); }

/* Footer dark mode */
html[data-theme="dark"] .footer {
    background: var(--surface);
    border-top: 1px solid var(--line);
    color: var(--muted);
}

/* Tonal button in top bar */
html[data-theme="dark"] .tonal-button {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
    color: var(--ink);
}
html[data-theme="dark"] .tonal-button:hover {
    background: rgba(255,255,255,0.12);
}

/* Dialog header in dark mode — solid blurred background so table scroll doesn't overlap text */
html[data-theme="dark"] .dialog__header {
    background: rgba(20,20,30,0.92);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Dropdown menu (Database) dark mode — blurred dark background */
html[data-theme="dark"] .dropdown__menu {
    background: rgba(15,15,22,0.92);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-color: rgba(255,255,255,0.08);
}

/* Table header in database dialogs — solid background so scroll doesn't bleed through */
html[data-theme="dark"] .dialog__table-container .data-table th {
    background: rgba(20,20,30,0.92);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom-color: rgba(255,255,255,0.08);
}
/* Mobile: thead th has inline background var(--surface) which is transparent in dark mode */
@media (max-width: 640px) {
    html[data-theme="dark"] .dialog__table-container .data-table thead th {
        background: rgba(20,20,30,0.95) !important;
    }
}

/* Icon button */
html[data-theme="dark"] .icon-button {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
    color: var(--muted);
}
html[data-theme="dark"] .icon-button:hover {
    background: rgba(255,255,255,0.15);
    color: var(--ink);
}

/* Dropdown items */
html[data-theme="dark"] .dropdown__item:hover { background: rgba(255,255,255,0.1); }
html[data-theme="dark"] .dropdown__item i { color: var(--muted); }

/* Input / select / textarea */
html[data-theme="dark"] .form-field__input,
html[data-theme="dark"] .item-name-input,
html[data-theme="dark"] .item-harga,
html[data-theme="dark"] .item-satuan,
html[data-theme="dark"] .item-keterangan,
html[data-theme="dark"] .item-qty,
html[data-theme="dark"] .db-search,
html[data-theme="dark"] .img-gallery-search,
html[data-theme="dark"] select.form-field__input,
html[data-theme="dark"] .img-gallery-searchbox,
html[data-theme="dark"] .shape-popup__row input[type="number"],
html[data-theme="dark"] .shape-popup__row input[type="text"] {
    background: rgba(255,255,255,0.08) !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: var(--ink) !important;
    box-shadow: none; /* REVERTABLE: hapus glow glass dark (sebelumnya inset 0 1px 0 rgba(255,255,255,0.06)) */
}
html[data-theme="dark"] .form-field__input:focus,
html[data-theme="dark"] .item-name-input:focus,
html[data-theme="dark"] .item-harga:focus,
html[data-theme="dark"] .item-satuan:focus,
html[data-theme="dark"] .item-keterangan:focus,
html[data-theme="dark"] .item-qty:focus,
html[data-theme="dark"] .item-kota:focus,
html[data-theme="dark"] .item-indopaket:focus,
html[data-theme="dark"] .item-indojaya:focus,
html[data-theme="dark"] .item-sub-name-input:focus,
html[data-theme="dark"] .item-sub-qty:focus,
html[data-theme="dark"] .item-sub-satuan:focus,
html[data-theme="dark"] .db-search:focus,
html[data-theme="dark"] .img-gallery-searchbox:focus-within {
    border-color: var(--md-primary) !important;
    background: var(--surface-soft);
    box-shadow: 0 0 0 3px rgba(43,87,154,0.25);
}
html[data-theme="dark"] .img-gallery-searchbox .img-gallery-search {
    background: transparent !important;
    color: var(--ink) !important;
}
html[data-theme="dark"] .form-field__input::placeholder,
html[data-theme="dark"] .note-editor:empty::before,
html[data-theme="dark"] .db-search::placeholder { color: var(--muted) !important; }

/* Note editor */
html[data-theme="dark"] .note-editor { color: var(--ink); }

/* Acuan disabled select */
html[data-theme="dark"] #acuanCard select.form-field__input:disabled {
    background: rgba(255,255,255,0.04) !important;
    color: var(--muted) !important;
    opacity: 0.6;
}

/* Switch (TTD) */
html[data-theme="dark"] .switch { background: rgba(255,255,255,0.15); }
html[data-theme="dark"] .switch__label { color: var(--muted); }
html[data-theme="dark"] .switch__thumb { background: #e8eaed; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
html[data-theme="dark"] .switch-input:checked + .switch { background: var(--md-primary); }
html[data-theme="dark"] .switch__icon { fill: var(--muted) !important; }

/* Toggle (PPN/Ongkir) */
html[data-theme="dark"] .note-toggle { background: var(--surface-soft); border-color: var(--line); }
html[data-theme="dark"] .note-toggle__opt.is-active { color: #fff; }
html[data-theme="dark"] .note-toggle__slider {
    background: var(--md-primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Checkbox */
html[data-theme="dark"] .note-check__box {
    border-color: rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.06);
}
html[data-theme="dark"] .note-check input:checked + .note-check__box {
    background: var(--md-primary);
    border-color: var(--md-primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Buttons — generate */
html[data-theme="dark"] .generate-btn-circle {
    background: var(--md-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
html[data-theme="dark"] .generate-btn-circle:disabled {
    background: var(--surface-soft);
    color: var(--muted);
}

/* Data table */
html[data-theme="dark"] .data-table__th {
    background: rgba(255,255,255,0.04);
    border-bottom-color: rgba(255,255,255,0.08);
    color: var(--muted);
}
html[data-theme="dark"] .data-table__td {
    border-bottom-color: rgba(255,255,255,0.06);
    color: var(--ink);
}
html[data-theme="dark"] .data-table__body tr:hover td { background: rgba(255,255,255,0.04); }
html[data-theme="dark"] .data-table__body tr.row-selected { background: rgba(43,87,154,0.15); }
html[data-theme="dark"] .data-table__body tr.row-selected:hover { background: rgba(43,87,154,0.25); }
html[data-theme="dark"] .empty-hint { color: var(--muted); }

/* DB action buttons */
html[data-theme="dark"] .data-table__action-btn--edit { background: rgba(43,87,154,0.2); color: #8ab4f8; }
html[data-theme="dark"] .data-table__action-btn--edit:hover { background: rgba(43,87,154,0.35); }
html[data-theme="dark"] .data-table__action-btn--delete { background: rgba(217,48,37,0.15); color: #f28b82; }
html[data-theme="dark"] .data-table__action-btn--delete:hover { background: rgba(217,48,37,0.25); }
html[data-theme="dark"] .data-table__action-btn--save { background: rgba(43,87,154,0.2); color: #8ab4f8; }
html[data-theme="dark"] .data-table__action-btn--save:hover { background: rgba(43,87,154,0.35); }

/* Item action buttons */
html[data-theme="dark"] .data-table__action-btn--delete { background: rgba(217,48,37,0.15); color: #f28b82; }
html[data-theme="dark"] .data-table__action-btn--delete:hover { background: rgba(217,48,37,0.25); }
html[data-theme="dark"] .data-table__action-btn--pdf { background: rgba(43,87,154,0.15); color: #8ab4f8; }
html[data-theme="dark"] .data-table__action-btn--pdf:hover { background: rgba(43,87,154,0.25); }

/* Image gallery */
html[data-theme="dark"] .img-gallery__thumb,
html[data-theme="dark"] .img-gallery__item img {
    background: rgba(255,255,255,0.04);
}
html[data-theme="dark"] .img-gallery__item {
    background: var(--surface-soft);
    border-color: var(--line);
}
html[data-theme="dark"] .img-gallery__item:hover { border-color: var(--md-primary); background: rgba(255,255,255,0.08); }
html[data-theme="dark"] .img-gallery__item.is-selected {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(43,87,154,0.25);
    background: rgba(43,87,154,0.15);
}
html[data-theme="dark"] .img-gallery__caption { color: var(--ink); }
html[data-theme="dark"] .img-gallery-empty { color: var(--muted); }

/* Upload pill */
html[data-theme="dark"] .img-upload-pill {
    background: var(--surface-soft);
    border-color: var(--line);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
html[data-theme="dark"] .img-upload-pill:hover { border-color: var(--md-primary); color: #8ab4f8; }
html[data-theme="dark"] .img-upload-pill.is-uploaded {
    background: var(--md-primary);
    border-color: var(--md-primary);
    color: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Preview */
html[data-theme="dark"] .preview-card { border-color: rgba(255,255,255,0.08); }
html[data-theme="dark"] .preview-frame { background: #1a1a2e; border-color: rgba(255,255,255,0.08); }
html[data-theme="dark"] .preview-pages .preview-page {
    background: #1a1a2e;
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

/* Autocomplete */
html[data-theme="dark"] .autocomplete-list {
    background: rgba(30,30,45,0.95);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
html[data-theme="dark"] .autocomplete-item { color: var(--ink); }
html[data-theme="dark"] .autocomplete-item:hover,
html[data-theme="dark"] .autocomplete-item.is-active {
    background: rgba(43,87,154,0.25);
    color: #8ab4f8;
}

/* Item suggestion */
html[data-theme="dark"] .item-suggest.is-floating {
    background: rgba(30,30,45,0.95);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* Item cell image */
html[data-theme="dark"] .cell-img { background: var(--surface-soft); }

/* Item upload button */
html[data-theme="dark"] .item-upload-btn { background: rgba(43,87,154,0.2); color: #8ab4f8; }
html[data-theme="dark"] .item-upload-btn:hover { background: rgba(43,87,154,0.35); }

/* Ket thumb */
html[data-theme="dark"] .ket-thumb { background: rgba(255,255,255,0.04); }
html[data-theme="dark"] .ket-thumb__x { background: rgba(0,0,0,0.6); color: #fff; }
html[data-theme="dark"] .ket-thumb__x:hover { background: rgba(0,0,0,0.8); }

/* Design / shape buttons */
html[data-theme="dark"] .btn-design { background: var(--surface-soft); border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] .btn-design:hover { border-color: var(--md-primary); }
html[data-theme="dark"] .btn-design.is-loaded { background: rgba(15,157,88,0.15); border-color: #2e7d4f; color: #81c995; }
html[data-theme="dark"] .btn-shape { background: var(--surface-soft); border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] .btn-shape:hover { border-color: var(--md-primary); }
html[data-theme="dark"] .btn-shape--active { border-color: #28a745; color: #28a745; }
html[data-theme="dark"] .shape-badge { background: rgba(43,87,154,0.2); border-color: var(--md-primary); color: #8ab4f8; }
html[data-theme="dark"] .shape-badge__x:hover { background: rgba(255,255,255,0.1); }

/* Shape popup */
html[data-theme="dark"] .shape-popup__row input[type="number"],
html[data-theme="dark"] .shape-popup__row input[type="text"] {
    background: rgba(255,255,255,0.08) !important;
    border-color: rgba(255,255,255,0.12);
    color: #e0e0e0;
}
html[data-theme="dark"] .shape-popup__row input[type="number"]:focus,
html[data-theme="dark"] .shape-popup__row input[type="text"]:focus {
    background: rgba(255,255,255,0.15) !important;
    border-color: #8ab4f8;
}
html[data-theme="dark"] .shape-popup__canvas-wrap canvas { background: #1e1e2e; }
html[data-theme="dark"] .shape-popup__delete {
    border-color: #dc3545;
    background: rgba(220,53,69,0.1);
    color: #f28b82;
}
html[data-theme="dark"] .shape-popup__delete:hover { background: #dc3545; color: #fff; }

/* shape popup container */
html[data-theme="dark"] #dialogShape .dialog__container--shape {
    background: rgba(30,30,45,0.96);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
html[data-theme="dark"] .shape-popup__close { color: var(--muted); }
html[data-theme="dark"] .shape-popup__close:active { background: rgba(255,255,255,0.1); }

/* Dialog scrim */
html[data-theme="dark"] .dialog__scrim { background: rgba(0,0,0,0.65); }

/* Disabled fields */
html[data-theme="dark"] #itemsTable .item-harga:disabled,
html[data-theme="dark"] #itemsTable .item-satuan:disabled,
html[data-theme="dark"] #itemsTable .item-qty:disabled,
html[data-theme="dark"] #itemsTable .item-keterangan:disabled {
    background: rgba(255,255,255,0.04) !important;
    opacity: 0.4;
}


/* Acuan */
html[data-theme="dark"] .acuan-db__tipe { border-bottom-color: rgba(255,255,255,0.06); }
html[data-theme="dark"] .acuan-db__warna-harga { color: var(--muted); }
html[data-theme="dark"] .acuan-form { background: var(--surface-soft); }
html[data-theme="dark"] .acuan-form-card { background: var(--surface); border-color: var(--line); border-radius: 20px; }

/* Table borders */
html[data-theme="dark"] #itemsTable tr { border-bottom-color: rgba(255,255,255,0.06); }
html[data-theme="dark"] .item-row--indomaret-sub.is-group-last > td,
html[data-theme="dark"] .item-row--indomaret.is-group-last > td { border-bottom-color: rgba(255,255,255,0.2); }
html[data-theme="dark"] .acuan-minicard {
    border-color: rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.06);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
html[data-theme="dark"] .acuan-minicard__tipe { color: #fff; }

/* Card shadow overrides */
html[data-theme="dark"] .card { box-shadow: 0 8px 32px rgba(0,0,0,0.3); } /* REVERTABLE: hapus inset glow glass dark */

/* Note options locked state */
html[data-theme="dark"] .note-editor.is-locked { background: var(--surface-soft); }

/* Tonal button danger */
html[data-theme="dark"] .tonal-button--danger { color: #f28b82; }
html[data-theme="dark"] .tonal-button--danger:hover { background: rgba(217,48,37,0.15); }

/* Image overlay */
html[data-theme="dark"] .item-img-pick__overlay { background: rgba(0,0,0,0.6); color: #fff; }

/* Note card header actions fix */
html[data-theme="dark"] #cardNote .tonal-button { background: var(--surface-soft); }


/* ============================================
   THEME SWITCH — Dark/Light toggle
   ============================================ */
.theme-switch {
  font-size: 17px;
  position: relative;
  display: inline-block;
  width: 4em;
  height: 2.2em;
  border-radius: 30px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.theme-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #2a2a2a;
  transition: 0.4s;
  border-radius: 30px;
  overflow: hidden;
}
.theme-switch .slider:before {
  position: absolute;
  content: "";
  height: 1.2em;
  width: 1.2em;
  border-radius: 20px;
  left: 0.5em;
  bottom: 0.5em;
  transition: 0.4s;
  transition-timing-function: cubic-bezier(0.81, -0.04, 0.38, 1.5);
  box-shadow: inset 8px -4px 0px 0px #fff;
  z-index: 1;
}
.theme-switch input:checked + .slider {
  background-color: #00a6ff;
}
.theme-switch input:checked + .slider:before {
  transform: translateX(1.8em);
  box-shadow: inset 15px -4px 0px 15px #ffcf48;
}
.theme-switch .star {
  background-color: #fff;
  border-radius: 50%;
  position: absolute;
  width: 5px;
  transition: all 0.4s;
  height: 5px;
  z-index: 1;
}
.theme-switch .star_1 { left: 2.5em; top: 0.5em; }
.theme-switch .star_2 { left: 2.2em; top: 1.2em; }
.theme-switch .star_3 { left: 3em; top: 0.9em; }
.theme-switch input:checked ~ .slider .star { opacity: 0; }
.theme-switch .cloud {
  width: 3.5em;
  position: absolute;
  bottom: -1.4em;
  left: -1.1em;
  opacity: 0;
  transition: all 0.4s;
  z-index: 1;
}
.theme-switch input:checked ~ .slider .cloud { opacity: 1; }


/* Desktop mode — compact top bar buttons */
@media (min-width: 641px) {
    .theme-switch {
        font-size: 12px;
    }
    #btnDatabase {
        min-height: 30px !important;
        padding: 0 17px !important;
        font-size: 0.78rem !important;
        gap: 5px !important;
    }
    #btnDatabase .fa-database {
        display: none !important;
    }
    #btnDatabase .fa-caret-down {
        display: none !important;
    }
    .top-bar__trailing .dropdown__menu {
        min-width: 120px;
        padding: 3px;
    }
    .top-bar__trailing .dropdown__item {
        padding: 6px 10px;
        font-size: 0.75rem;
        gap: 6px;
        border-radius: 8px;
    }
    .top-bar__trailing .dropdown__item i {
        font-size: 0.8rem;
        width: 16px;
    }
}

/* ===== PIN LOCK OVERLAY ===== */
/* Full privacy: the whole app is invisible while the device is locked.
   #pinLock (the lock card) is the only visible content until auth succeeds. */
body.is-locked > :not(#pinLock) { visibility: hidden; }
.pin-lock {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.pin-lock[hidden] {
    display: none !important;
}
body.pin-locked { overflow: hidden; }
.pin-lock__scrim {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.pin-lock__card {
    position: relative;
    z-index: 1;
    width: min(320px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 28px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    text-align: center;
    animation: pin-pop .18s ease-out;
}
@keyframes pin-pop {
    from { opacity: 0; transform: scale(.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.pin-lock__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--md-primary-container, #dce6f4);
    color: var(--md-primary, #2B579A);
    font-size: 22px;
}
.pin-lock__title {
    margin: 0 0 18px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
}
.pin-lock__inputs {
    position: relative;
    display: flex;
    justify-content: center;
    gap: 14px;
}
.pin-lock__field {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    border: 0;
    padding: 0;
    margin: 0;
    z-index: 2;
    cursor: default;
    -webkit-text-security: none;
}
.pin-box {
    width: 52px;
    height: 60px;
    text-align: center;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--ink);
    background: var(--surface-soft);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    outline: none;
    caret-color: var(--md-primary);
    -webkit-text-security: disc;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.pin-box:focus {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(43, 87, 154, 0.16);
}
.pin-lock__msg {
    margin-top: 16px;
    min-height: 18px;
    font-size: .82rem;
    color: var(--muted);
}
.pin-lock__msg.is-error {
    color: #d93025;
    font-weight: 600;
}
