/* ================================================================
   Sri Rejeki Motor — Sistem Kasir & Gudang
   Arah desain: "kartu stok bengkel" — graphite gelap, aksen brass/karat,
   tipografi tegas + monospace untuk kode & rupiah. Bukan tema SaaS biru
   generik — palet & huruf disusun khusus untuk toko onderdil motor.
   ================================================================ */

:root {
    /* Permukaan — abu-baja hangat, bukan putih/krem generik */
    --bg-base:       #eef0ea;
    --bg-surface:    #fffffe;
    --bg-elevated:   #e6e8e0;
    --bg-input:      #f5f6f0;
    --border:        #dcded3;
    --border-focus:  #a6551f;

    /* Aksen brass/karat — warna khas pelat logam & label gudang bengkel */
    --primary:       #a6551f;
    --primary-hover: #7c3d15;
    --primary-light: #c98a44;
    --primary-dim:   rgba(166,85,31,0.08);
    --blue:          #c98a44;
    --blue-dim:      rgba(201,138,68,0.14);

    /* Semantik (dibuat lebih redup/berbumi, senada dgn palet utama) */
    --green:         #3f8556;
    --green-dim:     rgba(63,133,86,0.1);
    --red:           #c2483c;
    --red-dim:       rgba(194,72,60,0.09);
    --amber:         #a6791f;
    --amber-dim:     rgba(166,121,31,0.1);

    /* Tinta & teks — hitam hangat, bukan navy-slate generik */
    --text-primary:  #211f1a;
    --text-secondary:#6b6a5f;
    --text-muted:    #8f8d80;

    /* Sidebar graphite (dipakai beberapa komponen non-token juga) */
    --graphite:      #191815;
    --graphite-2:    #232019;

    /* Tipografi: display bertulang industrial, teks tubuh teknis & legible,
       mono untuk kode_internal/kode_barang/rupiah — nuansa struk & kartu stok */
    --font-display:  'Big Shoulders Display', 'Arial Narrow', sans-serif;
    --font-body:      'IBM Plex Sans', 'Outfit', sans-serif;
    --font-mono:      'IBM Plex Mono', ui-monospace, monospace;

    --sidebar-w:     264px;
    --radius-sm:     5px;
    --radius-md:     9px;
    --radius-lg:     12px;
    --shadow-sm:     0 1px 2px rgba(25,24,21,0.05);
    --shadow-md:     0 6px 16px rgba(25,24,21,0.08);
    --shadow-lg:     0 14px 32px rgba(25,24,21,0.14);
    --transition:    all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Judul di seluruh halaman pakai huruf display yang sama — identitas
   konsisten tanpa perlu menyentuh <style> tiap halaman satu-satu. */
h1, h2, h3, .page-title, .table-title, .brand-name {
    font-family: var(--font-display);
    letter-spacing: 0.01em;
}

/* Placeholder & scrollbar mengikuti aksen brass, bukan biru bawaan browser */
::selection { background: rgba(166,85,31,0.22); color: var(--text-primary); }

/* ================================================================
   SCROLLBAR
   ================================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(166,85,31,0.3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(166,85,31,0.5); }

/* ================================================================
   APP LAYOUT
   ================================================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ================================================================
   HAMBURGER MENU
   ================================================================ */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-right: 12px;
}

.hamburger span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ================================================================
   SIDEBAR — Dark Elegant (Notion/Linear style)
   ================================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: #191815;
    border-right: 1px solid rgba(255,255,255,0.055);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    box-shadow: 2px 0 28px rgba(0,0,0,0.4);
}

.sidebar::before { display: none; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 19px 16px 18px;
    flex-shrink: 0;
    position: relative;
    background: linear-gradient(160deg, #123055 0%, #0d1f38 55%, #191815 100%);
    border-bottom: 1px solid rgba(255,255,255,0.09);
    box-shadow: 0 6px 16px -6px rgba(0,0,0,0.55);
}
/* Garis brass tipis di tepi atas sidebar — jahitan "pelat" */
.sidebar-brand::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, #a6551f, transparent 70%);
}

