/* ============================================================
   Rajawali Studio — Patch Order System v3
   Design system: navy/blue, light surface, admin-grade density
   ============================================================ */

:root {
    /* --- Navy scale (sidebar, header, dark surfaces) --- */
    --navy-950: #08111f;
    --navy-900: #0d1c31;
    --navy-850: #122542;
    --navy-800: #17304f;
    --navy-700: #1f3d63;
    --navy-600: #2b4f7d;

    /* --- Blue accent scale --- */
    --blue-700: #1d4ed8;
    --blue-600: #2563eb;
    --blue-500: #3b82f6;
    --blue-400: #60a5fa;
    --blue-100: #dbeafe;
    --blue-50:  #eff6ff;

    /* --- Neutrals --- */
    --surface:      #f3f6fb;
    --surface-alt:  #eaf0f9;
    --card:         #ffffff;
    --border:       #e1e8f2;
    --border-soft:  #edf1f8;
    --text:         #101a2c;
    --text-muted:   #5b6b85;
    --text-faint:   #92a0b8;

    /* --- Semantic --- */
    --green:      #059669;
    --green-bg:   #e7f8f1;
    --red:        #dc2626;
    --red-bg:     #fdecec;
    --orange:     #d97706;
    --orange-bg:  #fef3e2;

    /* --- Shape / motion --- */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(16, 26, 44, 0.06);
    --shadow: 0 4px 16px rgba(16, 26, 44, 0.08);
    --shadow-lg: 0 12px 32px rgba(16, 26, 44, 0.14);
    --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

    --sidebar-w: 248px;
    --topbar-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--surface);
    color: var(--text);
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
}
h1, h2, h3, h4, h5 {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    color: var(--text);
    margin: 0 0 6px;
    letter-spacing: -0.01em;
    line-height: 1.25;
}
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
h4 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
p { margin: 0 0 10px; color: var(--text-muted); }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--surface-alt); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
::selection { background: var(--blue-100); }
:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; border-radius: 4px; }

/* ============================================================
   APP LAYOUT — sidebar + topbar + content
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(185deg, var(--navy-950), var(--navy-850) 75%);
    color: #dce6f5;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform 0.25s var(--ease);
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .logo-badge {
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(37,99,235,0.35);
}
.sidebar-brand .brand-name { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 15px; color: #fff; line-height: 1.2; }
.sidebar-brand .brand-tag { font-size: 10.5px; color: #8fa3c4; margin-top: 1px; }

.sidebar-role {
    margin: 14px 18px 6px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
}
.sidebar-role .who-name { color: #fff; font-weight: 600; display: block; }
.sidebar-role .who-role {
    display: inline-block; margin-top: 4px; font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--blue-400);
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 12px; }
.sidebar-nav .nav-section-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
    color: #6c81a5; margin: 16px 10px 6px; font-weight: 700;
}
.sidebar-nav .nav-section-label:first-child { margin-top: 4px; }
.sidebar-link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: #b9c8e2; font-size: 13.5px; font-weight: 500;
    margin-bottom: 2px; transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}
.sidebar-link .ic { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar-link.active {
    background: rgba(59,130,246,0.16);
    color: #fff;
    border-left-color: var(--blue-500);
    font-weight: 600;
}
.sidebar-foot { padding: 14px 18px 18px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-logout {
    display: flex; align-items: center; gap: 9px; width: 100%;
    background: rgba(220,38,38,0.14); color: #ff9d9d; border: 1px solid rgba(220,38,38,0.25);
    padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
    cursor: pointer; text-align: left;
}
.sidebar-logout:hover { background: rgba(220,38,38,0.24); text-decoration: none; }

.sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(8,17,31,0.55);
    z-index: 35; backdrop-filter: blur(1px);
}

.main-col { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    height: var(--topbar-h); background: var(--card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; position: sticky; top: 0; z-index: 20;
    gap: 14px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar h1 { font-size: 17px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hamburger {
    display: none; width: 38px; height: 38px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--card); cursor: pointer;
    align-items: center; justify-content: center; font-size: 18px; color: var(--text); flex-shrink: 0;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-pill {
    display: none; align-items: center; gap: 8px; background: var(--surface-alt);
    padding: 6px 12px 6px 6px; border-radius: 999px; font-size: 12.5px;
}
.topbar-pill .avatar {
    width: 26px; height: 26px; border-radius: 50%; background: var(--blue-600); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11.5px;
}

.content { padding: 24px; flex: 1; max-width: 1240px; width: 100%; margin: 0 auto; }

.page-footer {
    text-align: center; padding: 22px 24px 30px; font-size: 12px; color: var(--text-faint);
    max-width: 1240px; margin: 0 auto; width: 100%;
}
.page-footer a { color: var(--text-faint); }
.page-footer .foot-brand { color: var(--text-muted); font-weight: 600; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }
    .main-col { margin-left: 0; }
    .hamburger { display: flex; }
    .content { padding: 16px; }
    .topbar { padding: 0 14px; }
}
@media (max-width: 640px) {
    .row-end > .btn, .row-end > a.btn, .row-end > button.btn { width: 100%; flex: 1 1 100%; }
}
@media (min-width: 640px) { .topbar-pill { display: flex; } }

/* Small phones -- tighten spacing/type so cards, stat tiles and tables actually
   fit the viewport at 100% zoom instead of relying on the user pinch-zooming out. */
