:root {
    --bg: #f7efe3;
    --bg-2: #efe2cf;
    --surface: #fffdf8;
    --surface-2: #fbf3e7;
    --ink: #3a2b1f;
    --ink-soft: #7a6a58;
    --accent: #7c4a24;
    --accent-2: #a9713c;
    --accent-3: #c68b4e;
    --border: #e8dcc9;
    --border-soft: #f0e7d8;
    --danger: #b2402c;
    --danger-bg: #fbe9e4;
    --danger-border: #f2cdc3;
    --success: #4f7a44;
    --success-bg: #eaf2e3;
    --success-border: #d3e4c8;
    --warn: #a96f1b;
    --warn-bg: #fdf3dd;
    --warn-border: #f3dfae;
    --shadow: 0 10px 30px rgba(96, 63, 30, .08);
    --shadow-lg: 0 20px 50px rgba(96, 63, 30, .16);
    --radius: 16px;
    --radius-sm: 10px;
    --grad-primary: linear-gradient(135deg, #7c4a24, #a9713c);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(900px 500px at 8% -10%, rgba(198, 139, 78, .16), transparent 60%),
        radial-gradient(800px 500px at 100% 0%, rgba(169, 113, 60, .14), transparent 55%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

h1, h2, h3 { margin: 0; font-weight: 700; }
h2 { font-size: 1.45rem; letter-spacing: -.01em; }
h3 { font-size: 1.12rem; }

.muted { color: var(--ink-soft); }
.strong { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.text-danger { color: var(--danger); }

/* ---------------------------------- Header ---------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 253, 248, .82);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-bottom: 1px solid var(--border-soft);
}

.header-inner {
    padding-top: 14px;
    padding-bottom: 12px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.unit-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.unit-controls label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.unit-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.unit-controls select {
    width: auto;
    min-width: 170px;
    padding: 8px 10px;
    font-size: .88rem;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--grad-primary);
    display: grid;
    place-items: center;
    font-size: 22px;
    box-shadow: 0 6px 16px rgba(124, 74, 36, .28);
}

.brand-text h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.28rem;
    letter-spacing: .01em;
    line-height: 1.1;
}

.brand-text p {
    margin: 2px 0 0;
    font-size: .8rem;
    color: var(--ink-soft);
}

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

.tab {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-soft);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    padding: 9px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: all .16s ease;
}

.tab:hover { background: var(--surface-2); color: var(--ink); }

.tab.is-active {
    background: var(--grad-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(124, 74, 36, .24);
}

/* ---------------------------------- Panels ---------------------------------- */
.panel { display: none; padding: 30px 0 60px; animation: fade .25s ease; }
.panel.is-active { display: block; }

@keyframes fade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.section-head p { margin: 4px 0 0; font-size: .9rem; }

.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------- Cards ---------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.02rem;
    margin-bottom: 14px;
}

/* ---------------------------------- Filter bar ---------------------------------- */
.filter-bar { margin-bottom: 20px; padding: 18px 20px; }

.filter-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 12px;
}

.filter-fields {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.filter-fields .field { flex: 0 1 200px; margin-bottom: 0; }

.filter-actions {
    display: flex;
    gap: 8px;
    padding-bottom: 1px;
}

.filter-actions .btn { white-space: nowrap; }

.filter-hint { margin: 10px 0 0; font-size: .82rem; }

/* ---------------------------------- Stats ---------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform .16s ease, box-shadow .16s ease;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stat-icon { font-size: 1.4rem; margin-bottom: 10px; }
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 800; margin-top: 4px; letter-spacing: -.02em; }

.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}

/* Anak grid default punya min-width:auto — tabel lebar di dalamnya bisa
   memaksa seluruh kolom melebar (bikin overflow di layar kecil). */
.dash-grid > * { min-width: 0; }

@media (max-width: 760px) {
    .dash-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------- Alerts ---------------------------------- */
.alert-card { border-left: 4px solid var(--danger); }
.ok-card { border-left: 4px solid var(--success); }

.alert-list, .recent-list { list-style: none; margin: 0; padding: 0; }

.alert-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-soft);
    flex-wrap: wrap;
}

.alert-list li:last-child { border-bottom: none; }

.alert-item-main { display: flex; flex-direction: column; gap: 1px; }
.alert-item-main .muted { font-size: .82rem; }

.ok-text { margin: 6px 0 0; }

.recent-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-soft);
    flex-wrap: wrap;
}