.brand-icon {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    display: block;
    background: #eef3fa;
    padding: 3px;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.18), 0 2px 6px rgba(0,0,0,0.35);
}

.brand-text { flex: 1; min-width: 0; }

.brand-name {
    display: block;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    color: #efece4;
    letter-spacing: 0.03em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-sub {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    color: rgba(226,184,120,.75);
    margin-top: 3px;
    letter-spacing: 0.04em;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;
}

.nav-section-label,
.nav-group-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    color: rgba(226,184,120,0.4);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    padding: 16px 11px 5px;
    margin-top: 2px;
    user-select: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 8px;
    color: rgba(255,255,255,0.48);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 400;
    transition: all 0.14s ease;
    position: relative;
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-item:hover {
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.88);
}

.nav-item.active {
    background: rgba(58,53,44,0.13);
    color: #e2b878;
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 65%;
    background: #c96a2e;
    border-radius: 0 3px 3px 0;
}

.nav-item-sub {
    padding-left: 30px;
    font-size: 12.5px;
    margin-top: -2px;
}
.nav-item-sub svg { width: 14px; height: 14px; }

/* Sidebar footer */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.sheet-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    color: rgba(255,255,255,0.28);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #3f8556;
    border-radius: 50%;
    box-shadow: 0 0 6px #3f8556;
    flex-shrink: 0;
}

/* Sidebar — user info & logout */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 4px;
    background: #100f0d;
    border: 1.5px solid rgba(226,184,120,.5);
    color: #e2b878;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-logout-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.05);
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.sidebar-logout-btn:hover {
    background: rgba(194,72,60,0.15);
    color: #d9776b;
}

@media (prefers-reduced-motion: no-preference) {
    .status-indicator { animation: pulse 2s infinite; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 32px 40px;
    min-height: 100vh;
    max-width: calc(100vw - var(--sidebar-w));
    background: var(--bg-base);
}

/* ================================================================
   PAGE HEADER
   ================================================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 20px;
}

.header-left {
    flex: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.page-title {
    font-weight: 700;
    font-size: 30px;
    text-transform: uppercase;
    color: var(--text-primary);
    letter-spacing: 0.01em;
    line-height: 1.15;
}

.page-subtitle {
    margin-top: 7px;
    padding-top: 7px;
    border-top: 2px solid var(--primary);
    display: inline-block;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-secondary);
}

.btn-reset {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-reset svg { width: 14px; height: 14px; }

.btn-reset:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-dim);
}

/* ================================================================
   NOTIFICATION
   ================================================================ */
.notification {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 14px;
    animation: slideDown 0.3s ease;
}

.notification.success {
    display: flex;
    background: rgba(63,133,86,0.08);
    border: 1px solid rgba(63,133,86,0.2);
    color: var(--green);
}

.notification.error {
    display: flex;
    background: rgba(194,72,60,0.08);
    border: 1px solid rgba(194,72,60,0.2);
    color: var(--red);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   FORM SECTIONS
   ================================================================ */
.form-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 28px;
    margin-bottom: 24px;
    position: relative;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.form-section:hover {
    box-shadow: var(--shadow-md);
}

/* Grid */
.form-grid {
    display: grid;
    gap: 20px;
}

.form-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-group.full-width {
    grid-column: 1 / -1;
}

/* ================================================================
   FORM FIELDS
   ================================================================ */
.field-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-scan {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary-dim);
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-left: auto;
}

.field-hint {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    margin-left: auto;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
    transition: var(--transition);
    z-index: 1;
}

.input-icon svg { width: 16px; height: 16px; }

.currency-icon {
    font-size: 12px;
    font-weight: 600;
}

.field-input {
    width: 100%;
    padding: 11px 12px 11px 40px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    -moz-appearance: textfield;
}

.field-input::-webkit-outer-spin-button,
.field-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.field-input::placeholder { color: var(--text-muted); }

.field-input:focus {
    border-color: var(--primary);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px rgba(166,85,31,0.06);
}

.field-input:focus + * .input-icon,
.input-wrapper:focus-within .input-icon {
    color: var(--primary);
}

.input-suffix {
    position: absolute;
    right: 14px;
    font-size: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

/* Scan input special style */
.scan-input .field-input {
    border-color: rgba(166,85,31,0.2);
    background: rgba(166,85,31,0.03);
}

.scan-pulse {
    position: absolute;
    right: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0;
}

.scan-input .field-input:focus ~ .scan-pulse {
    opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
    .scan-input .field-input:focus ~ .scan-pulse {
        animation: scanPulse 1s infinite;
    }
}

@keyframes scanPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(166,85,31,0.4); }
    50% { box-shadow: 0 0 0 6px rgba(166,85,31,0); }
}

