:root{
  --bg1:#eaf6ff;
  --bg2:#d6eeff;
  --card:#ffffff;
  --ink:#0b2239;
  --muted:#4c6a82;
  --line:#b9dbf4;
  --accent:#1b7dbf;
  --accent2:#0f5f95;
  --danger:#b42318;
  --shadow: 0 10px 28px rgba(12, 61, 102, .14);
  --radius: 16px;
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
  color:var(--ink);
  background:
    radial-gradient(1200px 600px at 15% 10%, var(--bg2), transparent 60%),
    radial-gradient(900px 500px at 80% 20%, #c8eaff, transparent 55%),
    linear-gradient(180deg, var(--bg1), #f7fbff);
  min-height:100vh;
}

.page-header{
  padding: 22px 18px 10px;
  max-width: 1100px;
  margin: 0 auto;
}

.header-wrap{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;
}

h1{
  margin:0;
  font-size:22px;
  letter-spacing:.2px;
}

.subtitle{
  margin:6px 0 0;
  color:var(--muted);
  font-size:13px;
}

.layout{
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 18px 34px;
  display:grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 18px;
}

.card{
  background:var(--card);
  border:1px solid rgba(27,125,191,.18);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.card-head{
  padding: 14px 16px;
  background: linear-gradient(90deg, rgba(27,125,191,.10), rgba(27,125,191,.02));
  border-bottom:1px solid rgba(27,125,191,.14);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.card-head b{font-size:14px}

.card-body{padding:16px}

.chip{
  font-size:12px;
  color: var(--accent2);
  background: rgba(27,125,191,.10);
  border: 1px solid rgba(27,125,191,.22);
  padding: 6px 10px;
  border-radius: 999px;
  white-space:nowrap;
}

.chip-soft{
  background: rgba(27,125,191,.06);
}

form{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field{display:block}
.full{grid-column: 1 / -1;}

label{
  display:block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}

input, textarea{
  width:100%;
  border:1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  outline:none;
  transition: .15s border-color, .15s box-shadow;
  background: #fbfeff;
  color: var(--ink);
}

textarea{min-height: 92px; resize: vertical;}

input:focus, textarea:focus{
  border-color: rgba(27,125,191,.55);
  box-shadow: 0 0 0 4px rgba(27,125,191,.12);
}

input[readonly]{
  background: #f1f8ff;
  color: #35556e;
  cursor:not-allowed;
}

.actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top: 10px;
}

.btn{
  border:0;
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 650;
  cursor:pointer;
  transition: .15s transform, .15s filter;
  font-size: 14px;
}

.btn:active{transform: translateY(1px);}

.primary{
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  color:white;
  box-shadow: 0 8px 18px rgba(27,125,191,.22);
}

.ghost{
  background: rgba(27,125,191,.08);
  color: var(--accent2);
  border: 1px solid rgba(27,125,191,.20);
}

.danger{
  background: rgba(180,35,24,.10);
  color: var(--danger);
  border:1px solid rgba(180,35,24,.18);
}

.hint{
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

/* Receipt preview */
.receipt{padding: 18px;}

.receipt-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 12px;
}

.brand{display:flex; flex-direction:column; gap:4px;}

.brand .site{
  font-size:16px;
  font-weight:800;
  letter-spacing:.2px;
}

.brand .meta{
  font-size:12px;
  color:var(--muted);
}

.stamp{
  border: 1px dashed rgba(27,125,191,.55);
  background: rgba(27,125,191,.06);
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--accent2);
  text-align:right;
  min-width: 150px;
}

.stamp-k{font-weight:800;}
.stamp-v{margin-top:2px;}

.grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.kv{
  border: 1px solid rgba(185,219,244,.9);
  border-radius: 12px;
  padding: 10px 10px;
  background: linear-gradient(180deg, #ffffff, #f6fbff);
}

.k{
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
}

.v{
  font-size: 14px;
  font-weight: 700;
  word-break: break-word;
}

.big{grid-column: 1 / -1;}
.amount{
  font-size: 20px;
  font-weight: 900;
  color: var(--accent2);
}

.note{
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  border-top: 1px solid rgba(27,125,191,.14);
  padding-top: 10px;
}

@media (max-width: 920px){
  .layout{grid-template-columns: 1fr;}
}

/* Print only preview */
@media print{
  body{background:white}
  .page-header, .form-card, .subtitle{display:none !important;}
  .layout{padding:0; max-width: 100%;}
  .preview-card{border:0; box-shadow:none;}
}

.receipt-box {
    width: 400px;
    margin: 20px auto;
    padding: 20px;
    border: 1px solid #000;
    background: #fff;
}

@media print {
    body * {
        visibility: hidden;
    }
    #printArea, #printArea * {
        visibility: visible;
    }
    #printArea {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    #btnPrint {
        display: none;
    }
}

/* =========================
   REPORT PANEL (RIGHT SLIDER)
========================= */

.report-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100%;
  background: #ffffff;
  box-shadow: -4px 0 18px rgba(0,0,0,0.15);
  transition: right 0.3s ease;
  z-index: 999;
  display: flex;
  flex-direction: column;
}

.report-panel.active {
  right: 0;
}


/* =========================
   REPORT HEADER
========================= */

.report-header {
  position: relative;
  padding: 14px;
  background: #f4f8fc;
  border-bottom: 1px solid #d9e6f2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.report-header h3 {
  width: 100%;
  margin: 0 0 6px 0;
  font-size: 16px;
  color: #0b2239;
}

/* Filter labels */
.report-header label {
  font-size: 12px;
  color: #4c6a82;
}

/* Date inputs */
.report-header input[type="date"] {
  padding: 6px;
  font-size: 12px;
  border: 1px solid #b9dbf4;
  border-radius: 6px;
  background: #fff;
}

/* Close button */
#closeReport {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #4c6a82;
}