.recent-list li:last-child { border-bottom: none; }
.recent-main { display: flex; flex-direction: column; gap: 1px; }
.recent-main .muted { font-size: .82rem; }
.recent-meta { font-size: .85rem; color: var(--ink-soft); }

/* ---------------------------------- Badges ---------------------------------- */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-neutral { background: #f0e9dd; color: var(--ink-soft); }

.stok-awal-row { background: #fbf6ee; }
.stok-awal-row td { border-bottom: 1px solid var(--border); }

/* Baris riwayat yang bisa diklik -> langsung ke transaksinya */
.riwayat-clickable { cursor: pointer; }
.riwayat-clickable:hover { background: #f6eee1; }

/* Sorotan singkat saat dibuka dari riwayat */
@keyframes trxFlash {
    0%   { background: #fdf0d5; box-shadow: inset 4px 0 0 var(--accent-2); }
    60%  { background: #fdf0d5; box-shadow: inset 4px 0 0 var(--accent-2); }
    100% { background: transparent; box-shadow: inset 4px 0 0 transparent; }
}

tr.trx-flash > td { animation: trxFlash 2.6s ease-out; }

.goto-note {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: .88rem;
    color: var(--warn);
    font-weight: 600;
}

.unit-context {
    margin: 0 0 12px;
    font-size: .85rem;
    color: var(--ink-soft);
}

.unit-context strong { color: var(--ink); }

.unit-list {
    margin-top: 18px;
    border-top: 1px solid var(--border-soft);
    padding-top: 8px;
}

.unit-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
    flex-wrap: wrap;
}

.unit-list-item:last-child { border-bottom: none; }
.unit-name { font-weight: 600; }
.unit-actions { display: flex; gap: 6px; }

/* ---------------------------------- Import ---------------------------------- */
.import-result {
    margin: 4px 0 12px;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: .87rem;
}

.import-result.is-hidden { display: none; }
.import-result.is-error { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger); }
.import-result.is-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success); }

.import-error-title { font-weight: 700; margin: 0 0 6px; }
.import-error-list { margin: 0; padding-left: 18px; max-height: 220px; overflow-y: auto; }
.import-error-list li { margin-bottom: 3px; }

.unit-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    font-size: .78rem;
    color: var(--ink-soft);
}

/* ---------------------------------- Tables ---------------------------------- */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }

thead th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-soft);
    font-weight: 700;
    padding: 13px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbf6ee; }

table.compact tbody td { padding: 11px 14px; }

/* ---------------------------------- Buttons ---------------------------------- */
.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    padding: 10px 16px;
    cursor: pointer;
    transition: all .16s ease;
}

.btn-primary {
    background: var(--grad-primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(124, 74, 36, .24);
}

.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--ink);
}

.btn-ghost:hover { background: var(--surface-2); }

.btn-sm { padding: 6px 11px; font-size: .82rem; border-radius: 8px; }

.btn-danger-sm {
    background: var(--danger-bg);
    color: var(--danger);
}

.btn-danger-sm:hover { background: #f5d8d0; }

.btn-block { width: 100%; margin-top: 6px; }

/* ---------------------------------- Forms ---------------------------------- */
.field { margin-bottom: 14px; }

.field label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 6px;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

@media (max-width: 520px) {
    .field-row { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    font: inherit;
    font-size: .92rem;
    color: var(--ink);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(169, 113, 60, .15);
}

/* ---------------------------------- Menu cards ---------------------------------- */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}

.menu-card { display: flex; flex-direction: column; gap: 16px; }

.menu-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.menu-card-head h3 { font-family: Georgia, 'Times New Roman', serif; font-size: 1.22rem; }
.menu-price { color: var(--accent-2); font-weight: 700; font-size: 1.05rem; margin-top: 2px; }
.menu-actions { display: flex; gap: 6px; }

.resep-box { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 12px 14px; }
.resep-title { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); font-weight: 700; margin-bottom: 8px; }

.resep-list { list-style: none; margin: 0; padding: 0; }
.resep-list li { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: .88rem; }
.resep-list li .muted { flex: 1; }
.resep-cost { font-weight: 600; font-variant-numeric: tabular-nums; }

.hpp-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hpp-metric { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.hpp-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); font-weight: 700; }
.hpp-value { font-weight: 800; font-size: 1.05rem; margin-top: 2px; letter-spacing: -.01em; }

.margin-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.margin-fill { height: 100%; background: var(--grad-primary); border-radius: 999px; transition: width .4s ease; }

/* ---------------------------------- Produksi ---------------------------------- */
.produksi-grid { align-items: start; }

