:root {
    --primary: #ea580c;
    --primary-dark: #c2410c;
    --primary-light: #fff1e8;
    --primary-ring: rgba(234, 88, 12, 0.18);
    --dark: #1c1f26;
    --sidebar: #16181f;
    --sidebar-active: #23262f;
    --border: #e6e6ea;
    --bg: #f7f7f9;
    --surface: #ffffff;
    --text: #1c1f26;
    --muted: #767a85;
    --muted-light: #a2a5ad;
    --success: #16a35e;
    --success-light: #e6f8ef;
    --danger: #e0342c;
    --danger-light: #fdeaea;
    --info: #2563eb;
    --info-light: #eaf1ff;
    --purple: #7c3aed;
    --purple-light: #f3eaff;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.05);
    --shadow: 0 4px 16px rgba(20, 20, 30, 0.06);
    --shadow-lg: 0 16px 40px rgba(20, 20, 30, 0.14);
    --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }

::selection { background: var(--primary-light); color: var(--primary-dark); }

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Mobile top bar (hidden on desktop) ---------- */
.mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 30;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--sidebar);
    color: #fff;
}
.mobile-topbar .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.08);
    cursor: pointer;
}
.mobile-topbar .hamburger span { display: block; width: 16px; height: 2px; background: #fff; margin: 0 auto; border-radius: 2px; }
.mobile-topbar .brand { font-weight: 700; font-size: 16px; }
.mobile-topbar .brand span { color: var(--primary); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 14, 0.5);
    z-index: 39;
    opacity: 0;
    transition: opacity .25s var(--ease);
}
.sidebar-overlay.open { display: block; opacity: 1; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 240px;
    background: var(--sidebar);
    color: #fff;
    flex-shrink: 0;
    padding: 22px 0;
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    font-size: 19px;
    font-weight: 800;
    padding: 0 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar .brand span { color: var(--primary); }
.sidebar .close-sidebar { display: none; }

.sidebar nav { padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #b4b7c1;
    font-size: 14px;
    font-weight: 500;
    border-radius: 9px;
    transition: background .15s var(--ease), color .15s var(--ease);
}

.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }

.sidebar nav a.active {
    background: var(--primary);
    color: #fff;
}

.sidebar .user-box {
    margin-top: auto;
    padding: 16px 22px 4px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 13px;
}

.sidebar .user-box .nama { font-weight: 600; }

.sidebar .user-box .role-badge {
    display: inline-block;
    background: rgba(234, 88, 12, 0.18);
    color: #ffb185;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 5px;
}

.sidebar .user-box a.logout {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    color: #f0918a;
    font-size: 13px;
    font-weight: 500;
}
.sidebar .user-box a.logout:hover { color: #ff9d7a; }

/* ---------- Main content ---------- */
.main {
    flex: 1;
    min-width: 0;
    padding: 28px 32px 60px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.topbar h1 { font-size: 23px; margin: 0; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }

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

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
}

.stat-card .label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 26px; font-weight: 800; margin-top: 8px; letter-spacing: -0.02em; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
    transition: background .15s var(--ease), box-shadow .15s var(--ease), transform .1s var(--ease), border-color .15s var(--ease);
    box-shadow: var(--shadow-sm);
}

.btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.btn-outline:hover { background: #fafafa; border-color: #d5d5db; }
.btn.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn.btn-danger { background: var(--danger); }
.btn.btn-danger:hover { background: #c22a23; }
.btn.btn-success { background: var(--success); }
.btn.btn-success:hover { background: #128a4e; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #444; }

.form-group { margin-bottom: 16px; }

input[type=text], input[type=number], input[type=password], input[type=date], input[type=file], select, textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

input::placeholder, textarea::placeholder { color: var(--muted-light); }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}

.form-row { display: flex; gap: 14px; }
.form-row > * { flex: 1; }

.radio-group { display: flex; gap: 10px; }
.radio-option {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.radio-option input { display: none; }
.radio-option.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; background: #fafafa; }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
tbody tr { transition: background .1s var(--ease); }
tbody tr:hover td { background: #fafafa; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border-radius: 20px; font-size: 11.5px; font-weight: 700; letter-spacing: .01em; }
.badge-aktif, .badge-selesai, .badge-tunai { background: var(--success-light); color: var(--success); }
.badge-nonaktif, .badge-dibatalkan { background: var(--danger-light); color: var(--danger); }
.badge-qris { background: var(--info-light); color: var(--info); }
.badge-transfer { background: var(--purple-light); color: var(--purple); }

/* ---------- Alerts ---------- */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.alert-success { background: var(--success-light); color: #0f7a44; border: 1px solid #b6e8cd; }
.alert-error { background: var(--danger-light); color: #b71f1f; border: 1px solid #f6c1c1; }

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 15%, rgba(234, 88, 12, 0.25), transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(124, 58, 237, 0.18), transparent 45%),
        linear-gradient(160deg, #1c1f26, var(--sidebar));
}
.login-box {
    background: var(--surface);
    width: 100%;
    max-width: 380px;
    padding: 36px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.login-box .logo-mark {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin-bottom: 16px;
}
.login-box h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; }
.login-box p.sub { color: var(--muted); margin: 0 0 26px; font-size: 13.5px; }
.login-box .btn { width: 100%; padding: 12px; margin-top: 8px; font-size: 14.5px; }

/* ---------- POS / kasir layout ---------- */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    align-items: start;
}

.menu-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.menu-tabs button {
    padding: 7px 15px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.menu-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.menu-item-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .1s var(--ease);
}
.menu-item-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.menu-item-card:active { transform: translateY(0); }
.menu-item-card .nama { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.menu-item-card .harga { color: var(--primary); font-weight: 700; font-size: 14px; }

.cart-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    position: sticky;
    top: 20px;
}
.cart-box h3 { margin-top: 0; }
.cart-items { max-height: 280px; overflow-y: auto; margin-bottom: 12px; }

.cart-summary-bar {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    padding: 4px 2px;
}
.cart-summary-chevron { color: var(--muted); transition: transform .2s var(--ease); font-size: 12px; }
.cart-empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 28px 0; }

.cart-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid #f0f0f2; }
.cart-row .info { flex: 1; min-width: 0; }
.cart-row .info .nama { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-row .info .harga { font-size: 12.5px; color: var(--muted); }
.cart-row .qty-ctrl { display: flex; align-items: center; gap: 6px; }
.cart-row .qty-ctrl button {
    width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border);
    background: var(--surface); cursor: pointer; font-size: 14px; line-height: 1; font-family: inherit;
    transition: background .15s var(--ease), border-color .15s var(--ease);
}
.cart-row .qty-ctrl button:hover { background: var(--primary-light); border-color: var(--primary); }
.cart-row .subtotal { width: 78px; text-align: right; font-size: 13px; font-weight: 700; }
.cart-row .remove { color: var(--danger); cursor: pointer; font-size: 18px; padding: 0 2px; line-height: 1; }

.cart-total-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; font-weight: 800; padding: 14px 0; border-top: 2px dashed var(--border); margin-top: 4px; }

.kembalian-box { background: var(--primary-light); border-radius: var(--radius-sm); padding: 11px 14px; font-size: 14px; margin-top: 10px; color: #7a3106; }

/* ---------- Struk / receipt ---------- */
.struk-preview-wrap { display: flex; justify-content: center; padding: 24px 0; }
.struk {
    width: 302px;
    background: #fff;
    padding: 14px;
    font-family: 'Courier New', monospace;
    font-size: 12.5px;
    color: #000;
    border: 1px dashed #ccc;
    border-radius: 4px;
}
.struk .center { text-align: center; }
.struk .bold { font-weight: 700; }
.struk hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }
.struk .row { display: flex; justify-content: space-between; gap: 6px; }
.struk .item-name { flex: 1; }
.struk table.struk-items { width: 100%; border-collapse: collapse; margin: 6px 0; }
.struk table.struk-items td { padding: 2px 0; border: none; font-size: 12px; }

.no-print-toolbar { text-align: center; margin-bottom: 16px; }

@media print {
    body * { visibility: hidden; }
    .struk, .struk * { visibility: visible; }
    .struk { position: absolute; top: 0; left: 0; width: 80mm; border: none; padding: 4mm; }
    .no-print-toolbar, .sidebar, .mobile-topbar { display: none !important; }
    @page { margin: 0; size: 80mm auto; }
}

.empty-state { text-align: center; padding: 44px 0; color: var(--muted); font-size: 14px; }

.filter-bar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .form-group { margin-bottom: 0; min-width: 150px; }

.thumb { width: 88px; height: 88px; object-fit: cover; border-radius: var(--radius-sm); background: #eee; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
    .mobile-topbar { display: flex; }

    .app-shell { flex-direction: column; }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 260px;
        max-width: 82vw;
        transform: translateX(-100%);
        transition: transform .25s var(--ease);
        z-index: 40;
        overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .sidebar .close-sidebar {
        display: block;
        margin-left: auto;
        background: none;
        border: none;
        color: #b4b7c1;
        font-size: 22px;
        line-height: 1;
        cursor: pointer;
        padding: 2px 6px;
    }

    .main { padding: 18px 16px 90px; }

    .topbar { flex-direction: column; align-items: flex-start; gap: 4px; }

    .pos-layout { grid-template-columns: 1fr; }

    /* Keranjang jadi "bottom sheet": collapsed = cuma bar ringkasan, tap buat expand */
    .cart-box {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 25;
        border-radius: var(--radius) var(--radius) 0 0;
        box-shadow: 0 -8px 24px rgba(20,20,30,0.14);
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding: 12px 16px;
        max-height: 75vh;
        display: flex;
        flex-direction: column;
    }

    .cart-summary-bar { display: flex; }
    .cart-box.expanded .cart-summary-chevron { transform: rotate(180deg); }

    .cart-full {
        display: none;
        overflow-y: auto;
        padding-top: 12px;
        margin-top: 10px;
        border-top: 1px solid var(--border);
    }
    .cart-box.expanded .cart-full { display: block; }

    /* kasih ruang di bawah biar konten halaman nggak ketutup bar ringkasan */
    .pos-layout { padding-bottom: 56px; }

    .filter-bar .form-group { min-width: 130px; flex: 1 1 130px; }

    table { font-size: 13px; }
    th, td { padding: 9px 8px; }
}