#closeReport:hover {
  color: #b42318;
}


/* =========================
   REPORT BODY
========================= */

.report-body {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}


/* =========================
   TABLE
========================= */

#reportTable {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

#reportTable th {
  background: #eaf4ff;
  font-size: 12px;
  font-weight: 600;
  color: #0b2239;
}

#reportTable th,
#reportTable td {
  border: 1px solid #dfeaf3;
  padding: 6px;
  font-size: 12px;
  text-align: left;
}

/* Editable reference input */
#reportTable input {
  width: 100%;
  border: none;
  background: #f9fbfd;
  font-size: 12px;
  padding: 4px;
}

#reportTable input:focus {
  outline: 1px solid #1b7dbf;
  background: #fff;
}


/* =========================
   BUTTONS INSIDE PANEL
========================= */

.report-body .btn {
  width: 100%;
  margin-top: 6px;
  padding: 9px;
  font-size: 13px;
  border-radius: 8px;
}


/* =========================
   SCROLLBAR (Optional nice look)
========================= */

.report-body::-webkit-scrollbar {
  width: 6px;
}

.report-body::-webkit-scrollbar-thumb {
  background: #b9dbf4;
  border-radius: 4px;
}


/* =========================
   MOBILE RESPONSIVE
========================= */

@media (max-width: 600px) {
  .report-panel {
    width: 100%;
  }
}

.transaction-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.transaction-row select {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

.transaction-row input {
  width: 120px;
}

.txn-total {
  margin-top: 8px;
  font-size: 14px;
  color: #0f5f95;
}

.receipt-link {
    color: #0B3D91;
    text-decoration: underline;
    cursor: pointer;
}
/* ===== MODERN LOADER ===== */
.loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loader::after {
  content: "";
  width: 45px;
  height: 45px;
  border: 5px solid #dbeafe;
  border-top: 5px solid #1b7dbf;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.hidden {
  display: none;
}

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

/* ===== MODERN TOAST ===== */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  color: #fff;
  background: #1b7dbf;
  box-shadow: 0 10px 20px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: #16a34a;
}

.toast.error {
  background: #dc2626;
}
/* ===== VALIDATION UI ===== */
.error-msg {
  color: #dc2626;
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

.input-error {
  border: 1px solid #dc2626 !important;
  background: #fff5f5;
}
.popup {
  position: fixed;
  top:0; left:0;
  width:100%; height:100%;
  background: rgba(0,0,0,0.5);
  display:flex;
  justify-content:center;
  align-items:center;
}

.popup-content {
  background:#fff;
  padding:20px;
  border-radius:8px;
  width:300px;
}

.hidden {
  display:none;
}
.unit-suggestions {
  position: absolute;
  background: #fff;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  width: 100%;
  max-height: 180px;
  overflow-y: auto;
  z-index: 2000;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.unit-suggestions.hidden {
  display: none;
}

.unit-suggestion-item {
  padding: 10px 12px;
  cursor: pointer;
}

.unit-suggestion-item:hover {
  background: #f3f8fd;
}

.unit-wrapper {
  position: relative;
  width: 100%;
}

.unit-suggestions {
  position: absolute;
  top: 100%;   /* directly below input */
  left: 0;
  width: 100%; /* same width as input */
  background: #fff;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 9999;
  box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.unit-suggestions.hidden {
  display: none;
}

.unit-suggestion-item {
  padding: 10px;
  cursor: pointer;
}

.unit-suggestion-item:hover {
  background: #f3f8fd;
}