.produksi-preview {
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin: 4px 0 16px;
    background: var(--surface-2);
}

.produksi-preview.is-empty { text-align: center; }

.preview-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    margin-bottom: 10px;
}

.preview-total .big { font-size: 1.2rem; font-weight: 800; }

.preview-list { list-style: none; margin: 0 0 4px; padding: 0; }
.preview-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    font-size: .87rem;
    border-bottom: 1px solid var(--border-soft);
}
.preview-list li:last-child { border-bottom: none; }
.preview-list .short { color: var(--danger); font-weight: 600; }

/* ---------------------------------- Recipe editor ---------------------------------- */
.resep-editor { margin: 4px 0 8px; }

.resep-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.resep-editor-head label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.recipe-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.recipe-row select { flex: 1.4; }
.recipe-row input { flex: 1; }
.recipe-row .r-satuan { min-width: 34px; text-align: center; font-size: .82rem; color: var(--ink-soft); }

.r-remove {
    appearance: none;
    border: none;
    background: var(--danger-bg);
    color: var(--danger);
    width: 32px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
    flex-shrink: 0;
}

.r-remove:hover { background: #f5d8d0; }

/* ---------------------------------- Modal ---------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.is-open { display: flex; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(58, 43, 31, .45);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 460px;
    padding: 22px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn .2s ease;
}

.modal-card-wide { max-width: 560px; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: none; }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-close {
    appearance: none;
    border: none;
    background: var(--surface-2);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--ink-soft);
    font-size: .9rem;
}

.modal-close:hover { background: var(--border-soft); }

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* ---------------------------------- Toast ---------------------------------- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink);
    color: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: .9rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: all .25s ease;
    z-index: 200;
    max-width: min(90vw, 520px);
    text-align: center;
}

.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: var(--danger); }
.toast.is-success { background: var(--success); }

/* ---------------------------------- Misc ---------------------------------- */
.empty-hint {
    margin: 6px 0;
    color: var(--ink-soft);
    font-size: .92rem;
    text-align: center;
    padding: 20px 0;
}

/* ---------------------------------- Auth (login / setup) ---------------------------------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-wrap { width: 100%; max-width: 420px; }

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-lg);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-soft);
}

.auth-brand h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.22rem;
    line-height: 1.1;
}

.auth-brand p { margin: 2px 0 0; font-size: .8rem; color: var(--ink-soft); }

.auth-card h2 { font-size: 1.12rem; margin-bottom: 4px; }
.auth-note { font-size: .86rem; margin: 0 0 16px; }

.auth-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: .86rem;
    margin-bottom: 14px;
}

.auth-foot {
    text-align: center;
    font-size: .78rem;
    color: var(--ink-soft);
    margin-top: 16px;
}

/* ---------------------------------- Header: user box ---------------------------------- */
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 18px;
    border-left: 1px solid var(--border-soft);
}

.user-info { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; font-size: .9rem; }

.role-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.role-admin { background: #efe4d5; color: #7c4a24; }
.role-staf { background: #e7eee6; color: #4f7a44; }

.user-actions { display: flex; gap: 6px; }

@media (max-width: 820px) {
    .header-right { width: 100%; }
    .user-box { padding-left: 0; border-left: none; padding-top: 10px; border-top: 1px solid var(--border-soft); width: 100%; justify-content: space-between; }
}

/* ---------------------------------- Checkbox grid (unit per user) ---------------------------------- */
.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
}

.check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .88rem;
    cursor: pointer;
}

.check-item input { width: auto; }

/* ---------------------------------- List toolbar (pencarian) ---------------------------------- */
.list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 16px;
    margin-bottom: 18px;
}

.search-field {
    position: relative;
    flex: 1 1 320px;
    min-width: 240px;
    display: flex;
    align-items: center;
}

.search-field input[type="search"] {
    width: 100%;
    padding: 11px 40px 11px 40px;
    font-size: .93rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    -webkit-appearance: none;
    appearance: none;
}

.search-field input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

.search-field input[type="search"]:focus {
    outline: none;
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(169, 113, 60, .15);
}

.search-icon {
    position: absolute;
    left: 13px;
    font-size: .95rem;
    opacity: .6;
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 8px;
    appearance: none;
    border: none;
    background: var(--surface-2);
    color: var(--ink-soft);
    width: 26px;
    height: 26px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .8rem;
    line-height: 1;
    display: none;
}

.search-clear:hover { background: var(--border-soft); color: var(--ink); }
.search-field.has-value .search-clear { display: block; }