/* Currency display */
.field-preview {
    display: block;
    font-size: 11px;
    color: var(--primary);
    margin-top: 4px;
    min-height: 16px;
    padding-left: 4px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* ================================================================
   CUSTOM SELECT / LOKASI RAK
   ================================================================ */
.custom-select-wrapper {
    position: relative;
}

.select-arrow {
    position: absolute;
    right: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: var(--transition);
    z-index: 2;
}

.custom-select-wrapper.open .select-arrow {
    transform: rotate(180deg);
    color: var(--primary);
}

.dropdown-list {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid rgba(166,85,31,0.2);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    max-height: 260px;
    overflow-y: auto;
    animation: dropIn 0.15s ease;
}

.custom-select-wrapper.open .dropdown-list {
    display: block;
}

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

.dropdown-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    color: var(--text-muted);
    font-size: 13px;
    justify-content: center;
    flex-direction: column;
}

.dropdown-item {
    padding: 11px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

.dropdown-item:hover,
.dropdown-item.highlighted {
    background: var(--primary-dim);
    color: var(--primary);
}

.dropdown-item .item-icon {
    width: 20px;
    height: 20px;
    background: rgba(166,85,31,0.1);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: var(--primary);
    font-family: var(--font-body);
    font-weight: 600;
    flex-shrink: 0;
}

.dropdown-count {
    padding: 8px 16px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    text-align: center;
}

/* ================================================================
   MARGIN CARD
   ================================================================ */
.margin-card {
    display: flex;
    gap: 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.margin-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.margin-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.margin-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--green);
    
}

.margin-value.negative { color: var(--red); }

/* ================================================================
   FORM ACTIONS
   ================================================================ */
.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    margin-top: 12px;
    padding: 0 4px;
}

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary svg { width: 15px; height: 15px; }

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-dim);
}

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 11px 28px;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.015em;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.btn-primary svg { width: 15px; height: 15px; }

.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { background: var(--primary-hover); }

.btn-primary.loading span { opacity: 0; }
.btn-loader {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: rgba(255,255,255,0.9);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    position: absolute;
}