@media (max-width: 480px) {
    .content { padding: 12px; }
    h2 { font-size: 19px; }
    h3 { font-size: 15.5px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-box { padding: 12px; min-width: 0; }
    .stat-box .num { font-size: 20px; }
    .stat-box .label { font-size: 10px; }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .product-card { padding: 10px; min-width: 0; }
    table { min-width: 0; font-size: 12px; }
    th, td { padding: 8px; }
}

/* ============================================================
   PUBLIC (storefront) LAYOUT
   ============================================================ */
.public-header {
    background: linear-gradient(120deg, var(--navy-950), var(--navy-800));
    color: #fff; padding: 18px 20px;
    position: sticky; top: 0; z-index: 20;
    box-shadow: var(--shadow);
}
.public-header-inner { max-width: 880px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.public-header .logo-badge {
    width: 42px; height: 42px; border-radius: 11px;
    background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
    display: flex; align-items: center; justify-content: center; font-size: 21px; flex-shrink: 0;
}
.public-header .brand-name { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 16px; }
.public-header .brand-tag { font-size: 11.5px; color: #9fb3d6; }
.public-header .staff-link { margin-left: auto; font-size: 12.5px; color: #cfe0fb; white-space: nowrap; }

.public-wrap { max-width: 880px; margin: 0 auto; padding: 22px 16px 40px; }

.public-footer {
    text-align: center; padding: 26px 16px 40px; font-size: 12px; color: var(--text-faint);
}

/* ============================================================
   PRIMITIVES — card, buttons, badges, alerts
   ============================================================ */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 22px;
    margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.card-tight { padding: 16px 18px; }
.card-danger { border: 1.5px solid #f3b6b6; }
:root[data-theme="dark"] .card-danger { border-color: #7f2b2b; }
.danger-code {
    display: inline-block; font-family: "SFMono-Regular", Consolas, Menlo, monospace;
    font-size: 15px; font-weight: 700; letter-spacing: 2px;
    background: var(--red-bg); color: var(--red); border: 1px dashed var(--red);
    border-radius: var(--radius-sm); padding: 8px 12px;
}
.section {
    background: var(--surface-alt); padding: 16px; border-radius: var(--radius);
    border: 1px solid var(--border-soft); margin-bottom: 14px;
}

.btn {
    cursor: pointer; font-weight: 600; font-size: 13.5px; border: none;
    border-radius: var(--radius-sm); padding: 11px 18px;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    text-decoration: none; transition: background 0.15s var(--ease), transform 0.1s, box-shadow 0.15s;
    line-height: 1.2; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-primary { background: var(--blue-600); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,0.28); }
.btn-primary:hover { background: var(--blue-700); text-decoration: none; }
.btn-primary:disabled { background: #a9c1e8; box-shadow: none; cursor: not-allowed; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #047857; text-decoration: none; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: #b91c1c; text-decoration: none; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: #b45309; text-decoration: none; }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-alt); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-outline-blue { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-100); }
.btn-outline-blue:hover { background: var(--blue-100); text-decoration: none; }

/* pagination */
.pagination-nav { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.pagination-nav .btn { width: auto; }
.pagination-num { min-width: 36px; text-align: center; }
.pagination-ellipsis { padding: 0 4px; color: var(--text-muted); }

/* forms */
label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 5px; }
input, select, textarea {
    width: 100%; padding: 11px 13px; margin-bottom: 14px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); background: var(--card); color: var(--text);
    font-size: 14.5px; font-family: inherit; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-100);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 12.5px; }
.field-hint { font-size: 11.5px; color: var(--text-faint); margin-top: -10px; margin-bottom: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.checkbox-row input { width: auto; margin: 0; }
.checkbox-row label { margin: 0; font-weight: 500; color: var(--text); }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

/* .row-end: for rows that mix a labeled field (label+input stacked in a div) with a
   plain button/link that has no label above it -- e.g. "Pilih Batch" select next to a
   "Cetak Data Produksi" button. align-items:flex-end alone still misaligns them because
   the input/select keeps its normal 14px bottom margin, which the browser counts as part
   of that flex item's box -- so the button (no such margin) ends up sitting ~14px lower
   than the field's visible bottom edge. Zeroing that trailing margin fixes the alignment. */
.row-end { align-items: flex-end; }
.row-end > div > select:last-child,
.row-end > div > input:last-child { margin-bottom: 0; }
.row-end > .btn, .row-end > a.btn, .row-end > button.btn { flex: 0 0 auto; width: auto; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 480px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border-soft); }
th { color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
tbody tr:hover { background: var(--surface-alt); }

.badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
    border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em;
}
.badge-open { background: var(--green-bg); color: var(--green); }
.badge-closed { background: var(--orange-bg); color: var(--orange); }
.badge-archived { background: var(--surface-alt); color: var(--text-muted); }
.badge-paid { background: var(--green-bg); color: var(--green); }
.badge-unpaid { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-50); color: var(--blue-700); }
.badge-in_progress { background: var(--orange-bg); color: var(--orange); }
.badge-completed { background: var(--green-bg); color: var(--green); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin-bottom: 18px; }
.stat-box {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; text-align: left; position: relative; overflow: hidden;
    min-width: 0; /* grid items default to min-width:auto, which lets long label text
                     force the tile (and the whole row) wider than its track -- this
                     lets the label wrap/ellipsis inside the tile instead. */
}
.stat-box::before {
    content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%;
    background: linear-gradient(var(--blue-500), var(--blue-700));
}
.stat-box .num { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-box .label { font-size: 11px; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 4px; color: var(--text-muted); }

/* Category breakdown tables (rekap produksi / pakai stok) laid out inline side-by-side
   instead of stacked full-width, so several short category tables share a row. */
.breakdown-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; align-items: start; margin-top: 8px; }
.breakdown-grid > div h5 { margin: 0 0 4px; }
.breakdown-grid > div .table-wrap { margin-top: 0; }

/* Horizontal bar charts (stock page analytics) */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px,1fr)); gap: 16px; margin-bottom: 18px; }
.chart-grid .card { margin-bottom: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-muted); margin: 10px 0 4px; }
.chart-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.bar-chart { display: flex; flex-direction: column; gap: 11px; margin-top: 14px; }
.bar-chart-row { display: flex; align-items: center; gap: 10px; }
.bar-chart-rank { width: 16px; flex-shrink: 0; font-size: 11.5px; font-weight: 700; color: var(--text-faint); text-align: right; }
.bar-chart-label {
    width: 128px; flex-shrink: 0; font-size: 12.5px; font-weight: 600; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-chart-label small { display: block; font-size: 10px; font-weight: 500; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; }
.bar-chart-track { flex: 1; min-width: 0; position: relative; height: 18px; }
.bar-chart-fill-wrap { height: 100%; background: var(--border-soft); border-radius: 5px; overflow: hidden; }
.bar-chart-fill { height: 100%; border-radius: 5px; transition: width 0.3s var(--ease); }
.bar-fill-blue { background: var(--blue-500); }
.bar-fill-orange { background: var(--orange); }
.bar-fill-red { background: var(--red); }
.bar-chart-track[data-tooltip]:hover::after,
.bar-chart-track[data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute; left: 50%; bottom: calc(100% + 7px); transform: translateX(-50%);
    background: var(--text); color: var(--card); font-size: 11px; font-weight: 600;
    padding: 5px 10px; border-radius: 6px; white-space: nowrap; z-index: 5; box-shadow: var(--shadow-lg, var(--shadow));
    pointer-events: none;
}
.bar-chart-value { width: 62px; flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.bar-chart-badge-wrap { width: 60px; flex-shrink: 0; text-align: right; }
@media (max-width: 640px) {
    .bar-chart-label { width: 88px; }
    .bar-chart-value { width: 52px; font-size: 11px; }
    .bar-chart-badge-wrap { width: 52px; }
}

/* Stock page: category must be picked before its table renders, so cards start hidden
   and only the JS-selected one shows -- avoids a flash of every category at once. */
.stock-cat-card { display: none; }
.stock-filter-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stock-filter-row > div { flex: 1; min-width: 180px; }
.stock-filter-row label { margin-bottom: 5px; }

.alert { padding: 13px 15px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13.5px; display: flex; align-items: flex-start; gap: 9px; }
.alert-error { background: var(--red-bg); color: #9f1c1c; border: 1px solid #f8c9c9; }
.alert-success { background: var(--green-bg); color: #05684f; border: 1px solid #b7e8d3; }

.topbar-inner-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 10px; }

/* ============================================================
   PRODUCT PICKER — category chips, search, card grid
   ============================================================ */
.picker-toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.search-box { position: relative; }
.search-box input { padding-left: 38px; margin-bottom: 0; }
.search-box .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 15px; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--border);
    background: var(--card); color: var(--text-muted); font-size: 12.5px; font-weight: 600;
    cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.chip:hover { border-color: var(--blue-400); color: var(--blue-700); }
.chip.active { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }

.product-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px; margin-bottom: 18px;
}
/* Fixed 4 columns (x 20/page = 5 rows) on desktop so browsing stays a short,
   predictable scroll instead of reflowing to 5-6 columns on very wide screens.
   Narrower viewports keep the responsive auto-fill above. */
@media (min-width: 900px) {
    .product-grid { grid-template-columns: repeat(4, 1fr); }
}
.product-card {
    background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius);
    padding: 14px; cursor: pointer; transition: all 0.15s var(--ease); position: relative;
    display: flex; flex-direction: column; gap: 6px;
    min-width: 0; /* same grid-blowout guard as .stat-box */
}
.product-card:hover { border-color: var(--blue-400); box-shadow: var(--shadow); transform: translateY(-1px); }
.product-card.selected { border-color: var(--blue-600); background: var(--blue-50); box-shadow: 0 0 0 3px var(--blue-100); }
.product-card .p-cat { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--blue-600); font-weight: 700; }
.product-card .p-name { font-weight: 700; font-size: 14px; color: var(--text); line-height: 1.3; }
.product-card .p-note { font-size: 11.5px; color: var(--text-faint); }
.product-card .p-price-row { display: flex; align-items: baseline; justify-content: space-between; margin-top: auto; padding-top: 8px; }
.product-card .p-price { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; color: var(--navy-900); font-size: 15px; }
.product-card .p-attr-flag { font-size: 10px; color: var(--orange); font-weight: 700; }
.product-card .p-check {
    position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%;
    background: var(--blue-600); color: #fff; display: none; align-items: center; justify-content: center; font-size: 11px;
}
.product-card.selected .p-check { display: flex; }
.price-tier-note { font-size: 11px; color: var(--text-faint); margin: -8px 0 14px; }