.list-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.list-toolbar-right select {
    width: auto;
    min-width: 170px;
    padding: 9px 10px;
    font-size: .88rem;
}

.list-count { font-size: .84rem; white-space: nowrap; }

/* ---------------------------------- Stock opname ---------------------------------- */
.input-hint {
    font-size: .84rem;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    margin-bottom: 12px;
}

.opname-list-wrap {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    background: #fff;
}

.opname-table { width: 100%; }
.opname-table thead th { position: sticky; top: 0; z-index: 2; }
.opname-table td { padding: 7px 10px; }
.opname-table .op-fisik,
.opname-table .op-ket {
    padding: 6px 8px;
    font-size: .86rem;
    width: 100%;
}
.opname-table .op-fisik { max-width: 110px; text-align: right; }
.opname-table .op-ket { max-width: 150px; }
.opname-table td .unit-pill { margin-left: 6px; font-size: .72rem; }

/* baris yang sudah diisi -> mudah terlihat */
.opname-table tr.op-filled { background: #f6fbef; }
.opname-table tr.op-filled td { border-bottom-color: var(--success-border); }

.opname-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.opname-actions .btn { white-space: nowrap; }

/* ---------------------------------- Peringatan stok kurang ---------------------------------- */
.toast.is-warning { background: #a96f1b; color: #fff; }

.stock-warn-note {
    margin: 8px 0 0;
    color: var(--warn);
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-weight: 600;
    font-size: .85rem;
}

/* ---------------------------------- Card title dengan aksi ---------------------------------- */
.card-title-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

/* ---------------------------------- Pengaturan: logo & kop ---------------------------------- */
.logo-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 90px;
    padding: 14px;
    margin-bottom: 14px;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

.logo-preview img { max-height: 76px; max-width: 100%; object-fit: contain; }

.kop-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #7c4a24, #a9713c);
    color: #fff;
}

.kop-preview .kop-logo {
    max-height: 46px;
    max-width: 110px;
    object-fit: contain;
    background: #fff;
    border-radius: 6px;
    padding: 3px;
}

.kop-nama { font-family: Georgia, 'Times New Roman', serif; font-size: 1.15rem; font-weight: 700; line-height: 1.15; }
.kop-sub { font-size: .78rem; opacity: .9; margin-top: 2px; }

/* ---------------------------------- Detail mutasi: penerima ---------------------------------- */
.penerima-box {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.penerima-box .field-row { margin-bottom: 10px; }
.penerima-box .field { margin-bottom: 0; }

/* ---------------------------------- Stok Masuk: perlebar kolom input ---------------------------------- */
/* Form input ditaruh lebar penuh di atas, tabel riwayat di bawah —
   supaya kolom isian lega dan tabel riwayat (8 kolom) juga terbaca. */
.stok-masuk-grid { grid-template-columns: 1fr; }

/* Form stok masuk: baris isian dibagi 2 kolom yang lega (bukan sempit) */
.stok-masuk-grid > .card:first-child {
    padding: 24px 26px;
}

.stok-masuk-grid .field-row {
    gap: 18px;
}

.stok-masuk-grid input[type="number"],
.stok-masuk-grid input[type="text"],
.stok-masuk-grid input[type="date"],
.stok-masuk-grid select {
    padding: 11px 13px;
    font-size: .95rem;
}

/* Batasi lebar baris isian agar tidak terlalu melar di layar sangat lebar */
.stok-masuk-grid #form-stok-masuk {
    max-width: 900px;
}

/* ---------------------------------- Dashboard: pemilih unit & rekap ---------------------------------- */
.dash-filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dash-filter label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.dash-filter select {
    width: auto;
    min-width: 200px;
    padding: 9px 12px;
    font-size: .9rem;
}

.stat-sub {
    font-size: .78rem;
    color: var(--ink-soft);
    margin-top: 4px;
}

/* kartu unit terpilih -> hanya satu set yang tampil */
.stat-card[hidden] { display: none; }

.margin-pill {
    display: inline-block;
    min-width: 56px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--ink-soft);
}

.margin-pill.is-good { background: var(--success-bg); color: var(--success); }
.margin-pill.is-neg { background: var(--danger-bg); color: var(--danger); }

/* baris rekap unit yang bukan pilihan -> redup */
.rekap-row.is-dim { opacity: .45; }
.rekap-row.is-active { background: #fbf6ee; }

/* ---------------------------------- Dashboard: preset periode ---------------------------------- */
.dash-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
}

