/* ============================================================
   CSS VARIABLES — SAAS PALETTE (Linear/Notion inspired)
   ============================================================ */
:root {
  --primary:        #2563EB;
  --primary-light:  #EFF6FF;
  --primary-dark:   #1D4ED8;
  --accent:         #0EA5E9;
  --success:        #10B981;
  --success-light:  #ECFDF5;
  --warning:        #F59E0B;
  --warning-light:  #FFFBEB;
  --danger:         #EF4444;
  --danger-light:   #FEF2F2;
  --bg:             #F8FAFC;
  --surface:        #FFFFFF;
  --surface-2:      #F1F5F9;
  --border:         #E2E8F0;
  --border-light:   #F1F5F9;
  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;
  --sidebar-bg:     #0F172A;
  --sidebar-text:   #94A3B8;
  --sidebar-active: #FFFFFF;
  --sidebar-hover:  #1E293B;
  --sidebar-accent: #2563EB;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:      0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --radius-xl:      20px;
  --sidebar-width:  240px;
  --topbar-height:  60px;
  --bottom-nav-h:   64px;
  --font:           'Plus Jakarta Sans', sans-serif;
  --font-mono:      'JetBrains Mono', monospace;
  --transition:     all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; }

/* ============================================================
   LAYOUT
   ============================================================ */
#app { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: var(--transition);
  overflow: hidden;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1E293B;
}
.sidebar-logo .brand-name {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--surface);
  line-height: 1.2;
}
.sidebar-logo .brand-sub {
  font-size: 10px;
  color: #475569;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}
.nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #334155;
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 1px;
  white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--surface); }
.nav-item.active { background: var(--sidebar-accent); color: var(--surface); }
.nav-item .nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid #1E293B;
}

/* MAIN CONTENT */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOP BAR */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-date {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-primary);
  padding: 6px;
}

/* PAGE CONTENT */
.page-content {
  flex: 1;
  padding: 28px 28px 28px;
}
.page { display: none; }
.page.active { display: block; }

/* ============================================================
   COMPONENTS
   ============================================================ */

/* PAGE HEADER */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.page-desc { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger-light); color: var(--danger); border: 1.5px solid #FECACA; }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.card-body { padding: 20px; }

/* STAT CARDS */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.blue::before { background: var(--primary); }
.stat-card.green::before { background: var(--success); }
.stat-card.amber::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }
.stat-label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-primary); margin: 6px 0 4px; font-family: var(--font-mono); }
.stat-sub { font-size: 11px; color: var(--text-muted); }
.stat-icon { position: absolute; top: 18px; right: 18px; font-size: 22px; opacity: 0.12; }

