:root {
  --color-bg: #f0f6fb;
  --color-surface: #ffffff;
  --color-border: #dce8f2;
  --color-text: #14304a;
  --color-muted: #5d7891;
  --color-primary: #0891b2;
  --color-primary-dark: #0e7490;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-info: #2563eb;
  --radius: 14px;
  --sidebar-bg: #0b2f42;
  --sidebar-bg-active: #ffffff;
  --sidebar-text: rgba(255, 255, 255, 0.78);
  --sidebar-text-active: #0b2f42;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* --- Sidebar app shell --- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  text-decoration: none;
  padding: 6px 10px 22px;
}

.sidebar-brand .brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  width: 52px;
  border-radius: 9px;
  background: #fff;
  padding: 3px 4px;
  flex-shrink: 0;
}
.sidebar-brand .brand-icon .brand-mark { width: 100%; height: 100%; display: block; object-fit: contain; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar-link.active { background: var(--sidebar-bg-active); color: var(--sidebar-text-active); }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* Colour-coded module icons: each nav item gets a small filled chip in its own accent colour
   (set inline per-item in header.php) so the sidebar reads at a glance, matching the spec's call
   for a "modern, colourful" interface. The icon itself stays white-stroked inside the chip. */
.nav-icon-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  flex-shrink: 0;
  color: #fff;
}
.nav-icon-chip .nav-icon { width: 15px; height: 15px; }

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text);
  padding: 4px 8px;
}

.topbar-title { font-size: 1.3rem; margin: 0; }

.topbar-user { display: flex; align-items: center; gap: 14px; }

.notif-bell { position: relative; color: var(--color-text); display: flex; }
.notif-dot {
  position: absolute; top: -6px; right: -8px;
  background: var(--color-danger); color: #fff;
  font-size: 0.62rem; font-weight: 700;
  border-radius: 999px; padding: 1px 5px; line-height: 1.3;
}

.avatar-circle {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
}

.topbar-user-info { text-align: right; }
.topbar-user-name { font-size: 0.85rem; font-weight: 600; }