.dash-presets .btn { white-space: nowrap; }
.dash-presets .btn.is-active {
    background: var(--grad-primary);
    color: #fff;
    border-color: transparent;
}

/* ---------------------------------- Zona berbahaya (reset transaksi) ---------------------------------- */
.danger-zone {
    margin-top: 18px;
    border: 1px solid var(--danger-border);
    background: #fffdfc;
}

.danger-zone .card-title span { color: var(--danger); }

.danger-list {
    list-style: none;
    margin: 0 0 16px;
    padding: 12px 14px;
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-sm);
    font-size: .86rem;
}

.danger-list li { margin-bottom: 6px; }
.danger-list li:last-child { margin-bottom: 0; }

.danger-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.danger-count {
    flex: 1 1 120px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.danger-count span { display: block; font-size: .74rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.danger-count strong { font-size: 1.15rem; }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: transparent;
}

.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }

.danger-zone code {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    padding: 1px 6px;
    font-size: .85rem;
    font-weight: 700;
}

/* ---------------------------------- Edit massal bahan baku ---------------------------------- */
.bulk-bar {
    margin-bottom: 14px;
    border-left: 4px solid var(--accent-2);
    background: #fffdf8;
}

.bulk-bar-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.bulk-apply {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: .86rem;
}

.bulk-apply label { font-weight: 600; color: var(--ink-soft); }
.bulk-apply select { width: auto; padding: 7px 9px; font-size: .85rem; }
.bulk-apply input { padding: 7px 9px; font-size: .85rem; }

.bulk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

/* input di dalam tabel saat mode edit */
#tabel-bahan td input.bulk-input {
    width: 100%;
    min-width: 90px;
    padding: 6px 8px;
    font-size: .87rem;
    border: 1px solid var(--accent-3);
    border-radius: 8px;
    background: #fffdf5;
}

#tabel-bahan td input.bulk-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(169, 113, 60, .18);
}

#tabel-bahan tr.is-changed { background: #fffaf0; }
#tabel-bahan tr.is-changed td { border-bottom-color: var(--accent-3); }

#tabel-bahan td.cell-stok .muted-note {
    display: block;
    font-size: .7rem;
    color: var(--ink-soft);
}

/* ---------------------------------- Input banyak baris (stok masuk & penjualan) ---------------------------------- */
.bulk-note {
    font-size: .83rem;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    margin-bottom: 14px;
    color: var(--ink-soft);
}

.entry-head {
    display: grid;
    grid-template-columns: 2fr .8fr 1fr 1.1fr 34px;
    gap: 8px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
    padding: 0 2px 6px;
}

.entry-head.entry-head-jual { grid-template-columns: 3fr .9fr 34px; }
.entry-head .num { text-align: right; }

.entry-row {
    display: grid;
    grid-template-columns: 2fr .8fr 1fr 1.1fr 34px;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.entry-row.entry-row-jual { grid-template-columns: 3fr .9fr 34px; }

.entry-row select,
.entry-row input {
    padding: 9px 10px;
    font-size: .88rem;
}

.entry-row input[type="number"] { text-align: right; }

.entry-del {
    appearance: none;
    border: none;
    background: var(--danger-bg);
    color: var(--danger);
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
}

.entry-del:hover { background: #f5d8d0; }

.entry-row.is-dup { background: #fff7e6; border-radius: 8px; }

.entry-total {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    margin-bottom: 8px;
}

.entry-total .big { font-size: 1.1rem; }

@media (max-width: 640px) {
    .entry-head { display: none; }
    .entry-row, .entry-row.entry-row-jual {
        grid-template-columns: 1fr 1fr;
        background: var(--surface-2);
        border: 1px solid var(--border-soft);
        border-radius: var(--radius-sm);
        padding: 10px;
    }
    .entry-row select { grid-column: 1 / -1; }
    .entry-del { grid-column: 2; justify-self: end; width: 44px; }
}

/* ---------------------------------- Alat bantu isi no. bukti ---------------------------------- */
.entry-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.entry-tools input {
    flex: 1 1 220px;
    min-width: 180px;
    padding: 9px 11px;
    font-size: .88rem;
}

.entry-tools .btn { white-space: nowrap; }

/* ---------------------------------- Log audit ---------------------------------- */
.badge-neutral { background: #f0e9dd; color: var(--ink-soft); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }

#tabel-audit td { vertical-align: top; }
#tabel-audit td:nth-child(4) { min-width: 200px; }
#tabel-audit td:nth-child(5) { min-width: 240px; }