/* ALERTS */
.alert-list { margin-bottom: 20px; }
.alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
}
.alert-item.warning { background: var(--warning-light); color: #92400E; border: 1px solid #FDE68A; }
.alert-item.danger { background: var(--danger-light); color: #991B1B; border: 1px solid #FECACA; }
.alert-item.success { background: var(--success-light); color: #065F46; border: 1px solid #A7F3D0; }
.alert-item .alert-dismiss { margin-left: auto; cursor: pointer; opacity: 0.5; font-size: 16px; }
.alert-item .alert-dismiss:hover { opacity: 1; }

/* QUICK ACTIONS */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.quick-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}
.quick-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.quick-btn .qb-icon { font-size: 20px; }

/* TWO COLUMN GRID */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* TABLES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
td { padding: 11px 14px; font-size: 13px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-blue { background: #DBEAFE; color: #1E40AF; }
.badge-green { background: #D1FAE5; color: #065F46; }
.badge-amber { background: #FEF3C7; color: #92400E; }
.badge-red { background: #FEE2E2; color: #991B1B; }
.badge-gray { background: var(--surface-2); color: var(--text-muted); }
.badge-purple { background: #EDE9FE; color: #5B21B6; }

/* FORMS */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}
.required::after { content: ' *'; color: var(--danger); }
input[type="text"], input[type="email"], input[type="number"], input[type="tel"],
input[type="date"], input[type="url"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
  transition: var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* SEARCH BAR */
.search-bar {
  position: relative;
  max-width: 320px;
}
.search-bar input {
  padding-left: 34px;
  background: var(--bg);
}
.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
}

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 14px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 800; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.modal-close:hover { color: var(--text-primary); background: var(--surface-2); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* TABS */
.tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 9px 16px;
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1.5px;
  transition: var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover { color: var(--text-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* TOGGLE / SWITCH */
.toggle-wrap { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 99px;
  position: relative;
  transition: var(--transition);
  cursor: pointer;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: '';
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 3px; left: 3px;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { left: 21px; }

/* LOGO UPLOAD */
.logo-upload {
  width: 100px; height: 100px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  background: var(--bg);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  gap: 4px;
}
.logo-upload:hover { border-color: var(--primary); color: var(--primary); }
.logo-upload img { width: 100%; height: 100%; object-fit: contain; }

/* TOAST */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text-primary);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* BOTTOM NAVIGATION (Mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding: 0 8px;
  align-items: center;
  justify-content: space-around;
}
.bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
  min-width: 54px;
  text-align: center;
}
.bnav-item.active { color: var(--primary); }
.bnav-item .bnav-icon { font-size: 20px; }

/* MORE MENU (mobile) */
.more-menu {
  display: none;
  position: fixed;
  bottom: var(--bottom-nav-h);
  left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 199;
  padding: 16px;
}
.more-menu.open { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.more-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--radius-md);
  background: var(--bg);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  transition: var(--transition);
}
.more-menu-item:hover { background: var(--primary-light); color: var(--primary); }
.more-menu-item .mi-icon { font-size: 22px; }

/* MOBILE OVERLAY */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 199;
}
.sidebar-overlay.open { display: block; }

/* PARTY CARD (mobile view) */
.party-cards { display: none; }
.party-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 10px;
}
.party-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.party-card-name { font-size: 14px; font-weight: 700; }
.party-card-company { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.party-card-footer { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* SETTINGS SECTION */
.settings-section { margin-bottom: 32px; }
.settings-section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 13px; font-weight: 500; }
.settings-row-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* BACKUP ZONE */
.backup-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg);
}
.backup-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.backup-zone .bz-icon { font-size: 36px; margin-bottom: 10px; opacity: 0.5; }
.backup-zone h4 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.backup-zone p { font-size: 12px; color: var(--text-muted); }

/* DIVIDER */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* LOADING */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border-light) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   COSTING MODULE STYLES
   ============================================================ */

/* Summary panel rows */
.cs-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-secondary);
}
.cs-summary-row span:last-child {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}
.cs-summary-row.zero { opacity: 0.4; }

/* Material & process row */
.cost-row {
  display: grid;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  align-items: end;
  background: var(--surface);
  transition: background 0.15s;
}
.cost-row:hover { background: var(--bg); }
.cost-row:last-child { border-bottom: none; }
.cost-row.material-acrylic { grid-template-columns: 2fr 90px 90px 90px 90px 90px 36px; }
.cost-row.material-other   { grid-template-columns: 2fr 110px 90px 36px; }
.cost-row.process-row      { grid-template-columns: 2fr 130px 110px 36px; }
.cost-row.other-charge-row { grid-template-columns: 1fr 110px 36px; }
.cost-row label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.cost-row input, .cost-row select {
  font-size: 12px;
  padding: 6px 8px;
}
.cost-row .row-total {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  text-align: right;
  padding: 6px 0;
}
.cost-row .del-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  align-self: end;
}
.cost-row .del-btn:hover { background: var(--danger-light); color: var(--danger); border-color: #FECACA; }

/* Costing sheet layout responsive */
@media screen and (max-width: 1100px) {
  #cs-layout { grid-template-columns: 1fr !important; }
  #cs-summary-panel { position: static !important; }
  .cost-row.material-acrylic { grid-template-columns: 1fr 1fr 1fr; }
  .cost-row.material-other   { grid-template-columns: 1fr 1fr; }
  .cost-row.process-row      { grid-template-columns: 1fr 1fr; }
}

/* Costing mobile cards */
.costing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
}
.costing-card-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.costing-card-meta  { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }
.costing-card-nums  { display: flex; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.costing-card-num   { display: flex; flex-direction: column; gap: 2px; }
.costing-card-num-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.costing-card-num-val   { font-size: 14px; font-weight: 700; font-family: var(--font-mono); }

/* ============================================================
   QUOTATION MODULE STYLES
   ============================================================ */

/* Quotation status badges */
.qt-status-draft     { background:#F1F5F9; color:#475569; }
.qt-status-sent      { background:#DBEAFE; color:#1E40AF; }
.qt-status-accepted  { background:#D1FAE5; color:#065F46; }
.qt-status-rejected  { background:#FEE2E2; color:#991B1B; }
.qt-status-expired   { background:#FEF3C7; color:#92400E; }
.qt-status-converted { background:#EDE9FE; color:#5B21B6; }

/* Line item rows */
.qt-line-row {
  display: grid;
  grid-template-columns: 1fr 80px 100px 90px 90px 36px;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
  background: var(--surface);
  transition: background 0.15s;
}
.qt-line-row:hover { background: var(--bg); }
.qt-line-row:last-child { border-bottom: none; }
.qt-line-row input, .qt-line-row select { font-size: 12px; padding: 6px 8px; }
.qt-line-total {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-align: right;
  padding: 6px 0;
  color: var(--text-primary);
}
.qt-line-del {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 5px 7px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}
.qt-line-del:hover { background: var(--danger-light); color: var(--danger); border-color: #FECACA; }

/* Quotation print document */
#qt-print-document { font-family: var(--font); color: #1a1a1a; }
.qt-doc-header { padding: 40px 48px 24px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #E2E8F0; }
.qt-doc-logo { max-height: 70px; max-width: 180px; object-fit: contain; }
.qt-doc-company { text-align: right; }
.qt-doc-company h2 { font-size: 18px; font-weight: 800; color: #0F172A; margin-bottom: 4px; }
.qt-doc-company p { font-size: 12px; color: #64748B; line-height: 1.6; }
.qt-doc-meta { padding: 24px 48px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; background: #F8FAFC; }
.qt-doc-bill-to h4 { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #94A3B8; margin-bottom: 8px; }
.qt-doc-bill-to p { font-size: 13px; line-height: 1.7; color: #1E293B; }
.qt-doc-info { text-align: right; }
.qt-doc-info table { margin-left: auto; }
.qt-doc-info td { padding: 3px 0 3px 20px; font-size: 12px; }
.qt-doc-info td:first-child { color: #94A3B8; }
.qt-doc-info td:last-child { font-weight: 700; font-family: var(--font-mono); }
.qt-doc-subject { padding: 16px 48px; font-size: 14px; font-weight: 600; color: #1E293B; }
.qt-doc-table { padding: 0 48px; }
.qt-doc-table table { width: 100%; border-collapse: collapse; }
.qt-doc-table th { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: white; padding: 10px 14px; background: #0F172A; }
.qt-doc-table th:last-child, .qt-doc-table td:last-child { text-align: right; }
.qt-doc-table td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid #F1F5F9; vertical-align: top; }
.qt-doc-table tr:nth-child(even) td { background: #F8FAFC; }
.qt-doc-totals { padding: 20px 48px; display: flex; justify-content: flex-end; }
.qt-doc-totals table { min-width: 260px; }
.qt-doc-totals td { padding: 5px 0 5px 24px; font-size: 13px; }
.qt-doc-totals td:first-child { color: #64748B; }
.qt-doc-totals td:last-child { font-family: var(--font-mono); font-weight: 600; text-align: right; }
.qt-doc-grand td { font-size: 15px; font-weight: 800; border-top: 2px solid #E2E8F0; padding-top: 10px; }
.qt-doc-grand td:last-child { color: #2563EB; }
.qt-doc-footer { padding: 24px 48px 36px; border-top: 1px solid #E2E8F0; margin-top: 8px; }
.qt-doc-footer h5 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #94A3B8; margin-bottom: 8px; }
.qt-doc-footer p { font-size: 12px; color: #475569; line-height: 1.7; white-space: pre-line; }
.qt-doc-bank { padding: 16px 48px; background: #F8FAFC; border-top: 1px solid #E2E8F0; }
.qt-doc-bank h5 { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #94A3B8; margin-bottom:8px; }
.qt-doc-bank p { font-size: 12px; color: #475569; font-family: var(--font-mono); line-height:1.8; }
.qt-doc-stamp { padding: 32px 48px; display: flex; justify-content: flex-end; }
.qt-doc-stamp-box { text-align: center; min-width: 180px; }
.qt-doc-stamp-box .line { border-top: 1.5px solid #CBD5E1; margin-bottom: 6px; }
.qt-doc-stamp-box p { font-size: 11px; color: #94A3B8; }

/* Quotation mobile cards */
.qt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
}

/* Print styles */
@media print {
  .sidebar, .topbar, .bottom-nav, .more-menu, #toast-container,
  .page-header, #qt-list-view, #qt-builder-view,
  #inv-list-view, #inv-builder-view,
  #dc-list-view,
  button, .btn { display: none !important; }
  body { background: white; }
  .main { margin-left: 0; }
  .page-content { padding: 0; }
  #qt-print-view { display: block !important; }
  #qt-print-view > div:first-child { display: none !important; }
  #qt-print-document { box-shadow: none; max-width: 100%; }
  #inv-print-view { display: block !important; }
  #inv-print-view > div:first-child { display: none !important; }
  #inv-print-document { box-shadow: none; max-width: 100%; }
  #dc-print-view { display: block !important; }
  #dc-print-view > div:first-child { display: none !important; }
  #dc-print-document { box-shadow: none; max-width: 100%; }
}

/* Quotation builder responsive */
@media (max-width: 1100px) {
  #qt-layout { grid-template-columns: 1fr !important; }
  #qt-layout > div:last-child { position: static !important; }
  .qt-line-row { grid-template-columns: 1fr 60px 90px 70px 80px 32px; }
}

/* ============================================================
   INVOICE / PAYMENT / CHALLAN MODULE STYLES  (Phase 4-5-6)
   ============================================================ */

/* Invoice status badges */
.inv-status-draft    { background:#F1F5F9; color:#475569; }
.inv-status-issued   { background:#DBEAFE; color:#1E40AF; }
.inv-status-partial  { background:#FEF3C7; color:#92400E; }
.inv-status-paid     { background:#D1FAE5; color:#065F46; }
.inv-status-overdue  { background:#FEE2E2; color:#991B1B; }
.inv-status-cancelled{ background:#F1F5F9; color:#94A3B8; }

/* Payment method badges */
.pay-cash   { background:#D1FAE5; color:#065F46; }
.pay-bank   { background:#DBEAFE; color:#1E40AF; }
.pay-cheque { background:#EDE9FE; color:#5B21B6; }
.pay-online { background:#FEF3C7; color:#92400E; }

/* Receivables aging */
.aging-current  { color: var(--success); font-weight:700; }
.aging-30       { color: var(--warning); font-weight:700; }
.aging-60       { color: #EA580C; font-weight:700; }
.aging-90plus   { color: var(--danger); font-weight:700; }

/* Invoice builder layout same as quotation */
#inv-layout { display:grid; grid-template-columns:1fr 320px; gap:20px; align-items:start; }

/* Payment entry rows */
.pay-entry-row {
  display: grid;
  grid-template-columns: 130px 1fr 140px 36px;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
}
.pay-entry-row:last-child { border-bottom: none; }
.pay-entry-row input, .pay-entry-row select { font-size:12px; padding:6px 8px; }

/* Invoice document styles */
.inv-doc-header  { padding:40px 48px 24px; display:flex; justify-content:space-between; align-items:flex-start; border-bottom:2px solid #E2E8F0; }
.inv-doc-meta    { padding:24px 48px; display:grid; grid-template-columns:1fr 1fr; gap:24px; background:#F8FAFC; }
.inv-doc-table   { padding:0 48px; }
.inv-doc-table table { width:100%; border-collapse:collapse; }
.inv-doc-table th { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:0.06em; color:white; padding:10px 14px; background:#0F172A; }
.inv-doc-table th:last-child, .inv-doc-table td:last-child { text-align:right; }
.inv-doc-table td { padding:10px 14px; font-size:13px; border-bottom:1px solid #F1F5F9; vertical-align:top; }
.inv-doc-table tr:nth-child(even) td { background:#F8FAFC; }
.inv-doc-totals  { padding:20px 48px; display:flex; justify-content:flex-end; }
.inv-doc-totals table { min-width:260px; }
.inv-doc-totals td { padding:5px 0 5px 24px; font-size:13px; }
.inv-doc-totals td:first-child { color:#64748B; }
.inv-doc-totals td:last-child  { font-family:var(--font-mono); font-weight:600; text-align:right; }
.inv-doc-grand td { font-size:15px; font-weight:800; border-top:2px solid #E2E8F0; padding-top:10px; }
.inv-doc-grand td:last-child { color:#2563EB; }
.inv-doc-balance { padding:12px 48px; background:#FEF2F2; border-top:2px solid #FECACA; }
.inv-doc-balance-paid { background:#ECFDF5; border-top-color:#A7F3D0; }
.inv-doc-footer  { padding:24px 48px 36px; border-top:1px solid #E2E8F0; margin-top:8px; }
.inv-doc-footer h5 { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:0.06em; color:#94A3B8; margin-bottom:8px; }
.inv-doc-footer p  { font-size:12px; color:#475569; line-height:1.7; white-space:pre-line; }
.inv-doc-bank    { padding:16px 48px; background:#F8FAFC; border-top:1px solid #E2E8F0; }
.inv-doc-bank h5 { font-size:10px; font-weight:700; text-transform:uppercase; color:#94A3B8; margin-bottom:8px; }
.inv-doc-bank p  { font-size:12px; color:#475569; font-family:var(--font-mono); line-height:1.8; }
.inv-doc-stamp   { padding:32px 48px; display:flex; justify-content:flex-end; }
.inv-doc-stamp-box { text-align:center; min-width:180px; }
.inv-doc-stamp-box .line { border-top:1.5px solid #CBD5E1; margin-bottom:6px; }
.inv-doc-stamp-box p { font-size:11px; color:#94A3B8; }

/* Challan document */
.dc-doc-header { padding:32px 48px 20px; display:flex; justify-content:space-between; align-items:flex-start; border-bottom:2px solid #E2E8F0; }
.dc-doc-meta   { padding:20px 48px; display:grid; grid-template-columns:1fr 1fr; gap:24px; background:#F8FAFC; }
.dc-doc-table  { padding:0 48px; }
.dc-doc-table table { width:100%; border-collapse:collapse; }
.dc-doc-table th { font-size:10px; font-weight:700; text-transform:uppercase; color:white; padding:8px 14px; background:#0F172A; }
.dc-doc-table td { padding:9px 14px; font-size:13px; border-bottom:1px solid #F1F5F9; }
.dc-doc-sign   { padding:32px 48px; display:grid; grid-template-columns:1fr 1fr 1fr; gap:24px; border-top:1px solid #E2E8F0; margin-top:16px; }
.dc-doc-sign-box { text-align:center; }
.dc-doc-sign-box .line { border-top:1.5px solid #CBD5E1; margin-bottom:6px; }
.dc-doc-sign-box p { font-size:11px; color:#94A3B8; }

/* Party statement */
.stmt-row { display:grid; grid-template-columns:100px 1fr 110px 110px 110px; gap:8px; padding:9px 16px; border-bottom:1px solid var(--border-light); font-size:12px; align-items:center; }
.stmt-row.header { background:var(--sidebar-bg); color:white; font-weight:700; font-size:10px; text-transform:uppercase; letter-spacing:0.04em; border-radius:var(--radius-sm) var(--radius-sm) 0 0; }

/* Responsive for invoice builder */
@media (max-width: 1100px) {
  #inv-layout { grid-template-columns: 1fr !important; }
  #inv-layout > div:last-child { position: static !important; }
}



/* ============================================================
   PROFIT LEDGER MODULE STYLES (Phase 7 — Internal Only)
   ============================================================ */
.profit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
}
.profit-card-top { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; margin-bottom:8px; }
.profit-card-title { font-size:14px; font-weight:800; }
.profit-card-meta { font-size:11px; color:var(--text-muted); margin-top:2px; }
.profit-mini-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin:10px 0; }
.profit-mini { background:var(--bg); border:1px solid var(--border-light); border-radius:var(--radius-sm); padding:8px; }
.profit-mini span { display:block; font-size:9px; color:var(--text-muted); font-weight:800; text-transform:uppercase; letter-spacing:.04em; }
.profit-mini strong { display:block; font-size:12px; font-family:var(--font-mono); margin-top:2px; }
.profit-negative { color: var(--danger) !important; }
.profit-positive { color: var(--success) !important; }
@media screen and (max-width: 768px) {
  .profit-table-wrap { display:none; }
  #profit-cards-mobile { display:block !important; }
  .profit-mini-grid { grid-template-columns:1fr 1fr; }
}


/* ============================================================
   REPORTS MODULE STYLES (Phase 8)
   ============================================================ */
.report-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: end;
}
.report-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.report-mini-card {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.report-mini-card span {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.report-mini-card strong {
  display: block;
  font-size: 18px;
  font-family: var(--font-mono);
  margin-top: 4px;
  color: var(--text-primary);
}
.report-section-card { margin-bottom: 18px; }
.report-print-title { display:none; }

@media screen and (max-width: 768px) {
  .report-filter-grid { grid-template-columns: 1fr; }
  .report-kpi-grid { grid-template-columns: 1fr 1fr; }
  #reports-page-actions { width:100%; }
  #reports-page-actions .btn { flex:1; justify-content:center; }
}

@media print {
  body { background:white !important; }

  /* Reports print is now scoped only to the Reports print button.
     This prevents quotation/invoice/payment/challan printing from opening Reports. */
  body.print-reports .sidebar,
  body.print-reports .topbar,
  body.print-reports .bottom-nav,
  body.print-reports .more-menu,
  body.print-reports #toast-container,
  body.print-reports .page-header,
  body.print-reports .tabs,
  body.print-reports #reports-filters-card,
  body.print-reports button,
  body.print-reports .btn { display:none !important; }

  body.print-reports .main { margin-left:0 !important; }
  body.print-reports .page-content { padding:0 !important; }
  body.print-reports .page { display:none !important; }
  body.print-reports #page-reports { display:block !important; }
  body.print-reports #page-reports .tab-panel { display:block !important; page-break-inside: avoid; margin-bottom:18px; }
  body.print-reports #page-reports .card { box-shadow:none !important; border:1px solid #ddd !important; }
  body.print-reports .report-print-title { display:block !important; font-size:20px; font-weight:800; margin:0 0 16px; }
}

/* ============================================================
   RESPONSIVE — MOBILE FIRST
   ============================================================ */
@media screen and (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .hamburger { display: flex; }
  .page-content { padding: 16px 16px calc(16px + var(--bottom-nav-h)); }
  .bottom-nav { display: flex; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }
  .form-row.cols-2 { grid-template-columns: 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr; }
  .table-wrap { margin: 0 -20px; padding: 0 20px; }
  .party-cards { display: block; }
  .party-table-wrap { display: none; }
  .page-title { font-size: 18px; }
  .stat-value { font-size: 20px; }
  #toast-container { bottom: calc(var(--bottom-nav-h) + 12px); right: 12px; left: 12px; }
  /* Costing mobile — hide desktop table, show cards */
  #costing-list-view .card { display: none; }
  #costing-cards-mobile { display: block !important; }
  /* Costing sheet layout */
  #cs-layout { grid-template-columns: 1fr !important; }
  #cs-summary-panel { position: static !important; }
  .cost-row.material-acrylic { grid-template-columns: 1fr 1fr; gap:8px; }
  .cost-row.material-other   { grid-template-columns: 1fr 1fr; gap:8px; }
  .cost-row.process-row      { grid-template-columns: 1fr 1fr; gap:8px; }
  .cost-row.other-charge-row { grid-template-columns: 1fr; gap:8px; }
  /* Quotation mobile */
  .qt-table-wrap { display: none; }
  #qt-cards-mobile { display: block !important; }
  #qt-layout { grid-template-columns: 1fr !important; }
  #qt-layout > div:last-child { position: static !important; }
  .qt-line-row { grid-template-columns: 1fr 50px 80px 60px 70px 30px; gap:5px; }
  .qt-doc-header { flex-direction: column; gap: 16px; padding: 24px; }
  .qt-doc-company { text-align: left; }
  .qt-doc-meta { grid-template-columns: 1fr; padding: 16px 24px; }
  .qt-doc-info { text-align: left; }
  .qt-doc-info table { margin-left: 0; }
  .qt-doc-table, .qt-doc-totals, .qt-doc-footer, .qt-doc-bank, .qt-doc-stamp, .qt-doc-subject { padding-left: 24px; padding-right: 24px; }
  /* Invoice mobile */
  .inv-table-wrap { display: none; }
  #inv-cards-mobile { display: block !important; }
  #inv-layout { grid-template-columns: 1fr !important; }
  #inv-layout > div:last-child { position: static !important; }
  .inv-doc-header { flex-direction: column; gap:16px; padding:24px; }
  .inv-doc-meta { grid-template-columns:1fr; padding:16px 24px; }
  .inv-doc-table, .inv-doc-totals, .inv-doc-footer, .inv-doc-bank, .inv-doc-stamp, .inv-doc-balance { padding-left:24px; padding-right:24px; }
  /* Payments mobile */
  .pay-table-wrap { display: none; }
  #pay-cards-mobile { display: block !important; }
  /* Challans mobile */
  .dc-table-wrap { display: none; }
  #dc-cards-mobile { display: block !important; }
  .dc-doc-header { flex-direction:column; gap:16px; padding:24px; }
  .dc-doc-meta { grid-template-columns:1fr; padding:16px 24px; }
  .dc-doc-table, .dc-doc-sign { padding-left:24px; padding-right:24px; }
  .dc-doc-sign { grid-template-columns:1fr; }
  .pay-entry-row { grid-template-columns: 1fr 1fr; gap:6px; }
  .stmt-row { grid-template-columns: 80px 1fr 90px 90px; font-size:11px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 769px) and (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1400px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}


/* ============================================================
   HIGH PRIORITY HOTFIX — A4 PRINT/PDF DOCUMENT EXPORT + WHATSAPP ACTIONS
   Scope: quotation, invoice, delivery challan only. Keeps screen UI unchanged.
   ============================================================ */
@media print {
  @page { size: A4 portrait; margin: 8mm; }
  html, body { width: 210mm !important; min-height: 297mm !important; background: #fff !important; }
  body { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }
  body.print-document * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }
  body.print-document .sidebar,
  body.print-document .topbar,
  body.print-document .bottom-nav,
  body.print-document .more-menu,
  body.print-document #toast-container,
  body.print-document .page-header,
  body.print-document .tabs,
  body.print-document button,
  body.print-document .btn,
  body.print-document #qt-list-view,
  body.print-document #qt-builder-view,
  body.print-document #inv-list-view,
  body.print-document #inv-builder-view,
  body.print-document #dc-list-view,
  body.print-document #dc-builder-view { display: none !important; }
  body.print-document .main { margin-left: 0 !important; display: block !important; min-height: auto !important; }
  body.print-document .page-content { padding: 0 !important; display: block !important; }
  body.print-document .page { display: none !important; }
  body.print-document.print-quotation #page-quotations,
  body.print-document.print-invoice #page-invoices,
  body.print-document.print-challan #page-challans { display: block !important; }
  body.print-document.print-quotation #qt-print-view,
  body.print-document.print-invoice #inv-print-view,
  body.print-document.print-challan #dc-print-view { display: block !important; }
  body.print-document #qt-print-view > div:first-child,
  body.print-document #inv-print-view > div:first-child,
  body.print-document #dc-print-view > div:first-child { display: none !important; }
  body.print-document #qt-print-document,
  body.print-document #inv-print-document,
  body.print-document #dc-print-document {
    width: 194mm !important;
    max-width: 194mm !important;
    margin: 0 auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    page-break-inside: auto !important;
  }
  body.print-document .qt-doc-header,
  body.print-document .inv-doc-header { padding: 18px 28px 12px !important; }
  body.print-document .dc-doc-header { padding: 16px 28px 10px !important; }
  body.print-document .qt-doc-meta,
  body.print-document .inv-doc-meta { padding: 12px 28px !important; }
  body.print-document .dc-doc-meta { padding: 10px 28px !important; }
  body.print-document .qt-doc-subject,
  body.print-document .qt-doc-table,
  body.print-document .inv-doc-table,
  body.print-document .dc-doc-table,
  body.print-document .qt-doc-totals,
  body.print-document .inv-doc-totals,
  body.print-document .qt-doc-footer,
  body.print-document .inv-doc-footer,
  body.print-document .qt-doc-bank,
  body.print-document .inv-doc-bank,
  body.print-document .qt-doc-stamp,
  body.print-document .inv-doc-stamp,
  body.print-document .dc-doc-sign,
  body.print-document .inv-doc-balance { padding-left: 28px !important; padding-right: 28px !important; }
  body.print-document .qt-doc-table th,
  body.print-document .inv-doc-table th,
  body.print-document .dc-doc-table th { background: #0F172A !important; color: #fff !important; }
  body.print-document .qt-doc-table td,
  body.print-document .inv-doc-table td { padding-top: 6px !important; padding-bottom: 6px !important; font-size: 11.5px !important; }
  body.print-document .dc-doc-table td { padding-top: 6px !important; padding-bottom: 6px !important; font-size: 11.5px !important; }
  body.print-document .qt-doc-footer,
  body.print-document .inv-doc-footer { padding-top: 10px !important; padding-bottom: 10px !important; margin-top: 0 !important; }
  body.print-document .qt-doc-bank,
  body.print-document .inv-doc-bank { padding-top: 8px !important; padding-bottom: 8px !important; }
  body.print-document .qt-doc-stamp,
  body.print-document .inv-doc-stamp { padding-top: 18px !important; padding-bottom: 10px !important; page-break-inside: avoid !important; break-inside: avoid !important; }
  body.print-document .dc-doc-sign { padding-top: 24px !important; padding-bottom: 10px !important; margin-top: 10px !important; page-break-inside: avoid !important; break-inside: avoid !important; }
  body.print-document table, body.print-document tr, body.print-document thead { page-break-inside: avoid !important; break-inside: avoid !important; }
  body.print-document .qt-doc-grand, body.print-document .inv-doc-grand { page-break-inside: avoid !important; break-inside: avoid !important; }
body.print-document .qt-doc-header,
body.print-document .inv-doc-header,
body.print-document .dc-doc-header {
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  width: 100% !important;
}

/* VERY IMPORTANT: stop children from behaving like full-width blocks */
body.print-document .qt-doc-header > *,
body.print-document .inv-doc-header > *,
body.print-document .dc-doc-header > * {
  width: auto !important;
  display: inline-block !important;
}

/* Force company block to stay on right side */
body.print-document .qt-doc-company {
  margin-left: auto !important;
  text-align: right !important;
  display: flex !important;
  flex-direction: column !important;
}

}

/* ============================================================
   HOTFIX — Quotation Negotiation / Revised Rates
   ============================================================ */
.qt-status-negotiation { background:#FEF3C7; color:#92400E; }
.qt-status-rates_revised { background:#EDE9FE; color:#5B21B6; }
.mes-qt-history { max-width:800px; margin:16px auto 0; background:#fff; border:1px solid var(--border); border-radius:var(--radius-lg); box-shadow:var(--shadow-sm); padding:16px; }
.mes-qt-history h4 { font-size:14px; margin-bottom:10px; }
.mes-qt-history-item { border-top:1px solid var(--border-light); padding:10px 0; font-size:12px; }
.mes-qt-history-item:first-of-type { border-top:none; }
@media print { .no-print, .mes-qt-history { display:none !important; } }

/* Enhancement: payment allocation + backup reminder */
.payment-allocation-preview {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}
.allocation-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.allocation-table th,
.allocation-table td {
  font-size: 12px;
  padding: 8px 10px;
}
#backup-reminder-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
#backup-reminder-alert span:nth-child(2) {
  flex: 1;
}
.mes-wa-payment-btn,
.mes-wa-reminder-btn {
  margin-right: 4px;
}
/* ============================================================
   WORKER LABOUR MODULE
   ============================================================ */

#page-workers .tab-panel {
  margin-top: 16px;
}

#page-workers table td,
#page-workers table th {
  white-space: nowrap;
}

#page-workers .stat-grid {
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  #page-workers .form-row.cols-2,
  #page-workers .form-row.cols-3 {
    grid-template-columns: 1fr;
  }

  #page-workers .stat-grid {
    grid-template-columns: 1fr;
  }
}