/* Category -> search -> click add-item picker (order detail "Tambah Item") */
.add-item-search-wrap { position: relative; }
.add-item-results {
    display: none; position: absolute; z-index: 20; left: 0; right: 0; top: 100%;
    margin-top: 2px; max-height: 260px; overflow-y: auto;
    background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.add-item-option {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; text-align: left; padding: 9px 12px; border: none; border-bottom: 1px solid var(--border);
    background: var(--card); color: var(--text); font-size: 13px; cursor: pointer;
}
.add-item-option:last-child { border-bottom: none; }
.add-item-option:hover { background: var(--blue-50); color: var(--blue-700); }
.add-item-option-price { font-weight: 700; color: var(--navy-900); white-space: nowrap; font-size: 12px; }
.add-item-empty { padding: 10px 12px; font-size: 12.5px; color: var(--text-faint); }
.add-item-selected {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin-top: 6px; padding: 7px 10px; border-radius: var(--radius); font-size: 12.5px;
    background: var(--blue-50); border: 1px solid var(--blue-100); color: var(--blue-700); font-weight: 600;
}
.add-item-clear {
    border: none; background: transparent; color: var(--blue-600); font-size: 12px; font-weight: 700;
    cursor: pointer; text-decoration: underline; padding: 0; white-space: nowrap;
}

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-faint); }
.empty-state .ic { font-size: 34px; margin-bottom: 8px; display: block; }

