:root {
  --app-sidebar-width: 280px;
  --app-bg: #f6f7f9;
  --app-panel: #ffffff;
  --app-border: #dfe3e8;
  --app-text: #17202a;
  --app-muted: #667085;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--app-bg);
  color: var(--app-text);
  font-size: 14px;
  letter-spacing: 0;
}

.login-body {
  background:
    linear-gradient(135deg, rgba(13, 110, 253, 0.08), rgba(25, 135, 84, 0.08)),
    var(--app-bg);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 430px);
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.12);
}

.login-panel h1 {
  font-size: 28px;
  margin: 16px 0 6px;
}

.brand-lock {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #0d6efd;
  color: #fff;
  font-size: 26px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--app-sidebar-width) 1fr;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  background: #ffffff;
  border-right: 1px solid var(--app-border);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--app-text);
  text-decoration: none;
}

.app-brand span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: #0d6efd;
}

.app-nav {
  gap: 4px;
}

.app-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: #344054;
  border-radius: 8px;
  padding: 9px 12px;
}

.app-nav .nav-link.active,
.app-nav .nav-link:hover {
  color: #0b5ed7;
  background: #eef5ff;
}

.sidebar-user {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--app-border);
}

.app-main {
  min-width: 0;
  padding: 24px;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.app-topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.section-panel,
.print-sheet {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 22px;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--app-muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric-tile {
  min-height: 142px;
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 18px;
}

.metric-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 20px;
}

.metric-tile span,
.metric-tile small {
  display: block;
  color: var(--app-muted);
}

.metric-tile strong {
  display: block;
  font-size: 24px;
  margin: 2px 0;
}

.item-table-wrap {
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.item-table {
  margin-bottom: 0;
}

.item-table th,
.item-table td {
  min-width: 140px;
}

.item-table th:first-child,
.item-table td:first-child {
  min-width: 280px;
}

.stock-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stock-chips span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 12px;
}

.selected-document {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.selected-document > div {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.selected-document span {
  display: block;
  color: var(--app-muted);
  font-size: 12px;
}

.permission-matrix {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  overflow: hidden;
}

.permission-row {
  display: grid;
  grid-template-columns: 1fr 110px 110px;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-top: 1px solid var(--app-border);
}

.permission-row:first-child {
  border-top: 0;
}

.permission-head {
  background: #f8fafc;
  font-weight: 700;
}

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

.empty-state i {
  display: block;
  margin-bottom: 12px;
  font-size: 42px;
  color: #98a2b3;
}

.empty-state h2 {
  color: var(--app-text);
  font-size: 22px;
}

.print-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.print-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--app-border);
}

.print-header h2 {
  margin: 0;
  font-size: 28px;
}

.print-sheet h3 {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--app-muted);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: static;
    height: auto;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .app-main,
  .app-sidebar {
    padding: 16px;
  }

  .section-heading,
  .app-topbar,
  .print-header {
    flex-direction: column;
    align-items: stretch;
  }

  .metric-grid,
  .selected-document {
    grid-template-columns: 1fr;
  }

  .permission-row {
    grid-template-columns: 1fr 74px 74px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-sidebar,
  .app-topbar,
  .no-print,
  .alert {
    display: none !important;
  }

  .app-shell,
  .app-main {
    display: block;
    padding: 0;
  }

  .print-sheet {
    border: 0;
    padding: 0;
  }
}

/* Popup-first forms + date filters (Update 017) */
.app-form-modal .modal-content {
  border: 0;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
}

.app-form-modal .modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--app-border);
}

.app-form-modal .modal-body {
  padding: 20px;
  background: #fbfcfe;
}

.app-form-modal .modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: #fff;
  border-top: 1px solid var(--app-border);
}

.popup-form-launcher {
  display: flex;
  justify-content: flex-end;
  padding: 10px 0;
}

.list-date-filter {
  min-width: 155px;
}

@media (max-width: 700px) {
  .app-form-modal .modal-content {
    border-radius: 0;
  }

  .app-form-modal .modal-header,
  .app-form-modal .modal-body,
  .app-form-modal .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .app-form-modal .modal-footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .app-form-modal .modal-footer .btn,
  .popup-form-launcher .btn {
    width: 100%;
  }

  .list-date-filter {
    width: calc(50% - 4px);
    min-width: 135px;
  }

  .table-responsive {
    border-radius: 8px;
  }
}


/* Update 024: modal Stock Opname Online harus selalu dapat di-scroll */
.stock-opname-modal .modal-dialog {
  height: calc(100% - var(--bs-modal-margin) * 2);
}

.stock-opname-modal .modal-content {
  max-height: 100%;
  overflow: hidden;
}

.stock-opname-modal-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.stock-opname-modal-form .modal-header,
.stock-opname-modal-form .modal-footer {
  flex: 0 0 auto;
}

.stock-opname-modal-form .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.stock-opname-modal-form .table-responsive {
  overflow-x: auto;
  overflow-y: visible;
}

