:root {
  --bg: #f8fafc; --card: #fff; --border: #e5e7eb; --border-2: #d1d5db; --text: #111827; --muted: #6b7280; --muted-2: #9ca3af;
  --primary: #2563eb; --primary-600: #1d4ed8; --primary-50: #eff6ff; --primary-100: #dbeafe;
  --green: #16a34a; --green-50: #dcfce7; --red: #dc2626; --red-50: #fee2e2; --amber: #d97706; --amber-50: #fef3c7;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Roboto Mono', Menlo, Consolas, monospace;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.boot { padding: 40px; color: var(--muted); }

/* Layout */
.layout { display: grid; grid-template-columns: 215px 1fr; min-height: 100vh; }
.sidebar { background: #fff; border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 134px; border-bottom: 1px solid var(--border); padding: 12px; }
.brand img { max-height: 104px; max-width: 150px; }
.brand .brand-text { font-family: Georgia, 'Times New Roman', serif; font-size: 34px; color: #1f6f2b; letter-spacing: 1px; line-height: 1; margin-top: 4px; }
.brand .brand-sub { font-size: 7px; letter-spacing: 4px; color: #65a30d; margin-top: 2px; }
.nav { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.nav a, .nav button.nav-group { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 8px; color: #1f2937; text-decoration: none; font-size: 14.5px; border: 0; background: none; cursor: pointer; width: 100%; text-align: left; }
.nav a:hover, .nav button.nav-group:hover { background: #f3f4f6; }
.nav a.active { background: var(--primary-100); color: var(--primary-600); font-weight: 600; }
.nav .chev { margin-left: auto; transition: transform .15s; }
.nav .open .chev { transform: rotate(90deg); }
.nav .sub { display: flex; flex-direction: column; gap: 2px; padding-left: 30px; }
.nav .sub a { padding: 8px 12px; font-size: 13.5px; }
.nav .sub[hidden] { display: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 57px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 22px; gap: 16px; position: sticky; top: 0; z-index: 20; }
.topbar .title { font-weight: 600; font-size: 15px; }
.topbar .user { margin-left: auto; text-align: right; line-height: 1.15; }
.topbar .user b { font-size: 12px; display: block; }
.topbar .user small { color: var(--muted); font-size: 10.5px; }
.topbar .logout { background: none; border: 0; display: flex; gap: 6px; align-items: center; cursor: pointer; color: #374151; font-size: 13px; }
.menu-btn { display: none; background: none; border: 0; cursor: pointer; }
.content { padding: 28px 36px 60px; max-width: 1420px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--border); margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip-date { display: inline-block; background: #f3f4f6; color: #4b5563; font-size: 11.5px; padding: 3px 8px; border-radius: 6px; margin-top: 6px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.card-pad { padding: 20px 22px; }
.card h2, .card h3 { margin: 0; font-size: 17px; font-weight: 700; }
.card-head { display: flex; align-items: center; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } .g2 { grid-template-columns: repeat(2, 1fr); }
.stat { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.stat .ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.stat small { color: var(--muted); font-size: 12.5px; display: block; }
.stat b { font-size: 20px; }
.loc-card { padding: 18px 20px; }
.loc-card h3 { font-size: 15px; margin-bottom: 14px; }
.loc-card .row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.loc-card .row .ico { width: 26px; height: 26px; border-radius: 50%; background: #f3f4f6; display: grid; place-items: center; color: #4b5563; flex: none; }
.loc-card .row small { color: var(--muted); font-size: 12px; display: block; }
.loc-card .row b { font-size: 15px; }
.skeleton { background: linear-gradient(90deg, #f1f5f9, #e5e7eb, #f1f5f9); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 7px; border: 1px solid var(--border-2); background: #fff; cursor: pointer; font-size: 13.5px; font-weight: 500; white-space: nowrap; color: #1f2937; }
.btn:hover { background: #f9fafb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-outline { border-color: var(--primary); color: var(--primary); background: #fff; }
.btn-outline:hover { background: var(--primary-50); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { border-color: transparent; background: none; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.seg { display: inline-flex; gap: 6px; }
.seg .btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.icon-btn { background: none; border: 0; padding: 3px; cursor: pointer; color: #374151; border-radius: 5px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: #f3f4f6; color: var(--primary); }
.icon-btn.danger:hover { color: var(--red); background: var(--red-50); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Forms */
label.f { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: #111827; }
label.f .req { color: var(--red); }
.f-hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.input, .select, textarea.input { width: 100%; height: 38px; border: 1px solid var(--border-2); border-radius: 7px; padding: 0 11px; background: #fff; outline: none; font-size: 14px; }
textarea.input { height: auto; padding: 9px 11px; min-height: 90px; resize: vertical; }
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.input.ro { background: #f3f6fb; border-color: #e2e8f0; color: var(--primary-600); font-weight: 600; }
.input-wrap { position: relative; }
.input-wrap .suffix { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12.5px; }
.fgrid { display: grid; gap: 14px 14px; }
.f5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } .f3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .f2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d1d5db; border-radius: 22px; cursor: pointer; transition: .15s; }
.switch span::after { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(16px); }
.filter-lbl { font-size: 10.5px; letter-spacing: .4px; color: var(--muted); font-weight: 600; text-transform: uppercase; margin-bottom: 4px; }
.err { color: var(--red); font-size: 12.5px; margin-top: 6px; }
.info-box { background: var(--primary-50); border: 1px solid var(--primary-100); color: #1e3a8a; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.5; }
.warn-box { background: var(--amber-50); border: 1px solid #fde68a; color: #78350f; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.5; }

/* Table */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.t th { background: #f3f4f6; text-align: left; font-weight: 500; color: #374151; padding: 11px 12px; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.t th:first-child { border-top-left-radius: 8px; } table.t th:last-child { border-top-right-radius: 8px; }
table.t td { padding: 11px 12px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
table.t tr:hover td { background: #fafbfc; }
table.t .mono { font-family: var(--mono); font-size: 12px; color: #374151; white-space: nowrap; }
table.t td.nw { white-space: nowrap; }
table.t .num { text-align: right; }
.bordered { border: 1px solid var(--border); border-radius: 9px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11.5px; font-weight: 500; background: var(--primary-50); color: var(--primary-600); white-space: nowrap; }
.badge.green { background: var(--green-50); color: #15803d; border-radius: 20px; }
.badge.red { background: var(--red-50); color: #b91c1c; border-radius: 20px; }
.badge.gray { background: #f3f4f6; color: #4b5563; border-radius: 20px; }
.badge.amber { background: var(--amber-50); color: #92400e; border-radius: 20px; }
.badge.lama { background: #f3f4f6; color: #6b7280; font-size: 10px; padding: 1px 6px; margin-left: 6px; }
.actions-cell { display: flex; gap: 4px; white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 10px; padding: 14px 4px 0; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; margin-left: auto; }
.pager .pages button { min-width: 32px; height: 32px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; padding: 0 8px; }
.pager .pages button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager .pages button:disabled { opacity: .4; cursor: not-allowed; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

/* Modal / drawer */
.overlay { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.lg { max-width: 640px; } .modal.xl { max-width: 900px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 12px; }
.modal-head h3 { margin: 0; font-size: 18px; } .modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.modal-close { margin-left: auto; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: #fff; cursor: pointer; display: grid; place-items: center; color: #4b5563; flex: none; }
.modal-body { padding: 6px 22px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.overlay.drawer { justify-content: flex-end; padding: 0; }
.drawer .modal { max-width: 68vw; height: 100vh; max-height: 100vh; border-radius: 0; }
.drawer .modal-head { border-bottom: 1px solid var(--border); padding: 18px 22px; }
.drawer .modal-head h3 { font-size: 17px; }
.section { border: 1px solid var(--border); border-radius: 10px; padding: 16px 16px 18px; margin-bottom: 18px; }
.section > h4 { margin: 0 0 14px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.baris { border: 1px solid var(--border); border-radius: 10px; padding: 14px 20px 16px; margin-top: 12px; }
.baris-head { display: flex; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.baris-head b { font-size: 15px; }
.baris-head .btn { margin-left: auto; }
.btn-soft-red { background: #fca5a5; border-color: #fca5a5; color: #fff; }
.btn-soft-red:hover { background: #f87171; }
.grade-box { background: #f3f4f6; border-radius: 10px; padding: 14px; margin-top: 16px; }
.grade-row { display: grid; grid-template-columns: 1fr 110px 110px 28px; gap: 10px; align-items: end; margin-top: 10px; }
.sum-rows { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; font-size: 13px; }
.sum-rows div { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
.sum-rows div b { color: var(--text); }
.total-box { background: var(--primary-50); border: 1px solid var(--primary-100); border-radius: 10px; padding: 14px 18px; display: flex; gap: 30px; flex-wrap: wrap; }
.total-box small { color: var(--muted); display: block; font-size: 12px; }
.total-box b { font-size: 18px; color: var(--primary-600); }
.det-block { background: #f3f4f6; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.det-block h4 { margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); font-size: 15px; }
.det-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.det-grid small { color: var(--muted); font-size: 12.5px; display: block; }
.det-grid b { font-weight: 500; font-size: 14.5px; }
.pre { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; line-height: 1.6; }

/* Popover */
.pop { position: absolute; z-index: 60; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.15); padding: 12px; min-width: 220px; }
.pop .opt { display: flex; align-items: center; gap: 8px; padding: 6px 4px; cursor: pointer; font-size: 13.5px; }

/* Toast */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 11px 16px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 8px 20px rgba(0,0,0,.25); max-width: 380px; animation: fade .15s; }
.toast.ok { background: #166534; } .toast.bad { background: #991b1b; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #f0fdf4, #eff6ff); }
.login-card { width: 100%; max-width: 380px; padding: 30px 28px; }
.login-card .brand { border: 0; height: auto; padding: 0 0 16px; }
.login-card h2 { text-align: center; font-size: 18px; margin: 0 0 4px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 13px; }

/* Dashboard tables */
.stock-wrap { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 16px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 56px; gap: 10px; align-items: center; font-size: 12.5px; margin-bottom: 8px; }
.bar-row .bar { height: 10px; background: #eef2f7; border-radius: 10px; overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--primary); border-radius: 10px; }
.sup-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed #eef0f3; font-size: 13px; }
.sec-title { font-size: 15px; font-weight: 700; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { background: none; border: 0; padding: 9px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13.5px; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.receipt-prev { background: #fff; border: 1px solid var(--border); box-shadow: 0 2px 10px rgba(0,0,0,.08); width: 270px; padding: 16px 12px; font-family: var(--mono); font-size: 9.5px; line-height: 1.45; white-space: pre-wrap; margin: 0 auto; }
.receipt-prev .c { text-align: center; } .receipt-prev .b { font-weight: 700; }

@media (max-width: 1100px) { .struk-grid { grid-template-columns: 1fr !important; } .f5 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(2, 1fr); } .stock-wrap { grid-template-columns: 1fr; } .drawer .modal { max-width: 100vw; } }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 240px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  .sidebar.show { transform: none; }
  .menu-btn { display: block; }
  .content { padding: 18px 14px 50px; }
  .g3, .g2, .f3, .f2 { grid-template-columns: 1fr; }
  .f5 { grid-template-columns: 1fr 1fr; }
  .topbar .title { font-size: 13px; }
}
@media print {
  .sidebar, .topbar, .page-head .actions, .no-print { display: none !important; }
  .layout { display: block; } .content { padding: 0; } body { background: #fff; }
  .card { border-color: #ccc; break-inside: avoid; }
}
