/* =====================================================================
   Aangan ERP (Laravel) — page styles on top of aangan.css
   ===================================================================== */

/* ---------- login (from the prototype) ---------- */
.ag-auth-body { min-height: 100vh; background: var(--ag-bg); }
.ag-auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); }
.ag-auth-brand {
  position: relative; overflow: hidden; color: #e3eef1; padding: 3rem 3.5rem; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(90% 70% at 30% 20%, rgba(255, 176, 107, .2), transparent 60%), linear-gradient(150deg, #074155 0%, #053746 55%, #032733 100%);
}
.ag-auth-brand::before {
  content: ""; position: absolute; inset: 0; opacity: .1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23FFB06B' stroke-width='1.2'%3E%3Cpath d='M32 3 61 32 32 61 3 32Z'/%3E%3Cpath d='M32 15 49 32 32 49 15 32Z'/%3E%3Ccircle cx='32' cy='32' r='5'/%3E%3Cpath d='M32 0v10M32 54v10M0 32h10M54 32h10'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-image: radial-gradient(circle at 70% 75%, #000 0, transparent 65%); mask-image: radial-gradient(circle at 70% 75%, #000 0, transparent 65%);
}
.ag-auth-brand > * { position: relative; }
.ag-auth-logo { width: min(400px, 78%); filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .35)); }
.ag-auth-brand h1 { color: #fff; font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.12; letter-spacing: -.02em; max-width: 520px; }
.ag-auth-brand h1 em { font-style: normal; color: var(--ag-orange); }
.ag-auth-brand p { color: rgba(227, 238, 241, .75); max-width: 470px; font-size: 1.02rem; }
.ag-auth-feats { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.4rem; }
.ag-auth-feats span { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .85rem; border-radius: 999px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1); font-size: .82rem; font-weight: 600; color: var(--ag-cream); }
.ag-auth-feats .ti { color: var(--ag-orange); font-size: 1.05rem; }
.ag-auth-foot { font-size: .8rem; color: rgba(227, 238, 241, .55); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ag-auth-form { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.ag-auth-card { width: 100%; max-width: 430px; }
.ag-auth-card .mobile-logo { display: none; height: 70px; margin-bottom: 1.5rem; }
.ag-auth-card h2 { font-size: 1.85rem; margin-bottom: .35rem; }
.ag-auth-card .form-control { padding: .72rem .95rem; }
.ag-auth-card .input-group-text { background: var(--ag-card); }
.ag-pass-toggle { cursor: pointer; }
.ag-divider { display: flex; align-items: center; gap: .8rem; color: var(--ag-muted); font-size: .78rem; margin: 1.4rem 0; }
.ag-divider::before, .ag-divider::after { content: ""; flex: 1; height: 1px; background: var(--ag-border); }
.ag-otp-btn { border: 1px solid var(--ag-border-strong); background: var(--ag-card); }
.ag-demo-note { border: 1px dashed var(--ag-orange-300); background: var(--ag-orange-50); color: var(--ag-orange-800); border-radius: var(--ag-radius); padding: .65rem .85rem; font-size: .8rem; display: flex; gap: .55rem; align-items: flex-start; }
[data-bs-theme="dark"] .ag-demo-note { background: rgba(255, 176, 107, .08); color: var(--ag-orange-300); }
@media (max-width: 991.98px) {
  .ag-auth { grid-template-columns: 1fr; }
  .ag-auth-brand { display: none; }
  .ag-auth-card .mobile-logo { display: block; }
  .ag-auth-body { background: linear-gradient(180deg, #074155 0, #074155 230px, var(--ag-bg) 230px); }
  .ag-auth-card { background: var(--ag-card); border-radius: var(--ag-radius-xl); padding: 1.6rem; box-shadow: var(--ag-shadow-lg); }
  .ag-auth-card .mobile-logo { margin: -6.9rem auto 1.4rem; height: 72px; }
}

/* ---------- sidebar "Soon" badge ---------- */
.ag-menu-link .ag-soon-badge { background: rgba(255, 255, 255, .08); color: rgba(245, 240, 220, .55); font-weight: 600; letter-spacing: .04em; }
.ag-menu-link.active .ag-soon-badge { background: rgba(4, 44, 57, .15); color: var(--ag-teal-900); }

/* ---------- coming soon page ---------- */
.ag-soon-hero { position: relative; overflow: hidden; border: 0; color: #e8f2f4; background: linear-gradient(115deg, #074155 0%, #0a5068 55%, #0f617c 100%); }
.ag-soon-hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 300px; height: 300px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 176, 107, .35), transparent 70%); }
.ag-soon-hero h2 { color: #fff; }
.ag-soon-hero .lead { color: rgba(232, 242, 244, .8); max-width: 640px; font-size: 1rem; }
.ag-soon-hero .ag-soon-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .8rem; border-radius: 999px; background: rgba(255, 176, 107, .18); color: var(--ag-orange-300); font-weight: 700; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.ag-soon-hero > * { position: relative; z-index: 1; }
.ag-ready-card { display: flex; gap: 1rem; align-items: flex-start; padding: 1.2rem; height: 100%; color: inherit; }
.ag-ready-card:hover .fw-semibold { color: var(--ag-teal-600); }

/* ---------- estimate form ---------- */
.est-grid { width: 100%; border-collapse: separate; border-spacing: 0; }
.est-grid th { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ag-muted); font-weight: 700; padding: .65rem .5rem; background: var(--ag-card-2); border-bottom: 1px solid var(--ag-border); white-space: nowrap; }
.est-grid td { padding: .6rem .5rem; vertical-align: top; border-bottom: 1px dashed var(--ag-border); }
.est-grid tr.est-row:hover td { background: var(--ag-hover); }
.est-grid .num { text-align: right; }
.est-grid .form-control, .est-grid .form-select { padding: .42rem .55rem; font-size: .86rem; border-radius: 8px; }
.est-grid .select2-container--default .select2-selection--single { min-height: 36px; border-radius: 8px; }
.est-grid .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 34px; font-size: .86rem; }
.est-grid .select2-container--default .select2-selection--single .select2-selection__arrow { height: 34px; }
.est-grid .est-sr { width: 34px; text-align: center; color: var(--ag-muted); font-weight: 700; padding-top: 1rem; }
.est-item { min-width: 250px; }
.est-item .est-meta { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .35rem; font-size: .74rem; }
.est-item textarea { margin-top: .35rem; font-size: .8rem !important; resize: vertical; }
.est-kind { font-size: .68rem; font-weight: 700; padding: .12rem .45rem; border-radius: 6px; letter-spacing: .02em; }
.est-kind.prod { background: var(--lb-primary-bg); color: var(--lb-primary-fg); }
.est-kind.man { background: var(--lb-orange-bg); color: var(--lb-orange-fg); }
.est-rate { min-width: 128px; }
.est-padtar { margin-top: .35rem; font-size: .74rem; line-height: 1.35; color: var(--ag-muted); white-space: nowrap; }
.est-padtar b { color: var(--ag-heading); font-variant-numeric: tabular-nums; }
.est-padtar .m-up { color: var(--lb-success-fg); font-weight: 700; }
.est-padtar .m-low { color: var(--lb-warning-fg); font-weight: 700; }
.est-padtar .m-loss { color: var(--lb-danger-fg); font-weight: 700; }
.est-padtar .chg { color: var(--lb-info-fg); font-weight: 700; }
.est-padtar input { width: 92px; display: inline-block; padding: .18rem .4rem !important; font-size: .76rem !important; height: auto; }
.est-amount { min-width: 110px; font-weight: 700; color: var(--ag-heading); font-variant-numeric: tabular-nums; padding-top: 1rem !important; text-align: right; }
.est-amount .sub { display: block; font-weight: 500; font-size: .72rem; color: var(--ag-muted); }
.est-del { padding-top: .55rem !important; }
.est-sum .tt-r { display: flex; justify-content: space-between; padding: .38rem 0; font-size: .9rem; border-bottom: 1px dashed var(--ag-border); font-variant-numeric: tabular-nums; }
.est-sum .tt-g { display: flex; justify-content: space-between; align-items: center; margin-top: .6rem; padding: .85rem 1rem; border-radius: var(--ag-radius); background: var(--ag-teal); color: #fff; font-family: var(--ag-font-head); font-size: 1.25rem; font-weight: 700; }
[data-bs-theme="dark"] .est-sum .tt-g { background: #0f617c; }
.est-internal { border: 1.5px dashed var(--ag-orange-300); background: var(--ag-orange-50); border-radius: var(--ag-radius-lg); padding: 1rem 1.1rem; }
[data-bs-theme="dark"] .est-internal { background: rgba(255, 176, 107, .07); }
.est-internal .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--lb-orange-fg); }
.est-internal .v { font-family: var(--ag-font-head); font-weight: 700; font-size: 1.15rem; color: var(--ag-heading); font-variant-numeric: tabular-nums; }
.est-sticky { position: sticky; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--ag-card) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--ag-border); margin: 0 -1.35rem -1.2rem; padding: .85rem 1.35rem; border-radius: 0 0 var(--ag-radius-lg) var(--ag-radius-lg); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.est-errors li { margin-bottom: .15rem; }
@media (max-width: 991.98px) {
  /* each line becomes a card: item on top, then qty · unit · HSN, rate · disc, GST · amount */
  .est-grid thead { display: none; }
  .est-grid, .est-grid tbody { display: block; width: 100%; counter-reset: ln; }
  .est-grid tr.est-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: .6rem; row-gap: .15rem; border: 1px solid var(--ag-border); border-radius: var(--ag-radius); margin: 0 .75rem .75rem; padding: .6rem .7rem .7rem; position: relative; background: var(--ag-card); counter-increment: ln; }
  .est-grid td { display: block; border: 0; padding: .3rem 0; min-width: 0; }
  .est-grid td[data-l]::before { content: attr(data-l); display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ag-muted); font-weight: 700; margin-bottom: .2rem; text-align: left; }
  .est-grid td.est-item::before { content: "Item " counter(ln); padding-right: 2.5rem; }
  .est-grid .est-sr { display: none; }
  .est-grid td.est-item { grid-column: 1 / -1; min-width: 0; }
  .est-grid td[data-l="Qty"] { grid-column: span 2; order: 1; }
  .est-grid td[data-l="Unit"] { grid-column: span 2; order: 2; }
  .est-grid td[data-l="HSN / SAC"] { grid-column: span 2; order: 3; }
  .est-grid td.est-rate { grid-column: span 3; order: 4; }
  .est-grid td[data-l="Disc %"] { grid-column: span 3; order: 5; }
  .est-grid td.gst-col { grid-column: span 3; order: 6; }
  .est-grid td.est-amount { grid-column: span 3; order: 7; text-align: left; padding-top: .3rem !important; font-size: 1.02rem; }
  .est-grid .num { text-align: left; }
  .est-grid td input, .est-grid td > div { width: 100% !important; margin-left: 0 !important; }
  .est-grid .est-padtar { white-space: normal; }
  .est-grid .est-padtar input { width: 96px !important; }
  .est-del { position: absolute; top: .45rem; right: .45rem; padding: 0 !important; }
  .est-grid tr.est-row:hover td { background: transparent; }
}