/* attribute step panel */
.attr-panel { border: 1.5px dashed var(--blue-400); background: var(--blue-50); }
.attr-panel h4 { color: var(--blue-700); }

/* basket / cart */
.basket-item {
    background: var(--card); border: 1px solid var(--border); padding: 12px 14px;
    border-radius: var(--radius-sm); margin-bottom: 8px;
}
.basket-item .bi-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.basket-item .bi-name { font-weight: 700; font-size: 13.5px; }
.basket-item .bi-price { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; color: var(--navy-900); white-space: nowrap; }
.basket-item .bi-attrs { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.basket-item .bi-remove { background: none; border: none; color: var(--red); font-size: 11px; font-weight: 700; cursor: pointer; padding: 4px 0; width: auto; margin: 6px 0 0; }

.cart-summary-bar {
    position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(16,26,44,0.08); padding: 14px 18px; margin: 0 -22px -22px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.cart-summary-bar .cs-total { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 18px; color: var(--navy-900); }
.cart-summary-bar .cs-units { font-size: 11.5px; color: var(--text-muted); }

/* ============================================================
   FLOATING CART BAR — fixed to the viewport (not just the card),
   so the customer always sees count/total/what's missing while
   browsing products, without needing to scroll down to the basket.
   ============================================================ */
.floating-cart-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--card); border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(16,26,44,0.12);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    transform: translateY(110%); transition: transform 0.25s var(--ease);
}
/* On admin/staff pages (fixed sidebar present) keep the bar clear of the sidebar
   instead of running underneath it full-bleed. Public order pages have no
   .app-shell, so this simply has no effect there. */
