@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,600&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --primary-dark: #075985;
  
  --secondary: #475569;
  --dark-navy: #0f172a;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #38bdf8;
  
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #06b6d4;
  --info-bg: #cffafe;
  
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body, input, button, select, textarea {
  font-family: 'Be Vietnam Pro', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-main);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}
a:hover {
  color: var(--primary-hover);
}

/* ==========================================================================
   APP LAYOUT (SIDEBAR + MAIN CONTENT)
   ========================================================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 235px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition);
  z-index: 1000;
}

.sidebar-header {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.4px;
}

.sidebar-logo {
  height: 30px;
  max-width: 150px;
  width: auto;
  object-fit: contain;
  display: block;
}

.sidebar-menu {
  padding: 14px 10px;
  flex-grow: 1;
  overflow-y: auto;
  list-style: none;
}

.menu-category {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  padding: 8px 10px 4px;
  margin-top: 6px;
}

.menu-item {
  margin-bottom: 3px;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  color: var(--sidebar-text);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 11px;
  transition: var(--transition);
}

.menu-link i {
  font-size: 14px;
  width: 16px;
  text-align: center;
}

.menu-link:hover {
  background-color: var(--sidebar-hover);
  color: #ffffff;
}

.menu-item.active .menu-link {
  background-color: rgba(2, 132, 199, 0.15);
  color: var(--sidebar-active);
  font-weight: 600;
  border-left: 3px solid var(--sidebar-active);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background-color: rgba(0, 0, 0, 0.2);
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  box-shadow: var(--shadow-sm);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 9px;
  color: #38bdf8;
  font-weight: 600;
}

/* Main Area */
.main-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 56px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 99;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 5px;
  border-radius: var(--radius-sm);
  display: none;
}
.sidebar-toggle:hover {
  background-color: var(--bg-main);
  color: var(--text-main);
}

.topbar-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--dark-navy);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content-body {
  padding: 20px;
  flex-grow: 1;
}

/* ==========================================================================
   CARDS & WIDGETS
   ========================================================================== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #ffffff;
}

.card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--dark-navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 18px;
}

.card-footer {
  padding: 10px 18px;
  background-color: #fcfdfe;
  border-top: 1px solid var(--border-color);
}

/* Stat Cards (KPI) - Fixed Grid & Proportional Fluid Scaling */
.stat-grid,
.kpi-grid-5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 1vw, 14px);
  margin-bottom: 18px;
}

.kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1vw, 14px);
  margin-bottom: 18px;
}

.kpi-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1vw, 14px);
  margin-bottom: 18px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: clamp(10px, 1vw, 14px) clamp(8px, 0.8vw, 13px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  min-width: 0;
  gap: 6px;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3.5px;
}

.stat-card.primary::before { background-color: var(--primary); }
.stat-card.success::before { background-color: var(--success); }
.stat-card.warning::before { background-color: var(--warning); }
.stat-card.danger::before { background-color: var(--danger); }
.stat-card.info::before { background-color: var(--info); }

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-title {
  font-size: clamp(8.5px, 0.65vw, 10px);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.stat-value {
  font-size: clamp(12px, 1vw, 16px);
  font-weight: 800;
  color: var(--dark-navy);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-subtext {
  font-size: clamp(8.5px, 0.6vw, 9.8px);
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-icon {
  width: clamp(26px, 2vw, 34px);
  height: clamp(26px, 2vw, 34px);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(12px, 0.9vw, 16px);
  flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.35;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 10px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 9px 18px;
  font-size: 12.5px;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  color: #ffffff;
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}
.btn-success:hover {
  background-color: #059669;
  color: #ffffff;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background-color: #dc2626;
  color: #ffffff;
}

.btn-secondary {
  background-color: #f1f5f9;
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background-color: #e2e8f0;
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary);
  color: #ffffff;
}

.btn-outline-secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-color);
}
.btn-outline-secondary:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

/* ==========================================================================
   BADGES
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  font-size: 9.5px;
  font-weight: 600;
  border-radius: 9999px;
  line-height: 1.2;
}

.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-indigo { background: #e0e7ff; color: #3730a3; }
.badge-emerald { background: #d1fae5; color: #065f46; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-rose { background: #ffe4e6; color: #9f1239; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-cyan { background: #cffafe; color: #155e75; }
.badge-slate { background: #f1f5f9; color: #334155; }
.badge-gray { background: #e2e8f0; color: #475569; }

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }

/* ==========================================================================
   TABLES & RESPONSIVE PROPORTIONS
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}
.table-responsive::-webkit-scrollbar-track {
  background: #f8fafc;
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
}

.table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: middle;
}

.table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--text-main);
}

.table tbody tr:hover td {
  background-color: #f8fafc;
}

.table-bordered {
  border: 1px solid var(--border-color);
}
.table-bordered th, .table-bordered td {
  border: 1px solid var(--border-color);
}

/* Prevent unwanted line-breaking on amounts, currencies, badges and buttons */
.table td.text-end,
.table th.text-end,
.table td.text-right,
.table th.text-right,
.text-nowrap,
.amount-val,
.currency-val {
  white-space: nowrap !important;
}