.role-badge {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.03em;
  background: #e0f2fe; color: var(--color-primary-dark);
}
.role-badge.role-admin { background: #ede9fe; color: #5b21b6; }
.role-badge.role-director { background: #ede9fe; color: #5b21b6; }
.role-badge.role-manager { background: #dcfce7; color: #166534; }
.role-badge.role-finance { background: #fef3c7; color: #92400e; }
.role-badge.role-supervisor { background: #fce7f3; color: #9d174d; }
.role-badge.role-cashier { background: #e0f2fe; color: #0369a1; }
.role-badge.role-storekeeper { background: #ffedd5; color: #9a3412; }
.role-badge.role-auditor { background: #f3f4f6; color: #374151; }
.role-badge.role-readonly { background: #f3f4f6; color: #6b7280; }

main.container { padding-top: 24px; padding-bottom: 60px; }

h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.2rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
p.subtitle { color: var(--color-muted); margin-top: 0; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  overflow-x: auto;
  box-shadow: 0 4px 16px rgba(11, 47, 66, 0.05);
}
.card + .card { margin-top: 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 4px 16px rgba(11, 47, 66, 0.05);
}
.stat.stat-success { border-left-color: var(--color-success); }
.stat.stat-warning { border-left-color: var(--color-warning); }
.stat.stat-danger { border-left-color: var(--color-danger); }
.stat.stat-info { border-left-color: var(--color-info); }
.stat .value { font-size: 1.6rem; font-weight: 700; color: var(--color-text); }
.stat .label { color: var(--color-muted); font-size: 0.82rem; margin-top: 4px; }

label {
  display: block; font-weight: 600; font-size: 0.88rem;
  margin-bottom: 6px; margin-top: 14px;
}
label:first-child { margin-top: 0; }

input[type=text], input[type=number], input[type=email], input[type=password],
input[type=date], input[type=month], input[type=file], input[type=tel],
select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.15);
}
.field-hint { font-size: 0.78rem; color: var(--color-muted); margin-top: 4px; }
.two-col { display: flex; gap: 12px; }
.two-col > div { flex: 1; }
.three-col { display: flex; gap: 12px; }
.three-col > div { flex: 1; }

.btn {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-top: 16px;
}
.btn:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; margin-top: 0; }
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--color-success); }
.btn-success:hover { background: #15803d; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { display: block; width: 100%; text-align: center; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); }
th { color: var(--color-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }

/* Section 26: colour-coded transaction statuses, used across POS/banking/stock */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; text-decoration: none; }
.badge-green { background: #dcfce7; color: #166534; }   /* Approved / Completed */
.badge-orange { background: #fef3c7; color: #92400e; }  /* Pending */
.badge-red { background: #fee2e2; color: #991b1b; }     /* Rejected / Overdue / Critical */
.badge-blue { background: #dbeafe; color: #1e40af; }    /* Processing */
.badge-grey { background: #f3f4f6; color: #6b7280; }    /* Cancelled */

.inline-form { display: inline; }
.btn-link-danger { background: none; border: none; color: var(--color-danger); cursor: pointer; padding: 0; font-size: inherit; font-family: inherit; text-decoration: underline; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 0.92rem; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

.site-footer { border-top: 1px solid var(--color-border); color: var(--color-muted); font-size: 0.82rem; padding: 18px 0; text-align: center; }

body.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #22d3ee 0%, #0891b2 45%, #0b2f42 100%);
}
body.auth-body main.container { padding: 20px; }
.login-wrap { max-width: 380px; width: 100%; margin: 0; }
.login-wrap .card {
  margin-bottom: 0; border: none; border-radius: 20px; padding: 36px 32px;
  box-shadow: 0 24px 60px rgba(11, 47, 66, 0.35);
}
.login-wrap h1 { text-align: center; }
.login-wrap p.subtitle { text-align: center; margin-bottom: 24px; }
.login-wrap .btn { width: 100%; text-align: center; padding: 12px 18px; font-size: 0.98rem; }
.login-logo {
  display: flex; align-items: center; justify-content: center;
  width: 150px; height: 84px; border-radius: 20px; margin: 0 auto 16px;
  background: #fff; padding: 8px 14px;
  box-shadow: 0 6px 18px rgba(11, 47, 66, 0.18);
}
.login-logo .brand-mark { width: 100%; height: 100%; object-fit: contain; display: block; }

.text-muted { color: var(--color-muted); }
.text-sm { font-size: 0.85rem; }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.mt-0 { margin-top: 0; }
.actions-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   POS sale screen — product grid runs full width; the cart is a horizontal
   bar pinned to the bottom of the viewport so it's always visible while
   scrolling/browsing products, matching a typical POS-terminal layout.
--------------------------------------------------------------------- */
.pos-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.pos-products-card { margin-bottom: 24px; }
.pos-tab {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text); font-size: 0.85rem;
  font-weight: 600; cursor: pointer;
}
.pos-tab.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.product-btn {
  border: 1px solid var(--color-border); background: var(--color-surface);
  border-radius: 12px; padding: 14px 10px; text-align: center; cursor: pointer;
  font-family: inherit;
}
.product-btn:hover { border-color: var(--color-primary); box-shadow: 0 4px 14px rgba(8,145,178,0.12); }
.product-btn .pname { font-weight: 700; font-size: 0.88rem; display: block; }
.product-btn .pprice { color: var(--color-primary-dark); font-weight: 600; font-size: 0.82rem; margin-top: 4px; display: block; }
.product-btn .pstock { color: var(--color-muted); font-size: 0.72rem; margin-top: 2px; display: block; }
.product-btn .pstock.low { color: var(--color-danger); font-weight: 600; }
.product-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.cart-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -8px 24px rgba(11, 47, 66, 0.1);
  padding: 18px 22px;
  max-height: 44vh;
  overflow-y: auto;
}
.cart-bar-col { flex: 1; min-width: 200px; }
.cart-bar-col h3 { margin-top: 0; }
.cart-bar-customer { flex: 0.8; min-width: 180px; }
.cart-bar-items { flex: 1.3; }
.cart-bar-totals { flex: 0.9; min-width: 190px; }
.cart-bar-payment { flex: 1.1; min-width: 220px; }
.cart-bar-payment .btn-block { margin-top: 14px; }

.cart-items { max-height: 30vh; overflow-y: auto; margin: 10px 0; }
.cart-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.cart-row:last-child { border-bottom: none; }
.cart-row .ci-name { flex: 1; font-size: 0.85rem; font-weight: 600; }
.cart-row .ci-sub { font-size: 0.72rem; color: var(--color-muted); }
.cart-row .ci-qty { width: 54px; padding: 4px 6px; text-align: center; }
.cart-row .ci-total { width: 70px; text-align: right; font-weight: 600; font-size: 0.85rem; }
.cart-row .ci-remove { background: none; border: none; color: var(--color-danger); cursor: pointer; font-size: 1.1rem; padding: 0 4px; }
.cart-empty { color: var(--color-muted); font-size: 0.85rem; text-align: center; padding: 30px 0; }

.cart-totals { border-top: 1px dashed var(--color-border); padding-top: 10px; margin-top: 6px; }
.cart-totals-row { display: flex; justify-content: space-between; font-size: 0.88rem; padding: 3px 0; }
.cart-totals-row.grand { font-size: 1.15rem; font-weight: 700; border-top: 1px solid var(--color-border); margin-top: 6px; padding-top: 8px; }

.pay-methods { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pay-method-chip {
  border: 1px solid var(--color-border); background: var(--color-surface);
  border-radius: 8px; padding: 6px 10px; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; color: var(--color-text);
}
.pay-method-chip.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* Receipt / print */
.receipt-box { max-width: 380px; margin: 0 auto; font-family: 'Courier New', monospace; }
.receipt-box hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }
.receipt-line { display: flex; justify-content: space-between; font-size: 0.85rem; }
.receipt-center { text-align: center; }

/* ---------------------------------------------------------------------
   Corporate document print layout (Quotation / Proforma / Invoice / Delivery
   Note) — styled to match the business's existing quotation template.
--------------------------------------------------------------------- */
.doc-print { max-width: 800px; margin: 0 auto; padding: 20px; color: #1a1a1a; font-size: 0.92rem; }
.doc-print-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; }
.doc-print-logo { height: 60px; width: auto; }
.doc-print-title { text-align: right; }
.doc-print-doctype { font-size: 1.9rem; letter-spacing: 0.05em; font-weight: 300; color: #2c2c2c; }
.doc-print-docno { font-weight: 700; margin-top: 2px; }

.doc-print-parties { display: flex; gap: 30px; margin-bottom: 20px; }
.doc-print-parties > div { flex: 1; line-height: 1.6; }
.doc-print-from strong, .doc-print-to strong { font-size: 1rem; }
.doc-print-meta { text-align: left; }
.doc-print-meta > div { margin-bottom: 4px; }

.doc-print-subject { font-weight: 600; margin: 16px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--color-border); }

.doc-print-items { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 0.88rem; }
.doc-print-items thead th { background: #2c2c2c; color: #fff; text-align: left; padding: 10px 12px; font-weight: 600; }
.doc-print-items td { padding: 10px 12px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.dpi-num { text-align: right; }
.doc-print-items thead th.dpi-num { text-align: right; }
.doc-print-items thead th:first-child, .doc-print-items td:first-child { text-align: left; width: 32px; }

.doc-print-totals { margin-top: 14px; display: flex; flex-direction: column; align-items: flex-end; }
.doc-print-totals table { width: 320px; border-collapse: collapse; }
.doc-print-totals td { padding: 6px 4px; }
.doc-print-totals tr.dpi-grand td { font-weight: 700; font-size: 1.05rem; background: #f3f3f1; padding: 10px 8px; }
.doc-print-words { width: 320px; text-align: right; margin-top: 8px; font-size: 0.85rem; }

.doc-print-closing { margin-top: 26px; line-height: 1.6; }
.doc-print-closing p { margin: 0 0 14px; }

.doc-print-footer { margin-top: 30px; padding-top: 14px; border-top: 1px solid var(--color-border); font-size: 0.8rem; color: var(--color-muted); text-align: center; }

@media print {
  .doc-print { max-width: 100%; padding: 0; }
}

@media print {
  .no-print, .sidebar, .topbar, .site-footer { display: none !important; }
  body { background: #fff; }
  .app-shell { display: block; }
  .main-content { display: block; }
  .container { max-width: 100%; padding: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}

@media (max-width: 1000px) {
  .cart-bar { flex-direction: column; position: static; max-height: none; }
  .cart-bar-col { min-width: 0; width: 100%; }
}

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .mobile-menu-toggle { display: inline-flex; }
  .sidebar { width: 100%; height: auto; position: static; padding: 14px 12px; display: none; }
  .sidebar.mobile-open { display: block; }
  .sidebar-brand { padding-bottom: 10px; }
  .topbar { padding: 14px 16px; }
}

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .two-col, .three-col { flex-direction: column; }
}