.stock-opname-modal-form thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bs-tertiary-bg, #f8f9fa);
}

@media (max-width: 991.98px) {
  .stock-opname-modal .modal-dialog {
    height: 100%;
    margin: 0;
  }

  .stock-opname-modal .modal-content,
  .stock-opname-modal-form {
    height: 100%;
    max-height: 100%;
  }

  .stock-opname-modal-form .modal-body {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }

  .stock-opname-modal-form .modal-footer {
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
  }
}

/* Update 025: Stock Opname Online dipindahkan ke halaman khusus */
.online-opname-page-form .online-opname-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.online-opname-page-form .online-opname-table {
  min-width: 980px;
}

.online-opname-page-form .online-opname-table thead th {
  white-space: nowrap;
}

.online-opname-page-form [data-opname-physical] {
  min-width: 125px;
}

@media (max-width: 767.98px) {
  .online-opname-page .section-heading {
    gap: 1rem;
  }

  .online-opname-page .section-heading > div:last-child,
  .online-opname-page-form .btn {
    width: 100%;
  }
}

/* Update 029 — UI refresh + cashier workspace */
:root {
  --app-bg: #f2f5f3;
  --app-panel: #ffffff;
  --app-border: #dde5df;
  --app-text: #17211b;
  --app-muted: #6b756e;
  --app-radius: 14px;
}

body {
  background:
    radial-gradient(circle at 84% 5%, rgba(34, 139, 94, .07), transparent 24%),
    var(--app-bg);
}