.btn-primary.loading .btn-loader { display: block; }
.btn-primary.loading svg { opacity: 0; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================================================================
   TABLE STYLES
   ================================================================ */
.table-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-toolbar {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.table-title {
    
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-dim);
    border: 1px solid rgba(166,85,31,0.25);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.refresh-btn:hover { 
    background: rgba(166,85,31,0.15);
    border-color: var(--primary);
}

.refresh-btn svg { width: 14px; height: 14px; }

table { 
    width: 100%; 
    border-collapse: collapse; 
}

thead th {
    padding: 12px 16px;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--bg-elevated); }

tbody td {
    padding: 12px 16px;
    font-size: 13.5px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.td-code { 
    font-family: var(--font-mono); 
    font-size: 12px; 
    color: var(--primary); 
    font-weight: 500;
}

.td-name { 
    color: var(--text-primary); 
    font-weight: 500; 
    max-width: 200px; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.td-price { 
    font-family: var(--font-body); 
    color: var(--green);
    font-weight: 500;
}

.td-stok { 
    font-weight: 600; 
    color: var(--text-primary); 
}

.loading-row td { 
    text-align: center; 
    padding: 40px; 
    color: var(--text-muted); 
}

.empty-state { 
    padding: 60px; 
    text-align: center; 
    color: var(--text-muted); 
}

.empty-state svg { 
    width: 40px; 
    height: 40px; 
    margin-bottom: 12px; 
    opacity: 0.4; 
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.search-bar input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    width: 180px;
}

.search-bar input::placeholder { 
    color: var(--text-muted); 
}

.search-bar svg { 
    width: 15px; 
    height: 15px; 
    color: var(--text-muted); 
    flex-shrink: 0; 
}

.badge-count {
    padding: 4px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ================================================================
   RESPONSIVE DESIGN
   ================================================================ */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .main-content { 
        padding: 28px 24px; 
    }
    
    .form-grid.cols-2 {
        grid-template-columns: 1fr;
    }
    
    .form-section {
        padding: 24px;
    }
    
    .page-title {
        font-size: 28px;
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    :root {
        --sidebar-w: 100%;
    }
    
    .hamburger {
        display: flex;
    }
    
    .page-header {
        flex-direction: row;
        align-items: center;
        margin-bottom: 24px;
        gap: 12px;
    }
    
    .header-left {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .header-left > div {
        flex: 1;
    }
    
    .header-right {
        display: none;
    }
    
    .page-title {
        font-size: 20px;
        margin: 0;
    }
    
    .page-subtitle {
        display: none;
    }
    
    .sidebar {
        width: 100%;
        max-width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.4);
        z-index: 99;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0 !important;
        max-width: 100vw !important;
        padding: 16px 14px;
    }
    
    .form-grid.cols-2 {
        grid-template-columns: 1fr;
    }
    
    .field-group.full-width {
        grid-column: 1;
    }
    
    .form-section {
        padding: 18px 14px;
        border-radius: var(--radius-md);
        margin-bottom: 16px;
    }
    
    .form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 0;
    }
    
    .btn-primary, 
    .btn-secondary {
        width: 100%;
        padding: 11px 16px;
        font-size: 13px;
    }
    
    .btn-reset {
        display: none;
    }
    
    .table-wrapper {
        border-radius: var(--radius-md);
    }
    
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px 12px;
    }
    
    .table-toolbar > div {
        width: 100%;
        display: flex;
        gap: 8px;
    }
    
    .table-toolbar > div:first-child {
        flex-wrap: wrap;
        align-items: center;
    }
    
    .search-bar {
        flex: 1;
        min-width: 150px;
        padding: 8px 12px;
    }
    
    .search-bar input {
        width: 100%;
        font-size: 13px;
    }
    
    .refresh-btn {
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
    }
    
    .badge-count {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .table-title {
        font-size: 14px;
    }
    
    table {
        font-size: 12px;
    }
    
    thead th {
        font-size: 10px;
        padding: 8px 10px;
    }
    
    tbody td {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .td-code {
        font-size: 11px;
    }
    
    .td-name {
        max-width: 100px;
        font-size: 12px;
    }
    
    .field-label {
        font-size: 12px;
    }
    
    .badge-scan {
        font-size: 9px;
        padding: 3px 6px;
    }
    
    .input-wrapper {
        position: relative;
    }
    
    .field-input {
        padding: 10px 12px 10px 36px;
        font-size: 13px;
    }
    
    .input-icon {
        width: 32px;
        left: 8px;
    }
    
    .input-icon svg {
        width: 14px;
        height: 14px;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .hamburger {
        width: 28px;
        height: 28px;
        gap: 4px;
        margin-right: 4px;
    }
    
    .hamburger span {
        width: 20px;
        height: 1.5px;
    }
    
    .page-header {
        padding: 0;
        margin-bottom: 16px;
    }
    
    .page-title {
        font-size: 18px;
        margin: 0;
    }
    
    .main-content {
        padding: 12px 10px;
    }
    
    .form-section {
        padding: 14px 12px;
        margin-bottom: 14px;
    }
    
    .form-grid {
        gap: 14px;
    }
    
    .field-label {
        font-size: 11px;
        gap: 4px;
    }
    
    .badge-scan {
        font-size: 8px;
        padding: 2px 4px;
        gap: 2px;
    }
    
    .field-hint {
        font-size: 9px;
    }
    
    .form-actions {
        gap: 8px;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 10px 14px;
        font-size: 12px;
        gap: 6px;
    }
    
    .btn-primary svg,
    .btn-secondary svg {
        width: 13px;
        height: 13px;
    }
    
    .table-wrapper {
        border-radius: var(--radius-sm);
    }
    
    .table-toolbar {
        padding: 10px 8px;
        gap: 8px;
    }
    
    .table-toolbar > div {
        gap: 6px;
    }
    
    .table-title {
        font-size: 13px;
    }
    
    .search-bar {
        flex: 1;
        padding: 6px 10px;
        min-width: auto;
    }
    
    .search-bar input {
        font-size: 12px;
        min-width: 120px;
    }
    
    .refresh-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    thead th {
        font-size: 9px;
        padding: 6px 8px;
    }
    
    tbody td {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .td-code {
        font-size: 10px;
    }
    
    .td-name {
        max-width: 80px;
        font-size: 11px;
    }
    
    .field-input {
        padding: 9px 10px 9px 32px;
        font-size: 12px;
    }
    
    .input-icon {
        width: 28px;
        left: 6px;
    }
    
    .input-icon svg {
        width: 13px;
        height: 13px;
    }
    
    .input-suffix {
        right: 10px;
        font-size: 11px;
    }
    
    .badge-count {
        padding: 3px 6px;
        font-size: 10px;
    }
}
.btn-batch{
    width:28px;
    height:28px;
    border-radius:6px;
    border:none;
    background:#a6551f;
    color:white;
    font-weight:bold;
    cursor:pointer;
    font-size:16px;
}

.btn-batch:hover{
    background:#7c3d15;
}

/* ================================================================
   GLOBAL OVERFLOW FIX
   ================================================================ */
html, body { overflow-x: hidden; }
.app-wrapper { overflow-x: hidden; }

/* ================================================================
   TABLET (769px – 1024px) — sidebar & content tighter
   ================================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    :root { --sidebar-w: 220px; }

    .main-content {
        padding: 24px 20px;
    }

    .form-section {
        padding: 20px;
    }

    .search-bar input {
        width: 140px;
    }
}

/* ================================================================
   MOBILE (≤768px) — additional overrides not in main block
   ================================================================ */
@media (max-width: 768px) {
    /* Search bar fills available space */
    .search-bar {
        flex: 1;
        min-width: 0;
    }
    .search-bar input {
        width: 100%;
        min-width: 80px;
    }

    /* Toolbar right side fills width */
    .table-toolbar > div:last-child {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    /* Threshold + search row: grow search, shrink threshold */
    .threshold-control {
        flex-shrink: 0;
        padding: 5px 10px;
        font-size: 12px;
    }
    .threshold-input { width: 42px; }

    /* Safe-area for notched phones */
    .notification {
        top: env(safe-area-inset-top, 12px);
        right: 12px;
        left: 12px;
        max-width: 100%;
    }
}

/* ================================================================
   SMALL MOBILE (≤480px) — extra tightening
   ================================================================ */
@media (max-width: 480px) {
    .table-toolbar > div:first-child {
        width: 100%;
    }
    .search-bar { min-width: 0; }
}