.table td .badge,
.table td .btn,
.table th .badge {
  white-space: nowrap !important;
  flex-shrink: 0;
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--dark-navy);
  margin-bottom: 4px;
}

.form-label.required::after {
  content: " *";
  color: var(--danger);
}

.form-control, .form-select {
  width: 100%;
  padding: 7px 10px;
  font-size: 11px;
  color: var(--text-main);
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  transition: var(--transition);
  font-family: inherit;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

textarea.form-control {
  min-height: 70px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.form-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .form-control {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.input-group-text {
  padding: 7px 10px;
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-weight: 600;
  font-size: 10.5px;
  color: var(--text-muted);
}

/* ==========================================================================
   ALERTS
   ========================================================================== */
.alert {
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success { background-color: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error, .alert-danger { background-color: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background-color: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background-color: var(--info-bg); color: #155e75; border: 1px solid #a5f3fc; }

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 540px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px);
  transition: var(--transition);
}

.modal-backdrop.show .modal-dialog {
  transform: translateY(0);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--dark-navy);
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 18px;
  max-height: 75vh;
  overflow-y: auto;
  font-size: 11px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  background-color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   DOCUMENT & PRINT STYLES (STANDARD A4 FORMAT)
   ========================================================================== */
.document-container {
  background: #ffffff;
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  margin: 20px auto;
  padding: 14mm 16mm;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  position: relative;
  color: #1e293b;
  font-family: 'Be Vietnam Pro', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 10.5px;
  box-sizing: border-box;
}

.doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #0284c7;
  padding-bottom: 14px;
  margin-bottom: 16px;
  gap: 18px;
}

.doc-logo-box {
  width: 180px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.doc-logo-box img {
  max-width: 100%;
  max-height: 60px;
  height: auto;
  object-fit: contain;
  display: block;
}

.doc-company-info {
  text-align: right;
  font-size: 9.5px;
  line-height: 1.45;
  color: #334155;
}

.doc-company-name {
  font-size: 12.5px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.doc-title-section {
  text-align: center;
  margin: 14px 0 18px;
}

.doc-main-title {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: #0f172a;
  text-transform: uppercase;
}

.doc-sub-title {
  font-size: 10.5px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 2px;
}

.doc-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.doc-box {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 9px 12px;
  background-color: #f8fafc;
}

.doc-box-title {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #0284c7;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 3px;
  margin-bottom: 6px;
}

.doc-row {
  display: flex;
  margin-bottom: 4px;
  font-size: 10px;
  line-height: 1.35;
}

.doc-label {
  width: 120px;
  font-weight: 600;
  color: #475569;
  flex-shrink: 0;
}

.doc-val {
  font-weight: 600;
  color: #0f172a;
  flex: 1;
  word-break: break-word;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 10px;
}

.doc-table th {
  background-color: #f1f5f9;
  color: #0f172a;
  font-weight: 800;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  text-align: center;
  font-size: 9.5px;
  letter-spacing: 0.2px;
}

.doc-table td {
  padding: 6px 9px;
  border: 1px solid #cbd5e1;
  vertical-align: middle;
}

.doc-table .text-right {
  text-align: right;
}
.doc-table .text-center {
  text-align: center;
}

.doc-summary {
  margin-left: auto;
  width: 320px;
  margin-bottom: 16px;
}

.doc-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 10.5px;
  border-bottom: 1px solid #e2e8f0;
}

.doc-summary-row.grand-total {
  font-size: 12.5px;
  font-weight: 800;
  color: #0284c7;
  border-top: 2px solid #0f172a;
  border-bottom: 2px solid #0f172a;
  padding: 7px 0;
}

.doc-amount-words {
  background-color: #f0fdf4;
  border: 1px dashed #86efac;
  padding: 9px 14px;
  border-radius: 4px;
  font-size: 10.5px;
  color: #15803d;
  margin-bottom: 18px;
  line-height: 1.45;
}

.doc-bank-box {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 10px 14px;
  background-color: #eff6ff;
  font-size: 10px;
  margin-bottom: 20px;
  line-height: 1.45;
}

.doc-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 8px;
}

.sig-col {
  width: 220px;
  text-align: center;
  position: relative;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.sig-title {
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  color: #0f172a;
}

.sig-sub {
  font-size: 9.5px;
  color: #64748b;
  font-style: italic;
}

.sig-spacer {
  height: 55px;
}

.sig-name {
  font-weight: 700;
  color: #0f172a;
  font-size: 11px;
  position: relative;
  z-index: 2;
}

.stamp-seal {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-40%);
  width: 120px;
  opacity: 0.88;
  pointer-events: none;
  z-index: 1;
}

/* ==========================================================================
   STRICT A4 PRINT OPTIMIZATION (PRINT ENGINE)
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 8mm 8mm 8mm;
  }

  html, body {
    width: 210mm !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 8.5pt !important;
    line-height: 1.35 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

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

  .app-wrapper, .main-wrapper, .content-body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    display: block !important;
    background: transparent !important;
  }

  .document-container {
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    page-break-after: avoid;
  }

  .doc-header {
    border-bottom: 2px solid #000000 !important;
    padding-bottom: 10px !important;
    margin-bottom: 12px !important;
  }

  .doc-table {
    width: 100% !important;
    border-collapse: collapse !important;
    page-break-inside: auto;
  }

  .doc-table tr {
    page-break-inside: avoid;
  }

  .doc-table th, .doc-table td {
    border: 1px solid #000000 !important;
    padding: 4px 6px !important;
    font-size: 8pt !important;
    line-height: 1.25 !important;
  }

  .doc-table th {
    background-color: #f1f5f9 !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .doc-summary-row.grand-total {
    border-top: 2px solid #000000 !important;
    border-bottom: 2px solid #000000 !important;
    color: #000000 !important;
  }

  .doc-header, .doc-signatures, .doc-company-info, .doc-summary, .doc-summary-box, .doc-title-section, .doc-info-grid, .doc-bank-box, .doc-amount-words {
    page-break-inside: avoid;
  }

  .stamp-seal {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* Dashboard Layout Rows - Proportional Fluid Scaling */
.chart-row,
.tables-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: clamp(12px, 1.3vw, 20px);
  margin-bottom: 18px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 998;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (DESKTOP SCALING, TABLET & MOBILE)
   ========================================================================== */
@media (min-width: 993px) {
  .stat-grid,
  .kpi-grid-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }
  .kpi-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  .kpi-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1200px) and (min-width: 993px) {
  .content-body {
    padding: 16px 12px;
  }
  .stat-card {
    padding: 9px 8px;
  }
  .stat-title {
    font-size: 8.5px;
  }
  .stat-value {
    font-size: 13px;
  }
  .stat-subtext {
    font-size: 8.5px;
  }
  .stat-icon {
    width: 26px;
    height: 26px;
    font-size: 13px;
  }
}

@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -280px;
    width: 260px;
    z-index: 999;
    box-shadow: none;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .sidebar.show {
    left: 0;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  }
  
  .sidebar.show ~ .sidebar-backdrop,
  .sidebar-backdrop.show {
    display: block;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .chart-row,
  .tables-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .form-row-3, .form-row-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .doc-info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .topbar {
    height: 50px;
    padding: 0 10px;
  }

  .topbar-subtitle {
    display: none !important;
  }

  .topbar-time,
  .topbar-divider {
    display: none !important;
  }

  .topbar-title {
    font-size: 12px;
    font-weight: 700;
  }

  .btn-create-job .btn-create-label {
    display: none !important;
  }

  .btn-create-job {
    padding: 5px 8px;
    font-size: 10px;
  }

  .content-body {
    padding: 12px 8px;
  }

  .stat-grid,
  .kpi-grid-5 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
    margin-bottom: 14px;
  }

  .stat-grid > :last-child:nth-child(odd),
  .kpi-grid-5 > :last-child:nth-child(odd) {
    grid-column: span 2;
  }

  .kpi-grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
    margin-bottom: 14px;
  }

  .kpi-grid-3 {
    grid-template-columns: 1fr !important;
    gap: 8px;
    margin-bottom: 14px;
  }

  .stat-card {
    padding: 10px 10px;
    border-radius: var(--radius-md);
  }

  .stat-title {
    font-size: 9px;
  }

  .stat-value {
    font-size: 13.5px;
  }

  .stat-subtext {
    font-size: 8.5px;
  }

  .card {
    border-radius: var(--radius-md);
    margin-bottom: 14px;
  }

  .card-header {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .card-body {
    padding: 12px;
  }

  .form-row-2,
  .form-row-3,
  .form-row-4 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
  }

  .table {
    min-width: 500px;
  }

  .modal-dialog {
    max-width: 95vw !important;
    margin: 10px auto;
  }

  .modal-body {
    max-height: 75vh;
    overflow-y: auto;
    padding: 12px;
  }

  .doc-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .doc-company-info {
    text-align: left;
  }

  .doc-signatures {
    flex-direction: column;
    gap: 16px;
    align-items: center;
  }

  .sig-col {
    width: 100%;
    max-width: 250px;
  }
}

@media (max-width: 480px) {
  .stat-grid,
  .kpi-grid-5,
  .kpi-grid-4 {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  .stat-grid > :last-child:nth-child(odd),
  .kpi-grid-5 > :last-child:nth-child(odd) {
    grid-column: span 1;
  }

  .stat-card {
    padding: 10px 12px;
  }

  .btn {
    font-size: 10.5px;
    padding: 5px 10px;
  }
}
