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

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: #f0f2f5;
  color: #1c1e21;
  line-height: 1.5;
}

.navbar {
  background: #2c3e50;
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.navbar a { color: #fff; text-decoration: none; }
.navbar .brand { font-size: 20px; font-weight: 600; }
.navbar .links { display: flex; align-items: center; flex-wrap: wrap; }
.navbar .links a { margin-left: 16px; }
.navbar .links a:hover { text-decoration: underline; }
.navbar .nav-user { margin-left: 16px; font-size: 13px; opacity: .85; border-left: 1px solid rgba(255,255,255,.3); padding-left: 16px; }

/* Autocomplete produk */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 999;
  background: #fff; border: 1px solid #ccd0d5; border-top: none;
  border-radius: 0 0 6px 6px; max-height: 200px; overflow-y: auto;
  box-shadow: 0 4px 8px rgba(0,0,0,.1);
}
.autocomplete-list div {
  padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f0f0f0;
}
.autocomplete-list div:hover { background: #f0f7ff; }
.autocomplete-list div span { color: #888; font-size: 12px; margin-left: 8px; }

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.1); padding: 18px; border-left: 4px solid #2980b9; }
.stat-label { font-size: 13px; color: #777; }
.stat-value { font-size: 24px; font-weight: 700; color: #2c3e50; margin: 4px 0; }
.stat-sub { font-size: 12px; color: #999; }
.bar-chart { display: flex; align-items: flex-end; gap: 16px; height: 220px; padding-top: 20px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 60%; background: linear-gradient(180deg, #3498db, #2980b9); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-amount { font-size: 11px; color: #555; margin-bottom: 4px; }
.bar-label { font-size: 12px; color: #777; margin-top: 6px; }

/* Halaman login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { width: 360px; max-width: 90%; }
.login-box h1 { text-align: center; font-size: 20px; margin-bottom: 2px; }
.login-sub { text-align: center; color: #777; margin-bottom: 18px; }
.login-hint { font-size: 12px; color: #888; text-align: center; margin-top: 16px; }

.container { max-width: 960px; margin: 24px auto; padding: 0 16px; }

.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  padding: 24px;
  margin-bottom: 20px;
}

h1, h2 { margin-bottom: 16px; color: #2c3e50; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e4e6eb; }
th { background: #f7f8fa; font-weight: 600; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  color: #fff;
  background: #2980b9;
}
.btn:hover { opacity: .9; }
.btn-success { background: #27ae60; }
.btn-danger { background: #c0392b; }
.btn-secondary { background: #7f8c8d; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #ccd0d5;
  border-radius: 6px;
  font-size: 14px;
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
}
.alert-success { background: #d4edda; color: #155724; }
.alert-error { background: #f8d7da; color: #721c24; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: #e4e6eb;
}

/* Bahagian item dinamik */
.item-row { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; }
.item-row .desc { flex: 3; min-width: 120px; }
.item-row .cls, .item-row .ttype { flex: 2; min-width: 90px; }
.item-row .qty, .item-row .price, .item-row .trate { flex: 1; min-width: 60px; }
.item-row .uomsel { flex: 1; min-width: 60px; }
.item-row .form-control { padding: 7px 8px; font-size: 13px; }
.item-row .remove {
  background: #c0392b; color: #fff; border: none;
  border-radius: 6px; padding: 8px 12px; cursor: pointer; flex: 0 0 auto;
}
.item-head { margin-bottom: 6px; }
.item-head th { font-size: 12px; padding: 4px 8px; background: transparent; border: none; }

/* Resit */
.receipt-box {
  max-width: 420px;
  margin: 0 auto;
  border: 1px solid #ddd;
  padding: 24px;
}
.receipt-box .shop-name { text-align: center; font-size: 22px; font-weight: 700; }
.receipt-box .shop-info { text-align: center; font-size: 13px; color: #555; margin-bottom: 12px; }
.receipt-box hr { border: none; border-top: 1px dashed #aaa; margin: 12px 0; }
.receipt-meta { font-size: 13px; margin-bottom: 8px; }
.receipt-meta div { display: flex; justify-content: space-between; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-weight: 700; font-size: 18px; border-top: 1px solid #000; padding-top: 6px; }
.thank-you { text-align: center; margin-top: 16px; font-size: 13px; }

/* Format e-Invois (LHDN) */
.einvoice { font-size: 13px; }
.ei-header { display: flex; justify-content: space-between; align-items: flex-start; }
.ei-title h2 { margin: 0 0 6px; }
.ei-qr { text-align: center; }
.ei-qr #qrcode { display: inline-block; }
.ei-status { font-size: 12px; margin-top: 4px; }
.ei-parties { display: flex; gap: 24px; margin: 12px 0; }
.ei-parties .party { flex: 1; font-size: 12px; line-height: 1.6; }
.party-title { font-weight: 700; color: #2c3e50; border-bottom: 2px solid #2c3e50; margin-bottom: 4px; }
.ei-doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 24px; font-size: 12px; margin-bottom: 12px; }
.ei-doc-meta div { display: flex; justify-content: space-between; }
.ei-doc-meta span { color: #555; }
.ei-items { font-size: 12px; }
.ei-items th, .ei-items td { padding: 6px 8px; }
.ei-totals { max-width: 320px; margin-left: auto; }
.ei-footer { font-size: 11px; color: #777; text-align: center; }

@media print {
  @page { size: A4; margin: 14mm; }
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .container { margin: 0; padding: 0; max-width: 100%; }
  .receipt-box { border: none; max-width: 100%; }
  .card { box-shadow: none; padding: 0; margin: 0; border-radius: 0; }
  .einvoice { font-size: 10.5px; }
  .ei-parties { page-break-inside: avoid; }
  .ei-items { page-break-inside: auto; }
  .ei-items tr { page-break-inside: avoid; page-break-after: auto; }
  .ei-items thead { display: table-header-group; }
  .ei-totals { page-break-inside: avoid; }
  .ei-footer { page-break-inside: avoid; }
  a[href]:after { content: ""; }
  .badge { border: 1px solid #999; }
}