@media (min-width: 901px) {
    .app-shell .floating-cart-bar { left: var(--sidebar-w); }
}
.floating-cart-bar.visible { transform: translateY(0); }
.floating-cart-bar .fcb-inner { max-width: 880px; margin: 0 auto; }
.floating-cart-bar .fcb-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.floating-cart-bar .fcb-info { min-width: 0; }
.floating-cart-bar .fcb-total { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 18px; color: var(--navy-900); line-height: 1.25; }
.floating-cart-bar .fcb-units { font-size: 11.5px; color: var(--text-muted); }
.floating-cart-bar .fcb-submit { flex-shrink: 0; }
.floating-cart-bar .fcb-missing {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.floating-cart-bar .fcb-missing-item {
    font-size: 11px; font-weight: 700; color: var(--orange); background: var(--orange-bg);
    padding: 4px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px;
}
.floating-cart-bar .fcb-missing-clickable {
    cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.floating-cart-bar .fcb-missing-clickable:hover { background: var(--orange); color: #fff; }
:root[data-theme="dark"] .floating-cart-bar .fcb-total { color: var(--text); }
body.has-floating-cart-bar { padding-bottom: 88px; }
@media (max-width: 640px) {
    body.has-floating-cart-bar { padding-bottom: 108px; }
    .floating-cart-bar .fcb-total { font-size: 16px; }
}

.step-track { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; }
.step-track .step {
    display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--text-faint);
}
.step-track .step .dot {
    width: 24px; height: 24px; border-radius: 50%; background: var(--surface-alt); color: var(--text-faint);
    display: flex; align-items: center; justify-content: center; font-size: 11.5px; flex-shrink: 0;
}
.step-track .step.active .dot { background: var(--blue-600); color: #fff; }
.step-track .step.active { color: var(--text); }
.step-track .step.done .dot { background: var(--green); color: #fff; }
.step-track .line { flex: 1; height: 2px; background: var(--border); min-width: 16px; }

@media (max-width: 640px) {
    .cart-summary-bar { margin: 0 -14px -16px; border-radius: 0; flex-direction: column; align-items: stretch; }
    .card { padding: 16px; }
}

/* ============================================================
   DARK MODE — toggle via [data-theme="dark"] on <html>
   ============================================================ */
:root[data-theme="dark"] {
    --surface:      #0a1220;
    --surface-alt:  #101d30;
    --card:         #131f32;
    --border:       #223349;
    --border-soft:  #1b2939;
    --text:         #e7edf7;
    --text-muted:   #96a7c2;
    --text-faint:   #667a97;

    --blue-50:  rgba(59,130,246,0.12);
    --blue-100: rgba(59,130,246,0.22);
    --green-bg: rgba(5,150,105,0.18);
    --red-bg:   rgba(220,38,38,0.20);
    --orange-bg:rgba(217,119,6,0.20);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 16px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}
:root[data-theme="dark"] body { background: var(--surface); }
:root[data-theme="dark"] .topbar { background: var(--card); border-color: var(--border); }
:root[data-theme="dark"] .btn-ghost { background: var(--surface-alt); }
:root[data-theme="dark"] .chip { background: var(--surface-alt); }
:root[data-theme="dark"] .chip.active { background: var(--blue-600); border-color: var(--blue-600); }
:root[data-theme="dark"] .public-wrap textarea,
:root[data-theme="dark"] .content textarea { color: var(--text); }
:root[data-theme="dark"] .badge-archived { background: var(--surface-alt); }
:root[data-theme="dark"] tbody tr:hover { background: var(--surface-alt); }
:root[data-theme="dark"] .product-img-placeholder { background: var(--surface-alt); color: var(--text-faint); }

/* These were hardcoded to --navy-900 (a fixed dark color used for the sidebar/etc.)
   instead of the theme-aware --text variable, so in dark mode this text rendered
   near-black on a near-black card background -- effectively invisible. */
:root[data-theme="dark"] .product-card .p-price,
:root[data-theme="dark"] .basket-item .bi-price,
:root[data-theme="dark"] .cart-summary-bar .cs-total,
:root[data-theme="dark"] .stat-box .num {
    color: var(--text);
}
/* Alert text colors were tuned for the light red/green backgrounds only --
   too dark to read against the dimmer dark-mode alert backgrounds. */
:root[data-theme="dark"] .alert-error { color: #ff9d9d; border-color: rgba(220,38,38,0.4); }
:root[data-theme="dark"] .alert-success { color: #7fe3bd; border-color: rgba(5,150,105,0.4); }

.theme-toggle {
    width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--card); cursor: pointer; font-size: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { background: var(--surface-alt); }
.public-header .theme-toggle { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); margin-left: 8px; }
.public-header .theme-toggle:hover { background: rgba(255,255,255,0.16); }

/* ============================================================
   PRODUCT IMAGES
   ============================================================ */
.product-card .p-img {
    width: 100%; aspect-ratio: 4/3; border-radius: var(--radius-sm); overflow: hidden;
    background: var(--surface-alt); margin-bottom: 2px;
}
.product-card .p-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-img-placeholder {
    width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-faint); font-size: 11px; gap: 4px; background: var(--surface-alt);
}
.product-img-placeholder .ic { font-size: 22px; }
.thumb-sm { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: var(--surface-alt); flex-shrink: 0; }
.thumb-sm img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-sm .product-img-placeholder .ic { font-size: 16px; }
.thumb-sm .product-img-placeholder { font-size: 0; }

/* Uploaded store logo image -- fills whichever .logo-badge/.thumb-sm sized container it's in;
   falls back to a small inline size when used standalone (e.g. receipt/print headers). */
.logo-badge-img { height: 1.3em; width: auto; vertical-align: middle; border-radius: 4px; display: inline-block; }
.logo-badge .logo-badge-img, .thumb-sm .logo-badge-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

/* Stock badge on the staff/admin/super order picker -- never shown to public customers */
.stock-badge {
    font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
    display: inline-block; margin: 2px 0 4px;
}
.stock-badge.stock-avail { background: var(--green-bg); color: var(--green); }
.stock-badge.stock-empty { background: var(--red-bg); color: var(--red); }

/* Welcome banner (public order page + internal dashboard) */
.welcome-banner {
    background: linear-gradient(120deg, var(--blue-50), var(--card));
    border-left: 4px solid var(--blue-500);
}
.welcome-banner p { margin: 0; font-size: 14px; font-weight: 500; }
.welcome-banner-compact { padding: 12px 16px; }
.welcome-banner-compact p { font-size: 13px; }
.welcome-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* Front-page ad/info banner (Pengaturan > Banner Iklan) -- shown just below the welcome text */
.ad-banner { padding: 0; overflow: hidden; }
.ad-banner a { display: block; color: inherit; }
.ad-banner a:hover { text-decoration: none; }
.ad-banner-img { width: 100%; height: auto; display: block; }
.ad-banner-text { margin: 0; padding: 12px 16px; font-size: 13px; font-weight: 500; color: var(--text); text-align: center; }
.ad-banner-img + .ad-banner-text { padding-top: 10px; }

/* ============================================================
   CATEGORY SWEEP (mobile-friendly horizontally scrollable rows)
   ============================================================ */
/* Horizontal tab nav (Kelola Katalog) -- same scroll-on-mobile treatment as .category-tabs */
.tab-nav {
    display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin-bottom: 18px; padding-bottom: 4px; border-bottom: 1.5px solid var(--border);
}
.tab-nav::-webkit-scrollbar { height: 5px; }
.tab-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.tab-btn {
    padding: 9px 16px; border-radius: var(--radius) var(--radius) 0 0; border: none;
    background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 700;
    cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.tab-btn:hover { color: var(--blue-700); }
.tab-btn.active { background: var(--navy-900); color: #fff; }
:root[data-theme="dark"] .tab-btn.active { background: var(--blue-600); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.category-tabs {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 4px;
    scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.category-tabs::-webkit-scrollbar { height: 5px; }
.category-tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.bundle-badge { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; font-size: 9.5px; font-weight: 800; padding: 3px 8px; border-radius: 999px; letter-spacing: 0.03em; }
.required-badge { color: var(--red); font-size: 10px; font-weight: 700; }

.price-override-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.price-override-row input { margin-bottom: 0; padding: 6px 9px; font-size: 13px; }
.price-override-row label { margin: 0; white-space: nowrap; font-size: 11px; }

/* Two rows -- qty controls, then the full-width add button below -- instead of
   cramming both into one row, which overflowed/overlapped once cards got
   narrower under the 4-column grid (see .product-grid breakpoint above). */
.qty-stepper { display: flex; flex-direction: column; gap: 8px; }
.qty-stepper-controls { display: flex; align-items: center; gap: 6px; }
.qty-stepper-controls button {
    width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; border: 1.5px solid var(--border);
    background: var(--card); color: var(--text); font-weight: 700; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.qty-stepper-controls button:hover { background: var(--surface-alt); }
.qty-stepper-controls input { flex: 1; min-width: 0; text-align: center; margin: 0; padding: 6px 4px; }

.card-add-btn {
    background: var(--navy-900); color: #fff; border: none; border-radius: var(--radius-sm);
    padding: 9px; font-weight: 700; font-size: 12.5px; cursor: pointer; width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.card-add-btn:hover { background: var(--blue-700); }
.card-detail-toggle {
    background: none; border: none; color: var(--blue-600); font-size: 11.5px; font-weight: 600;
    cursor: pointer; padding: 2px 0; width: auto; text-align: left;
}

/* ============================================================
   PRINT / RECEIPT
   ============================================================ */
@media print {
    .no-print, .sidebar, .topbar, .theme-toggle, .public-header .staff-link,
    .cart-summary-bar, .floating-cart-bar, .btn, .hamburger, .sidebar-backdrop, .page-footer, .public-footer { display: none !important; }
    body { background: #fff !important; }
    .content, .public-wrap { padding: 0 !important; max-width: 100% !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; }
    .main-col { margin-left: 0 !important; }
}
.receipt-print-btn { display: inline-flex; }