/* ---------- estimate view ---------- */
.est-doc-meta dt { color: var(--ag-muted); font-weight: 500; font-size: .82rem; }
.est-doc-meta dd { font-weight: 600; color: var(--ag-heading); }
.est-lines td, .est-lines th { white-space: nowrap; }
.est-lines td.wrap { white-space: normal; min-width: 240px; }

/* ---------- leads & follow-ups (from the prototype CRM) ---------- */
.ag-seg-links a { padding: .38rem .9rem; border-radius: 8px; font-size: .82rem; font-weight: 700; color: var(--ag-muted); display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.ag-seg-links a .ti { font-size: 1rem; }
.ag-seg-links a:hover { color: var(--ag-heading); }
.ag-seg-links a.on { background: var(--ag-card); color: var(--ag-heading); box-shadow: var(--ag-shadow-sm), 0 2px 8px -4px rgba(7, 65, 85, .3); }
.crm-toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .85rem 1.1rem; border-bottom: 1px solid var(--ag-border); }
.crm-prio input:checked + label.hot, .crm-prio a.hot.on { background: var(--lb-danger-bg); color: var(--lb-danger-fg); }
.crm-prio input:checked + label.warm, .crm-prio a.warm.on { background: var(--lb-warning-bg); color: var(--lb-warning-fg); }
.crm-prio input:checked + label.cold, .crm-prio a.cold.on { background: var(--lb-info-bg); color: var(--lb-info-fg); }
.crm-board { display: flex; gap: 14px; overflow-x: auto; padding: 16px; align-items: flex-start; min-height: 520px; scroll-snap-type: x proximity; }
.crm-col { flex: 0 0 278px; background: var(--ag-card-2); border: 1px solid var(--ag-border); border-radius: var(--ag-radius-lg); display: flex; flex-direction: column; max-height: 74vh; scroll-snap-align: start; }
.crm-col-h { display: flex; align-items: center; gap: .35rem; padding: .8rem .9rem .65rem; font-size: .86rem; color: var(--ag-heading); border-bottom: 1px dashed var(--ag-border-strong); }
.crm-list { padding: .65rem; display: flex; flex-direction: column; gap: .6rem; overflow-y: auto; min-height: 90px; flex: 1; }
.crm-list:empty::after { content: "Drop a lead here"; display: block; text-align: center; color: var(--ag-muted); font-size: .78rem; padding: 1.4rem .5rem; border: 1.5px dashed var(--ag-border-strong); border-radius: var(--ag-radius); }
.crm-card { user-select: none; -webkit-user-select: none; background: var(--ag-card); border: 1px solid var(--ag-border); border-radius: 12px; padding: .75rem .8rem .65rem; cursor: grab; position: relative; box-shadow: var(--ag-shadow-sm); transition: box-shadow .15s, transform .15s, border-color .15s; }
.crm-card::before { content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--ag-line); opacity: .8; }
.crm-card.prio-hot::before { background: var(--ag-danger); }
.crm-card.prio-warm::before { background: var(--ag-warning); }
.crm-card.prio-cold::before { background: var(--ag-info); }
.crm-card:hover { box-shadow: var(--ag-shadow); transform: translateY(-1px); border-color: var(--ag-border-strong); }
.crm-card:active { cursor: grabbing; }
.crm-name { font-weight: 700; color: var(--ag-heading); font-size: .9rem; line-height: 1.3; }
.crm-name:hover { color: var(--ag-teal-600); }
.crm-req { font-size: .78rem; color: var(--ag-muted); margin-top: .2rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.crm-more { width: 26px !important; height: 26px !important; color: var(--ag-muted); background: transparent; margin: -4px -6px 0 0; }
.crm-more:hover { background: var(--ag-hover); color: var(--ag-heading); }
.crm-foot { display: flex; align-items: center; gap: .4rem; margin-top: .65rem; padding-top: .55rem; border-top: 1px dashed var(--ag-border); flex-wrap: wrap; }
.crm-foot .badge { font-size: .68rem; }
.crm-quick { margin-left: auto; display: inline-flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.crm-card:hover .crm-quick, .crm-card:focus-within .crm-quick { opacity: 1; }
.crm-quick .btn-icon.btn-sm { width: 26px; height: 26px; }
.crm-quick .btn-icon.btn-sm .ti { font-size: .9rem; }
.crm-ghost { opacity: .35; border: 1.5px dashed var(--ag-orange); background: var(--ag-orange-50); }
.crm-drag { transform: rotate(2deg); box-shadow: var(--ag-shadow-lg); }
.crm-add { margin: 0 .65rem .65rem; border: 1.5px dashed var(--ag-border-strong); background: transparent; border-radius: var(--ag-radius); padding: .5rem; color: var(--ag-muted); font-weight: 700; font-size: .82rem; display: flex; align-items: center; justify-content: center; gap: .35rem; transition: all .15s; }
.crm-add:hover { border-color: var(--ag-orange); color: var(--ag-orange-700); background: var(--ag-orange-50); }
[data-bs-theme="dark"] .crm-add:hover { background: rgba(255, 176, 107, .08); color: var(--ag-orange); }
@media (hover: none) { .crm-quick { opacity: 1; } }
.fu-card .fu-body { max-height: 74vh; overflow-y: auto; }
.fu-sec + .fu-sec { margin-top: .9rem; }
.fu-sec-h { display: flex; align-items: center; gap: .35rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; color: var(--ag-muted); padding: .3rem .1rem .5rem; }
.fu-item { display: flex; gap: .7rem; align-items: flex-start; padding: .65rem .55rem; border-radius: var(--ag-radius); border: 1px solid transparent; transition: background .15s, border-color .15s; }
.fu-item:hover { background: var(--ag-hover); border-color: var(--ag-border); }
.fu-item.fu-high { box-shadow: inset 3px 0 0 var(--ag-danger); }
.fu-item .grow { flex: 1; }
.fu-acts { display: flex; flex-direction: column; gap: 4px; }
.fu-filter { display: flex; gap: 4px; flex-wrap: wrap; margin-top: .6rem; }
.fu-pf { border: 1px solid var(--ag-border); background: var(--ag-card); border-radius: 999px; padding: .22rem .65rem; font-size: .74rem; font-weight: 700; color: var(--ag-muted); display: inline-flex; align-items: center; }
.fu-pf .ag-dot { width: 7px; height: 7px; margin-right: 5px; }
.fu-pf.on { background: var(--ag-teal); border-color: var(--ag-teal); color: #fff; }
[data-bs-theme="dark"] .fu-pf.on { background: #0f617c; border-color: #0f617c; }
.fu-who { display: flex; align-items: center; gap: .8rem; padding: .75rem .9rem; border-radius: var(--ag-radius); background: var(--ag-card-2); border: 1px solid var(--ag-border); }
.crm-drop { display: flex; align-items: center; gap: .85rem; padding: .95rem 1.1rem; border: 1.5px dashed var(--ag-border-strong); border-radius: var(--ag-radius-lg); background: var(--ag-card-2); cursor: pointer; transition: border-color .15s, background .15s; margin: 0; }
.crm-drop:hover, .crm-drop:focus-visible, .crm-drop.over { border-color: var(--ag-orange); background: var(--ag-orange-50); outline: 0; }
[data-bs-theme="dark"] .crm-drop:hover, [data-bs-theme="dark"] .crm-drop.over { background: rgba(255, 176, 107, .08); }
.crm-files { display: flex; flex-wrap: wrap; gap: .4rem; }
.crm-files:empty { display: none; }
.crm-file { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .4rem .3rem .6rem; border-radius: 8px; background: var(--ag-card); border: 1px solid var(--ag-border); font-size: .78rem; font-weight: 600; color: var(--ag-heading); max-width: 100%; }
a.crm-file:hover { border-color: var(--ag-orange); color: var(--ag-heading); }
.crm-file > .ti { color: var(--ag-orange-600); font-size: 1rem; }
.crm-file small { color: var(--ag-muted); font-weight: 500; }
.crm-file button { border: 0; background: transparent; color: var(--ag-muted); width: 22px; height: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.crm-file button:hover { background: var(--lb-danger-bg); color: var(--lb-danger-fg); }
.ag-bell-count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--ag-danger); color: #fff; font-size: .64rem; font-weight: 800; display: flex; align-items: center; justify-content: center; border: 2px solid var(--ag-card); }
.ag-bell-item { display: flex; gap: .6rem; align-items: center; padding: .55rem .75rem; border-radius: 8px; color: var(--ag-text); }
.ag-bell-item:hover { background: var(--ag-hover); color: var(--ag-heading); }
@media (max-width: 767.98px) {
  .crm-board { padding: 12px; gap: 10px; min-height: 0; scroll-snap-type: x mandatory; }
  .crm-col { flex-basis: 84vw; max-height: none; }
  .crm-list { max-height: 62vh; }
  .crm-toolbar { padding: .7rem 1rem; }
  .crm-toolbar .ag-seg-links a { padding: .35rem .6rem; }
  .ag-page-actions > .ag-seg-links { flex: 1 1 100%; }
  .ag-page-actions > .ag-seg-links a { flex: 1; justify-content: center; }
  .fu-card .fu-body { max-height: 46vh; }
  .fu-acts { flex-direction: row; }
  .fu-item { flex-wrap: wrap; }
  .fu-item .fu-acts { margin-left: auto; }
}

/* ---------- Market line (purple), next to Showroom (jade) and Projects (copper) ---------- */
body[data-line="market"] { --ag-line: #6f5bd3; }
.ag-line-switch button.on[data-line="market"] { background: #6f5bd3; color: #fff; box-shadow: 0 4px 10px -4px rgba(111, 91, 211, .8); }
.ag-chooser .modal-dialog { max-width: 1000px; }
.ag-choice.market:hover { border-color: #6f5bd3; }
.ag-choice.market .go { color: var(--lb-purple-fg); }
.ag-choice.market::after { background: radial-gradient(circle, var(--lb-purple-bg), transparent 70%); }

/* =====================================================================
   Phones (< 768px) and tablets — the whole app on a mobile screen
   ===================================================================== */
.ag-search-open, .ag-search-close, .ag-tabbar, .ag-filter-toggle, .est-sticky-total { display: none; }

@media (max-width: 767.98px) {
  /* inputs at 16px so phones do not zoom in when a field is tapped */
  input.form-control, select.form-select, textarea.form-control, .select2-search__field, div.dt-container .dt-search input { font-size: 16px !important; }

  /* ---------- top bar: search opens over the whole bar ---------- */
  .ag-topbar { height: 56px; gap: .35rem; padding: 0 .45rem; }
  .ag-search { display: none; }
  .ag-search-open { display: inline-flex; }
  body.ag-searching .ag-search { display: flex; align-items: center; position: absolute; inset: 0; max-width: none; z-index: 3; padding: 0 .35rem 0 .15rem; background: var(--ag-card); border-radius: var(--ag-radius-lg); }
  body.ag-searching .ag-search .ti-search { left: .95rem; }
  body.ag-searching .ag-search input { height: 100%; padding-left: 2.7rem; }
  body.ag-searching .ag-search-close { display: inline-flex; }
  .ag-search-results { left: 0; right: 0; width: auto; max-height: calc(100dvh - 150px); }
  .ag-search-results a { padding: .65rem 1rem; }
  .ag-line-switch button { padding: .35rem .6rem; }
  .ag-topbar .dropdown-menu { max-width: calc(100vw - 1.5rem); }

  /* ---------- bottom tab bar ---------- */
  .ag-tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1032; padding: 0 .25rem env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--ag-card) 93%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--ag-border); box-shadow: 0 -10px 26px -18px rgba(7, 65, 85, .4); }
  .ag-tabbar > a, .ag-tabbar > button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 60px; border: 0; background: none; padding: 0;
    color: var(--ag-muted); font-size: .68rem; font-weight: 700; position: relative; -webkit-tap-highlight-color: transparent; min-width: 0; }
  .ag-tabbar > * > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ag-tabbar .ti { font-size: 1.45rem; }
  .ag-tabbar .on { color: var(--ag-teal); }
  [data-bs-theme="dark"] .ag-tabbar .on { color: #9fd0de; }
  .ag-tabbar .on::before { content: ""; position: absolute; top: -1px; left: 50%; width: 28px; height: 3px; margin-left: -14px; border-radius: 0 0 4px 4px; background: var(--ag-orange); }
  .ag-tabbar > a.ag-tabbar-fab { align-self: start; justify-self: center; width: 54px; height: 54px; margin-top: -16px; border-radius: 18px; color: var(--ag-teal-900);
    background: linear-gradient(140deg, var(--ag-orange) 0%, var(--ag-orange-500) 100%); box-shadow: 0 10px 20px -8px rgba(246, 148, 63, .95), 0 0 0 5px var(--ag-bg); transition: transform .12s; }
  .ag-tabbar > a.ag-tabbar-fab .ti { font-size: 1.75rem; }
  .ag-tabbar > a.ag-tabbar-fab:active { transform: scale(.94); }
  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body:not(.has-tabbar) { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .ag-footer { justify-content: center; text-align: center; font-size: .74rem; }
  .ag-toasts { top: .6rem; left: .75rem; right: .75rem; }
  .ag-toast { min-width: 0; max-width: none; }

  /* ---------- page head, cards ---------- */
  .ag-page-head { align-items: stretch; gap: .8rem; margin-bottom: 1rem; }
  .ag-page-title { font-size: 1.25rem; flex-wrap: wrap; row-gap: .3rem; }
  .ag-page-title .ag-tile { width: 36px; height: 36px; font-size: 1.15rem; border-radius: 10px; }
  .ag-page-sub { font-size: .8rem; }
  .ag-page-actions > .btn { flex: 1 1 calc(50% - .5rem); }
  .ag-page-actions > .ag-chip { margin-right: auto; }
  .card { --bs-card-spacer-x: 1rem; --bs-card-spacer-y: 1rem; }
  .card-header { padding-top: .8rem; padding-bottom: .8rem; }
  .ag-form-section { padding: 1rem; }
  .ag-kv { grid-template-columns: 104px minmax(0, 1fr); gap: .4rem .75rem; }
  .btn-icon.btn-sm { width: 34px; height: 34px; }
  .ag-actions { gap: 8px; }
  .nav-pills.ag-pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -.75rem; padding: 0 .75rem 2px; width: calc(100% + 1.5rem); }
  .nav-pills.ag-pills .nav-link { white-space: nowrap; }
  .ag-soon-hero .card-body { padding: 1.4rem !important; }
  .ag-soon-hero h2 { font-size: 1.45rem; }
  .ag-chip-rail { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; margin: 0 -.75rem; padding: 0 .75rem 2px; }
  .ag-chip-rail > * { flex: none; white-space: nowrap; }
  .ag-savebar-host { border: 0; box-shadow: none; background: transparent; margin: 0 !important; }

  /* ---------- save bar of every form: fixed at the bottom ---------- */
  .ag-savebar { position: fixed !important; left: 0; right: 0; bottom: 0; z-index: 1031; margin: 0 !important; border-radius: 0 !important; display: flex; flex-wrap: nowrap; gap: .5rem; align-items: center;
    padding: .6rem .75rem calc(.6rem + env(safe-area-inset-bottom)) !important; background: color-mix(in srgb, var(--ag-card) 94%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--ag-border); box-shadow: 0 -10px 26px -18px rgba(7, 65, 85, .4); }
  .ag-savebar > .btn { flex: 0 0 auto; }
  .ag-savebar > .btn-primary { flex: 1 1 auto; }
  .ag-savebar .btn-text { display: none; }
  .est-sticky-total { display: flex; flex-direction: column; line-height: 1.15; margin-right: auto; min-width: 0; }
  .est-sticky-total small { font-size: .66rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ag-muted); font-weight: 700; }
  .est-sticky-total b { font-family: var(--ag-font-head); font-size: 1.08rem; color: var(--ag-heading); white-space: nowrap; }

  /* ---------- Yajra listings: every row is a card ---------- */
  .ag-dt-card table.dataTable > thead, .ag-dt-card table.dataTable > tfoot { display: none; }
  .ag-dt-card table.dataTable, .ag-dt-card table.dataTable > tbody { display: block; width: 100% !important; }
  .ag-dt-card table.dataTable > tbody > tr { display: block; position: relative; padding: .8rem 1rem .75rem; border-bottom: 1px solid var(--ag-border); background: var(--ag-card); }
  .ag-dt-card table.dataTable > tbody > tr:last-child { border-bottom: 0; }
  .ag-dt-card table.dataTable > tbody > tr > td { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 28px; padding: .2rem 0; border: 0; background: transparent !important; text-align: right; }
  .ag-dt-card table.dataTable > tbody > tr > td:empty { display: none; }
  .ag-dt-card table.dataTable > tbody > tr > td::before { content: attr(data-label); flex: none; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ag-muted); text-align: left; }
  .ag-dt-card table.dataTable > tbody > tr > td:nth-child(2) { display: block; text-align: left; padding: 0 3.4rem .55rem 0; margin-bottom: .3rem; border-bottom: 1px dashed var(--ag-border); font-size: .95rem; }
  .ag-dt-card table.dataTable > tbody > tr > td:nth-child(2)::before { display: none; }
  .ag-dt-card table.dataTable > tbody > tr > td.sr { position: absolute; top: .8rem; right: 1rem; width: auto; min-height: 0; gap: 0; padding: .12rem .45rem; border-radius: 6px; background: var(--ag-hover) !important; font-size: .72rem; }
  .ag-dt-card table.dataTable > tbody > tr > td.sr::before { content: "#"; font-size: inherit; letter-spacing: 0; color: inherit; }
  .ag-dt-card table.dataTable > tbody > tr > td.dt-actions { position: static; width: auto; box-shadow: none; justify-content: flex-end; margin-top: .45rem; padding-top: .6rem; border-top: 1px dashed var(--ag-border); }
  .ag-dt-card table.dataTable > tbody > tr > td.dt-actions::before { display: none; }
  .ag-dt-card table.dataTable > tbody > tr > td.dt-empty { display: block; text-align: center; padding: 2rem .5rem !important; }
  .ag-dt-card table.dataTable > tbody > tr > td.dt-empty::before { display: none; }
  .ag-dt-card table.dataTable .ag-user-cell .nm { white-space: normal; }
  .ag-dt-card table.dataTable > tbody > tr > td > .dt-v { min-width: 0; text-align: right; }

  /* toolbar: search on its own line, then "Show 10", Filters and Export */
  div.dt-container .ag-dt-top { padding: .85rem 1rem .75rem; gap: .6rem; }
  div.dt-container .ag-dt-top > .dt-layout-cell { display: contents; }
  div.dt-container .ag-dt-top .dt-search { order: -1; flex: 1 1 100%; }
  div.dt-container .ag-dt-top .dt-length { margin-right: auto; }
  div.dt-container .ag-dt-top .ag-dt-tools { flex-wrap: nowrap; }
  div.dt-container .ag-dt-bottom { flex-direction: column; gap: .55rem; padding: .8rem 1rem; }
  div.dt-container .ag-dt-bottom > .dt-layout-cell { justify-content: center; margin: 0; }
  div.dt-container .dt-paging .dt-paging-button { min-width: 38px; height: 38px; }
  div.dt-container div.dt-processing { top: 90px; }

  /* filters fold away behind the Filters button */
  .ag-filter-toggle { display: inline-flex; }
  .ag-dt-filters.ag-folding:not(.show) { display: none; }
  .ag-dt-filters { padding: .8rem 1rem; gap: .6rem; }
  .ag-dt-filters > div { flex: 1 1 calc(50% - .6rem); min-width: 0; max-width: none; }
  .dt-container > .ag-dt-filters { background: var(--ag-card-2); border-top: 1px solid var(--ag-border); }

  /* ---------- estimate view: lines as small cards ---------- */
  .est-lines thead { display: none; }
  .est-lines, .est-lines tbody { display: block; }
  .est-lines tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .1rem .6rem; padding: .75rem 1rem; border-bottom: 1px solid var(--ag-border); }
  .est-lines tbody tr:last-child { border-bottom: 0; }
  .est-lines tbody td { display: block; padding: .15rem 0 !important; border: 0; text-align: left !important; white-space: normal; min-width: 0; }
  .est-lines tbody td[data-l]::before { content: attr(data-l); display: block; font-size: .64rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ag-muted); }
  .est-lines tbody td.wrap { grid-column: 1 / -1; min-width: 0; padding-bottom: .35rem !important; }
  .est-lines tbody td.ln-no { display: none; }
  .est-lines tbody td.ln-amt { font-size: 1rem; }
  .est-lines tbody td[data-l="Qty"] { order: 1; } .est-lines tbody td[data-l="Rate"] { order: 2; } .est-lines tbody td.ln-amt { order: 3; }
  .est-lines tbody td.ln-cost { order: 4; } .est-lines tbody td[data-l="Disc"] { order: 5; } .est-lines tbody td[data-l="GST"] { order: 6; } .est-lines tbody td[data-l="HSN"] { order: 7; }

  /* ---------- modals: small dialogs rise from the bottom ---------- */
  .modal-dialog-centered:not(.modal-fullscreen-sm-down) { align-items: flex-end; min-height: 100%; margin: 0; max-width: none; }
  .modal-dialog-centered:not(.modal-fullscreen-sm-down) .modal-content { border-radius: 22px 22px 0 0; max-height: 94dvh; overflow-y: auto; }
  .modal-dialog-centered:not(.modal-fullscreen-sm-down) .modal-footer { border-radius: 0; padding-bottom: calc(.9rem + env(safe-area-inset-bottom)); }
  .modal.fade .modal-dialog-centered:not(.modal-fullscreen-sm-down) { transform: translateY(60px); }
  .modal.show .modal-dialog-centered:not(.modal-fullscreen-sm-down) { transform: none; }
  .modal-header, .modal-body { padding-left: 1rem; padding-right: 1rem; }
  .modal-footer { padding-left: 1rem; padding-right: 1rem; flex-wrap: nowrap; }
  .modal-footer > .btn-primary { flex: 1 1 auto; }
  .ag-chooser-head { padding: 1.5rem 1rem .25rem; }
  .ag-chooser-head img { height: 58px; }
  .ag-choice { padding: 1.1rem 1.1rem 1rem; }
  .ag-choice kbd, .ag-choice .feat { display: none; }
  .ag-choice .ag-tile { width: 48px; height: 48px; font-size: 1.5rem; margin-bottom: .7rem; }
  .ag-choice .go { margin-top: .7rem; }
}

/* the off-canvas sidebar casts no shadow on the page edge until it opens */
@media (max-width: 1199.98px) {
  .ag-sidebar { box-shadow: none; }
  body.ag-mobile-open .ag-sidebar { box-shadow: 6px 0 30px -18px rgba(2, 28, 37, .8); }
}

/* tablets: the sidebar is off-canvas, filters three to a row */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .ag-dt-filters > div { flex: 1 1 200px; max-width: none; }
  .ag-search kbd { display: none; }
}