.app-main { padding: 22px 26px 34px; }
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: -22px -26px 22px;
  padding: 15px 26px;
  background: rgba(242, 245, 243, .88);
  border-bottom: 1px solid rgba(221, 229, 223, .82);
  backdrop-filter: blur(14px);
}
.app-topbar h1 { font-size: 23px; font-weight: 800; letter-spacing: -.02em; }
.section-panel,
.metric-tile,
.print-sheet {
  border-radius: var(--app-radius);
  border-color: var(--app-border);
  box-shadow: 0 6px 24px rgba(25, 55, 38, .045);
}
.section-panel { padding: 24px; }
.section-heading h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.form-control,
.form-select,
.input-group-text { border-radius: 10px; border-color: #d7e0da; min-height: 42px; }
.input-group > .form-control,
.input-group > .form-select,
.input-group > .input-group-text { border-radius: 0; }
.input-group > :first-child { border-radius: 10px 0 0 10px !important; }
.input-group > :last-child { border-radius: 0 10px 10px 0 !important; }
.btn { border-radius: 10px; font-weight: 650; }
.table > :not(caption) > * > * { padding: .78rem .7rem; }
.table thead th { color: #526057; font-size: 12px; text-transform: uppercase; letter-spacing: .035em; background: #f7f9f7; }

.cashier-shell { max-width: 1680px; margin: 0 auto; }
.cashier-header-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding: 20px 22px;
  background: linear-gradient(135deg, #ffffff 0%, #f5faf6 100%);
  border: 1px solid var(--app-border);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(25, 55, 38, .05);
}
.cashier-header-card h2 { font-size: 25px; font-weight: 850; letter-spacing: -.025em; }
.cashier-eyebrow { color: #25814d; text-transform: uppercase; letter-spacing: .09em; font-size: 11px; font-weight: 800; }
.cashier-session-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.cashier-session-meta span { display: inline-flex; gap: 7px; align-items: center; padding: 8px 11px; border-radius: 999px; background: #eef6f0; color: #315c40; font-size: 12px; font-weight: 700; }
.cashier-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(360px, .72fr); gap: 16px; align-items: start; }
.cashier-catalog-panel,
.cashier-cart-panel { background: #fff; border: 1px solid var(--app-border); border-radius: 16px; box-shadow: 0 8px 28px rgba(25, 55, 38, .05); }
.cashier-catalog-panel { padding: 18px; min-width: 0; }
.cashier-cart-panel { position: sticky; top: 86px; padding: 18px; max-height: calc(100vh - 105px); overflow: auto; }
.cashier-toolbar { display: grid; grid-template-columns: minmax(220px, .55fr) minmax(280px, 1fr); gap: 12px; align-items: end; }
.cashier-category-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 12px; scrollbar-width: thin; }
.cashier-category-tabs .btn { white-space: nowrap; color: #4b5d51; background: #f5f8f6; border: 1px solid #e0e8e2; }
.cashier-category-tabs .btn.active { color: #fff; background: #247a49; border-color: #247a49; }
.cashier-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 11px; }
.cashier-product-card { position: relative; min-height: 160px; display: flex; flex-direction: column; align-items: stretch; text-align: left; padding: 14px; color: var(--app-text); background: #fff; border: 1px solid #e1e8e3; border-radius: 14px; transition: transform .13s ease, box-shadow .13s ease, border-color .13s ease; }
.cashier-product-card:not(:disabled):hover { transform: translateY(-2px); border-color: #8dc4a1; box-shadow: 0 10px 22px rgba(25, 87, 52, .10); }
.cashier-product-card:disabled { opacity: .48; cursor: not-allowed; background: #f8f9f8; }
.cashier-product-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: #e9f5ed; color: #247a49; font-weight: 850; }
.cashier-product-copy { display: flex; flex-direction: column; gap: 4px; margin-top: 11px; min-width: 0; }
.cashier-product-copy strong { font-size: 14px; line-height: 1.3; }
.cashier-product-copy small { color: var(--app-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cashier-product-bottom { margin-top: auto; padding-top: 12px; display: flex; justify-content: space-between; align-items: end; gap: 8px; }
.cashier-product-bottom strong { color: #185d36; font-size: 14px; }
.cashier-product-bottom small { text-align: right; font-size: 11px; }
.cashier-empty-products { grid-column: 1 / -1; min-height: 240px; display: grid; place-items: center; align-content: center; gap: 6px; color: var(--app-muted); text-align: center; }
.cashier-empty-products i { font-size: 36px; }
.cashier-cart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 13px; border-bottom: 1px solid #edf1ee; }
.cashier-cart-head h3 { margin: 1px 0 0; font-size: 20px; font-weight: 850; }
.cashier-cart-count { padding: 6px 9px; border-radius: 999px; background: #eef6f0; color: #2b6843; font-size: 12px; font-weight: 750; }
.cashier-cart-items { min-height: 145px; max-height: 330px; overflow: auto; padding: 8px 2px 8px 0; }
.cashier-empty-cart { min-height: 140px; display: grid; place-items: center; align-content: center; gap: 5px; color: #7d8981; text-align: center; }
.cashier-empty-cart i { font-size: 31px; }
.cashier-cart-row { padding: 11px 0; border-bottom: 1px solid #eef2ef; }
.cashier-cart-row-main,
.cashier-cart-row-bottom { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.cashier-cart-row-main strong { display: block; font-size: 13px; }
.cashier-cart-row-main small { display: block; color: var(--app-muted); font-size: 11px; margin-top: 2px; }
.cashier-remove { border: 0; color: #a84646; background: transparent; }
.cashier-cart-row-bottom { margin-top: 9px; }
.cashier-qty-control { display: inline-grid; grid-template-columns: 34px 48px 34px; border: 1px solid #dfe7e1; border-radius: 10px; overflow: hidden; }
.cashier-qty-control button { border: 0; background: #f3f7f4; font-weight: 850; }
.cashier-qty-control input { width: 48px; border: 0; border-left: 1px solid #e2e8e3; border-right: 1px solid #e2e8e3; text-align: center; outline: 0; }
.cashier-customer-box { padding: 13px 0; border-top: 1px solid #edf1ee; }
.cashier-summary { padding: 13px 0; border-top: 1px solid #edf1ee; border-bottom: 1px solid #edf1ee; }
.cashier-summary > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; }
.cashier-tax-input { width: 112px; }
.cashier-grand-total { margin-top: 7px; padding-top: 10px !important; border-top: 1px dashed #cfd9d2; }
.cashier-grand-total span { font-weight: 800; }
.cashier-grand-total strong { color: #17663a; font-size: 22px; }
.cashier-payment-box { padding-top: 13px; }
.cashier-payment-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.cashier-payment-options label { cursor: pointer; }
.cashier-payment-options input { position: absolute; opacity: 0; pointer-events: none; }
.cashier-payment-options span { min-height: 58px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; border: 1px solid #dce5df; border-radius: 11px; background: #fafcfb; font-size: 11px; font-weight: 700; }
.cashier-payment-options span i { font-size: 18px; }
.cashier-payment-options input:checked + span { color: #17663a; background: #eaf6ee; border-color: #73b58d; box-shadow: inset 0 0 0 1px #73b58d; }
.cashier-change-row { display: flex; justify-content: space-between; color: #536158; }
.cashier-change-row strong { color: #17663a; }
.cashier-pay-button { min-height: 54px; font-weight: 850; }

@media (max-width: 1199.98px) {
  .cashier-layout { grid-template-columns: minmax(0, 1.4fr) 350px; }
  .cashier-product-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
@media (max-width: 991.98px) {
  .app-main { padding: 16px; }
  .app-topbar { margin: -16px -16px 16px; padding: 12px 16px; }
  .cashier-layout { grid-template-columns: 1fr; }
  .cashier-cart-panel { position: static; max-height: none; }
  .cashier-cart-items { max-height: none; }
}
@media (max-width: 640px) {
  .cashier-header-card { align-items: flex-start; flex-direction: column; padding: 16px; }
  .cashier-session-meta { justify-content: flex-start; }
  .cashier-catalog-panel, .cashier-cart-panel { padding: 13px; border-radius: 13px; }
  .cashier-toolbar { grid-template-columns: 1fr; }
  .cashier-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cashier-product-card { min-height: 154px; padding: 11px; }
  .cashier-product-bottom { align-items: flex-start; flex-direction: column; }
  .cashier-product-bottom small { text-align: left; }
  .cashier-payment-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
