:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --sidebar-bg: #0f172a;
  --sidebar-fg: #cbd5e1;
  --sidebar-w: 256px;
  --bg: #f1f5f9;
  --bs-primary: #0f766e;
  --bs-primary-rgb: 15, 118, 110;
  --bs-link-color: #0f766e;
  --bs-link-hover-color: #115e59;
}
body { font-family: 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: #1e293b; font-size: 15px; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); }
.text-bg-primary { background-color: var(--brand) !important; }
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--brand); }
.form-control:focus, .form-select:focus { border-color: #5eead4; box-shadow: 0 0 0 .2rem rgba(15,118,110,.15); }

/* Layout */
.app-wrap { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-fg); position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 1040; transition: transform .2s; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand > i { font-size: 26px; color: #2dd4bf; }
.brand-name { color: #fff; font-weight: 600; line-height: 1.2; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: 12px; color: #94a3b8; }
.side-nav { padding: 8px 10px 24px; }
.nav-group { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: 14px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: var(--sidebar-fg); text-decoration: none; border-radius: 8px; font-size: 14.5px; }
.nav-item i { font-size: 16px; width: 18px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid #e2e8f0; padding: 10px 24px; display: flex; align-items: center; position: sticky; top: 0; z-index: 1020; gap: 8px; flex-wrap: wrap; }
.page-title { font-size: 19px; font-weight: 600; margin: 0; }
.content { padding: 22px 24px; flex: 1; }
.app-footer { padding: 12px 24px; color: #94a3b8; font-size: 13px; }
.impersonate-bar { background: #b45309; color: #fff; padding: 8px 24px; font-size: 14px; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
}

/* Cards / tables */
.card { border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: #fff; border-bottom: 1px solid #e2e8f0; font-weight: 600; border-radius: 12px 12px 0 0 !important; }
.table { --bs-table-hover-bg: #f8fafc; margin-bottom: 0; }
.table thead th { background: #f8fafc; font-weight: 600; font-size: 13.5px; color: #475569; white-space: nowrap; border-bottom-width: 1px; }
.table td, .table th { vertical-align: middle; }
.table-responsive { border-radius: 0 0 12px 12px; }
.stat { display: flex; gap: 14px; align-items: center; padding: 16px; }
.stat .icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.stat .label { color: #64748b; font-size: 13.5px; }
.stat .value { font-size: 20px; font-weight: 700; line-height: 1.2; }
.bg-soft-teal { background: #ccfbf1; color: #0f766e; }
.bg-soft-blue { background: #dbeafe; color: #1d4ed8; }
.bg-soft-amber { background: #fef3c7; color: #b45309; }
.bg-soft-red { background: #fee2e2; color: #b91c1c; }
.bg-soft-violet { background: #ede9fe; color: #6d28d9; }
.bg-soft-slate { background: #e2e8f0; color: #334155; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.filter-bar .form-control, .filter-bar .form-select { min-width: 140px; }
.empty { text-align: center; color: #94a3b8; padding: 40px 10px; }
.form-label { font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.req::after { content: ' *'; color: #dc2626; }

/* Item table in forms */
.items-table td { padding: 6px; }
.items-table .form-control, .items-table .form-select { font-size: 14px; }
.items-table .col-qty { width: 110px; }
.items-table .col-price { width: 140px; }
.items-table .col-total { width: 140px; text-align: right; }
.totals-box td { padding: 6px 10px; }
.totals-box .grand { font-size: 18px; font-weight: 700; color: var(--brand); }

/* Guest pages */
body.guest { background: linear-gradient(135deg, #0f766e 0%, #0f172a 100%); min-height: 100vh; }
.guest-wrap { max-width: 560px; margin: 0 auto; padding: 40px 16px; }
.guest-brand { color: #fff; font-size: 26px; font-weight: 700; text-align: center; margin-bottom: 20px; }
.guest .card { border: 0; box-shadow: 0 20px 50px rgba(0,0,0,.25); }

/* Document (invoice/quotation) print */
.doc { background: #fff; max-width: 900px; margin: 0 auto; padding: 36px; border-radius: 12px; border: 1px solid #e2e8f0; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--brand); padding-bottom: 16px; margin-bottom: 20px; }
.doc-company h2 { font-size: 24px; margin: 0 0 4px; color: var(--brand); font-weight: 700; }
.doc-company img { max-height: 64px; margin-bottom: 8px; }
.doc-title { text-align: right; }
.doc-title h3 { font-size: 26px; letter-spacing: .08em; text-transform: uppercase; color: #334155; margin: 0 0 6px; }
.doc-meta td { padding: 2px 0 2px 14px; font-size: 14px; }
.doc .table thead th { background: var(--brand); color: #fff; }
.doc-foot { margin-top: 40px; display: flex; justify-content: space-between; }
.sign { border-top: 1px solid #94a3b8; padding-top: 4px; width: 200px; text-align: center; font-size: 13px; color: #475569; }
.stamp { position: absolute; right: 60px; top: 170px; border: 3px solid; padding: 4px 16px; font-weight: 700; font-size: 22px; transform: rotate(-12deg); opacity: .35; text-transform: uppercase; border-radius: 6px; }
.stamp.paid { color: #15803d; } .stamp.due { color: #b91c1c; } .stamp.partial { color: #b45309; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; font-size: 13px; }
  .sidebar, .topbar, .app-footer, .no-print, .impersonate-bar, .alert { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; }
  .doc { border: 0; padding: 0; max-width: none; }
  .doc .table thead th { background: #0f766e !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card { border: 0; box-shadow: none; }
}
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.notif-unread { border-left: 4px solid var(--brand); background: #f0fdfa; }
.chat-msg { border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; max-width: 85%; }
.chat-msg.me { background: #ccfbf1; margin-left: auto; }
.chat-msg.them { background: #f1f5f9; }

/* v2 */
.items-table.no-price .col-price, .items-table.no-price .col-total { display: none; }
.star-badge { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.star-card { border: 2px solid #f59e0b; }
.lang-switch .btn { font-size: 13px; padding: 4px 10px; }

/* Company pad (★) */
.pad-scroll { overflow-x: auto; }
.doc.doc-pad { width: 210mm; max-width: none; min-height: 297mm; padding: 0; border-radius: 0; overflow: hidden; margin: 0 auto; box-shadow: 0 2px 12px rgba(15,23,42,.08); }
.doc-pad .pad-bg { position: absolute; top: 0; left: 0; width: 210mm; height: 297mm; z-index: 0; pointer-events: none; }
.doc-pad .pad-bg img, .doc-pad .pad-bg canvas { width: 100%; height: 100%; object-fit: fill; display: block; }
.doc-pad .pad-layout { position: relative; z-index: 1; width: 100%; border-collapse: collapse; }
.doc-pad .pad-layout > thead > tr > td, .doc-pad .pad-layout > tfoot > tr > td, .doc-pad .pad-layout > tbody > tr > td { padding-top: 0; padding-bottom: 0; border: 0; vertical-align: top; }
.doc-pad .doc-head { border-bottom-width: 2px; padding-bottom: 10px; margin-bottom: 14px; }
.doc-head-pad { justify-content: flex-end; }
.doc-head-pad .doc-title { text-align: right; }
.doc-pad .stamp { top: auto; margin-top: 120px; }
@media print {
  .pad-scroll { overflow: visible; }
  .doc.doc-pad { box-shadow: none; width: 210mm; min-height: 0; overflow: visible; }
  .doc-pad .pad-bg { position: fixed; top: 0; left: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.pad-preview { position: relative; width: 210px; height: 297px; border: 1px solid #cbd5e1; background: #fff; overflow: hidden; }
.pad-preview .pad-bg { position: absolute; inset: 0; }
.pad-preview .pad-bg img, .pad-preview .pad-bg canvas { width: 100%; height: 100%; display: block; }
.pad-preview .pad-area { position: absolute; border: 2px dashed #dc2626; background: rgba(15,118,110,.08); }
