/* =====================================================================
   Quotation Maker – responsive layout
   Desktop  : > 1100px   (full sidebar, editor side by side)
   Tablet   : 701–1100px (icon sidebar, editor Edit / Preview switch)
   Mobile   : ≤ 700px    (top bar + slide-in menu, cards instead of tables)
   ===================================================================== */

#topbar, #sbBackdrop, .ed-mtabs { display: none; }
#app { height: 100vh; height: 100dvh; }
.ed { height: 100vh; height: 100dvh; }
img, svg { max-width: 100%; }
.table-scroll { -webkit-overflow-scrolling: touch; }

/* ---------- large desktop ---------- */
@media (min-width: 1500px) {
  #view { padding: 30px 44px 48px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
}

/* ---------- small desktop / tablet landscape ---------- */
@media (max-width: 1280px) {
  #view { padding: 22px 24px 36px; }
  .stats.stats-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rep-grid { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
}

/* =====================================================================
   TABLET  (≤ 1100px)
   ===================================================================== */
@media (max-width: 1100px) {
  /* icon sidebar (same look as in the editor) */
  #sidebar { width: 64px; }
  #sidebar .brand b, #sidebar .brand small, #sidebar nav a span, #sidebar .nav-new span, #sidebar .nav-head, #sidebar .user-txt { display: none; }
  #sidebar nav a { justify-content: center; padding: 11px 0; }
  #sidebar .brand { padding: 16px 14px; justify-content: center; }
  #sidebar .nav-new { margin: 8px 8px 0; padding: 8px 0; justify-content: center; }
  #sidebar .sb-foot { padding: 10px 8px; }
  #sidebar .user-chip { justify-content: center; padding: 6px 0; }

  .two-col { grid-template-columns: 1fr; }
  .dash-top { grid-template-columns: 1fr; }
  .stats.stats-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* editor: one panel at a time with an Edit / Preview switch */
  .ed-mtabs { display: flex; gap: 4px; padding: 6px 10px; background: #fff; border-bottom: 1px solid var(--line); flex: none; }
  .mtab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; border: 1px solid var(--line2); border-radius: 9px; background: #fff; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
  .mtab.on { background: var(--pri); border-color: var(--pri); color: #fff; }
  .ed-main { display: block; position: relative; }
  .ed-left { width: 100% !important; min-width: 0; height: 100%; border-right: 0; }
  .ed-split { display: none; }
  .ed-right { display: none; height: 100%; }
  .ed.mview-preview .ed-left { display: none; }
  .ed.mview-preview .ed-right { display: flex; }
  .ed-pane { padding: 14px 16px 40px; }
  .pv-scroll { padding: 12px 0 30px; }
}

/* =====================================================================
   MOBILE  (≤ 700px)
   ===================================================================== */
@media (max-width: 700px) {
  html { -webkit-text-size-adjust: 100%; }
  body { font-size: 14.5px; }

  /* --- top bar + slide-in menu --- */
  #topbar { display: flex; align-items: center; gap: 10px; position: fixed; top: 0; left: 0; right: 0; z-index: 950; height: 56px; padding: 0 12px; padding-top: env(safe-area-inset-top); background: linear-gradient(90deg, var(--side), var(--side2)); color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
  .tb-btn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .08); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
  .tb-btn:active { background: rgba(255, 255, 255, .18); }
  .tb-brand { display: flex; align-items: center; gap: 8px; color: #fff !important; text-decoration: none !important; flex: 1; min-width: 0; }
  .tb-brand b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tb-brand .brand-mark { width: 30px; height: 30px; border-radius: 8px; font-size: 14px; flex: none; }
  #tbNew { height: 36px; flex: none; }
  body.auth-mode #topbar, body.editor-mode #topbar { display: none; }

  #app { display: block; height: auto; min-height: 100dvh; }
  #sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 1001; width: 280px !important; max-width: 86vw; transform: translateX(-102%); transition: transform .25s ease; box-shadow: 8px 0 30px rgba(0, 0, 0, .3); overflow-y: auto; }
  body.sb-open #sidebar { transform: none; }
  #sbBackdrop { display: block; position: fixed; inset: 0; z-index: 1000; background: rgba(10, 18, 30, .5); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.sb-open #sbBackdrop { opacity: 1; pointer-events: auto; }
  body.sb-open { overflow: hidden; }
  /* full menu (undo icon-only) */
  #sidebar .brand b, #sidebar .brand small, #sidebar .nav-head, #sidebar .user-txt { display: block; }
  #sidebar nav a span, #sidebar .nav-new span { display: inline; }
  #sidebar .brand { padding: 18px 18px 16px; justify-content: flex-start; padding-top: calc(18px + env(safe-area-inset-top)); }
  #sidebar nav a { justify-content: flex-start; padding: 12px 14px; font-size: 15px; }
  #sidebar .nav-new { margin: 10px 12px 0; padding: 0 14px; height: 44px; justify-content: center; }
  #sidebar .sb-foot { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); display: block; }
  #sidebar .user-chip { justify-content: flex-start; padding: 8px 10px; }
  body.editor-mode #sidebar { display: none; }

  #view { overflow: visible; padding: 72px 14px calc(30px + env(safe-area-inset-bottom)); }
  body.editor-mode #view { padding: 0; }

  /* --- general --- */
  .page-head { align-items: flex-start; margin-bottom: 14px; gap: 10px; }
  .page-head h1 { font-size: 21px; }
  .page-head p { font-size: 13px; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; justify-content: center; }
  .btn { height: 42px; }
  .btn-sm { height: 36px; }
  .icon-btn { width: 38px; height: 38px; }
  input[type=text], input[type=number], input[type=date], input[type=search], input[type=email], input[type=password], input[type=tel], input[type=url], input:not([type]), select, textarea { font-size: 16px; height: 44px; }
  textarea { height: auto; }
  .chip-input { font-size: 16px; min-height: 44px; }
  .form-row2, .form-row3 { grid-template-columns: 1fr; }
  .card { border-radius: 12px; }
  .form-card { padding: 16px 14px 6px; }
  .filters { gap: 8px; }
  .filters .search { max-width: none; flex: 1 1 100%; }
  .filters select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .cards { grid-template-columns: 1fr; gap: 12px; }
  .card-actions .btn { flex: 1 1 auto; justify-content: center; }
  .empty { padding: 34px 14px; }

  /* --- home --- */
  .hero-new { padding: 16px; gap: 12px; }
  .hero-ic { width: 46px; height: 46px; }
  .hero-new b { font-size: 17px; }
  .stats, .stats.stats-2 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stats.stats-5 { grid-template-columns: 1fr 1fr; }
  .stat { padding: 12px; gap: 10px; }
  .stat-ic { width: 36px; height: 36px; }
  .stat-v { font-size: 19px; }

  /* --- modals slide up from the bottom --- */
  .modal-overlay { padding: 0; align-items: end; place-items: end stretch; }
  .modal { width: 100% !important; max-width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0; animation: slideup .22s ease; }
  .modal-head { padding: 14px 16px 8px; }
  .modal-head::before { content: ""; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; border-radius: 4px; background: #d5dbe3; transform: translateX(-50%); }
  .modal-head { position: relative; }
  .modal-body { padding: 6px 16px 14px; }
  .modal-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; justify-content: center; }
  @keyframes slideup { from { transform: translateY(40px); opacity: .4; } }
  .pop-menu { min-width: 0; width: min(320px, calc(100vw - 16px)); }
  .pop-item { padding: 12px 12px; font-size: 15px; }
  .combo-list { max-width: calc(100vw - 16px); }
  .combo-item { padding: 11px 12px; font-size: 15px; }
  #toasts { left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { max-width: none; text-align: center; }
  .pw-banner { left: 10px; right: 10px; transform: none; flex-wrap: wrap; bottom: calc(10px + env(safe-area-inset-bottom)); }
  .busy-box { margin: 0 20px; }

  /* --- login --- */
  .auth-wrap { padding: 16px; align-items: start; padding-top: 12vh; }
  .auth-card { padding: 22px 18px 24px; border-radius: 16px; }

  /* --- editor --- */
  .ed-top { padding: 6px 8px; gap: 4px; flex-wrap: nowrap; }
  .ed-top .btn span, .ed-top a.btn span { display: none; }
  .ed-top .btn { width: 40px; padding: 0; justify-content: center; height: 40px; }
  .ed-top .btn-primary { width: auto; padding: 0 12px; }
  .ed-top .btn-primary span { display: inline; }
  .ed-title { flex: 1; min-width: 0; }
  .ed-title b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
  .ed-title small, .ed-title .muted { display: none; }
  .ed-state { display: none; }
  .ed-top .grow { display: none; }
  .stepper { padding: 8px; gap: 2px; scrollbar-width: none; }
  .stepper::-webkit-scrollbar { display: none; }
  .step { padding: 6px 8px; }
  .step:not(.active) .step-l { display: none; }
  .step-head h2 { font-size: 18px; }
  .step-head p { font-size: 13px; }
  .ed-pane { padding: 12px 12px 24px; }
  .ed-card { padding: 12px 12px 2px; }
  .ed-foot { padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
  .ed-foot .btn-lg { flex: 1; justify-content: center; }
  .ed-foot .grow { display: none; }
  .pn-value { font-size: 21px; }
  .spec-row { grid-template-columns: 1fr; gap: 4px; padding: 6px 0; }
  .spec-body { padding: 4px 10px 8px; }
  .qno { flex-wrap: wrap; }
  .dl-grid { grid-template-columns: 1fr; }
  .dl-card { padding: 12px; }
  .add-bar { padding: 8px; gap: 5px; }
  .add-btn { height: 36px; padding: 0 10px; font-size: 13px; }
  .add-label { width: 100%; }
  .sec-head { gap: 6px; padding: 8px 6px; min-height: 52px; }
  .sec-head .grip { display: none; }
  .sec-acts .icon-btn { width: 32px; height: 32px; }
  .sec-name b { font-size: 13.5px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .sec-body { padding: 10px 10px 6px; }
  .rte-bar { gap: 1px; }
  .rte-btn { min-width: 34px; height: 34px; }
  .rte-btn.rte-field { margin-left: 0; }
  .rte-area { font-size: 16px; }
  .tbl-title { flex-direction: column; align-items: stretch; }
  .tbl-flags .chk { margin-bottom: 4px; }
  .colctl { flex-wrap: wrap; white-space: normal; }
  .tbl-grid .chip-input-wrap.cell .chip-input { min-width: 140px; }
  .tbl-foot .hint { width: 100%; margin: 4px 0 0; }
  .imgpick { flex-direction: column; align-items: stretch; }
  .imgpick-thumb { width: 100%; height: 120px; }
  .imgpick-actions { flex-direction: row; flex-wrap: wrap; }
  .pv-bar { flex-wrap: wrap; gap: 6px; padding: 6px 8px; }
  .pv-bar .chk { order: 9; width: 100%; margin: 0; font-size: 12px; }
  .pv-scroll { padding: 10px 0 24px; }
  .notice { padding: 10px 12px; }

  /* --- products / company / fields --- */
  .kvlist .kv-row { grid-template-columns: 1fr 1fr auto auto; }
  .co-preview-wrap { height: 170px; }
  .co-preview { transform: scale(.4); }
  .fields-ed .table-scroll { max-height: none; }
  .fields-foot { padding: 12px 4px; }
  .fb-row { flex-wrap: wrap; }
  .fb-row select, .fb-row input { flex: 1 1 140px; }
  .opt-row .opt-code { width: 64px; }
  .term-row { padding: 6px; }

  /* --- reports --- */
  .report-filters { padding: 12px 12px 2px; }
  .preset-bar { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 12px; padding: 0 12px 4px; scrollbar-width: none; }
  .preset-bar::-webkit-scrollbar { display: none; }
  .preset { flex: none; padding: 8px 14px; }
  .custom-range { flex-direction: column; gap: 8px; }
  .custom-range label { justify-content: space-between; }
  .custom-range input { width: auto; flex: 1; }
  .report-out .stat-v { font-size: 17px; }
  .rep-grid { grid-template-columns: 1fr; gap: 12px; }
  .rep-card { padding: 12px; }

  /* --- revision preview inside modal --- */
  .rev-scale { padding: 6px; }
}

/* ---------- very small phones ---------- */
@media (max-width: 340px) {
  .stats, .stats.stats-2, .stats.stats-5 { grid-template-columns: 1fr; }
  table.data-table:not(.fields-table) tr { grid-template-columns: 1fr; }
  .tb-brand b { font-size: 14.5px; }
  .hero-new small { display: none; }
}

/* ---------- touch devices: no hover-only tricks ---------- */
@media (hover: none) {
  .pv-doc .blk:hover { outline-color: transparent; }
  .hero-new:hover, .dl-card:hover { transform: none; }
}

/* ---------- landscape phones: keep editor usable ---------- */
@media (max-height: 500px) and (max-width: 1100px) {
  .ed-mtabs { padding: 4px 8px; }
  .mtab { height: 32px; }
  .stepper { padding: 4px 8px; }
  .step-head { margin-bottom: 8px; }
  .step-head p { display: none; }
}

/* never let the app itself scroll sideways */
@media (max-width: 1100px) {
  body { overflow-x: hidden; }
}

/* login card never wider than the screen */
.auth-wrap { grid-template-columns: minmax(0, 1fr); }
.auth-card { width: 100%; max-width: 400px; justify-self: center; box-sizing: border-box; }

@media (max-width: 700px) {
  .pw-banner { gap: 6px 10px; padding: 10px 12px; font-size: 13px; }
  .pw-banner > .ic-wrap { display: none; }
  .pw-banner .btn { margin-left: auto; }
}
#sidebar nav a:focus { outline: none; }
#sidebar nav a:focus-visible { outline: 2px solid #2bb8f0; outline-offset: 2px; }
@media (max-width: 700px) { .hide-phone { display: none !important; } }

/* =====================================================================
   LIST TABLES AS CARDS (tablet portrait and phones, ≤ 900px)
   ===================================================================== */
@media (max-width: 900px) {
  /* --- tables become cards --- */
  .table-card { overflow: visible; background: transparent; border: 0; box-shadow: none; }
  .table-card > .card-head { padding: 4px 2px 10px; }
  table.data-table:not(.fields-table) { display: block; }
  table.data-table:not(.fields-table) tbody { display: block; }
  table.data-table:not(.fields-table) tr:first-child:has(th) { display: none; }
  table.data-table:not(.fields-table) tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); position: relative; }
  table.data-table:not(.fields-table) td { display: block; padding: 0; border: 0 !important; white-space: normal !important; min-width: 0; text-align: left !important; }
  table.data-table:not(.fields-table) td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; margin-bottom: 1px; }
  table.data-table:not(.fields-table) td:first-child { grid-column: 1 / -1; padding-right: 44px; font-size: 15px; }
  table.data-table:not(.fields-table) td:first-child::before { display: none !important; }
  table.data-table:not(.fields-table) td.acts { position: absolute; top: 8px; right: 8px; }
  table.data-table:not(.fields-table) td.acts::before { display: none !important; }
  table.data-table:not(.fields-table) td:empty { display: none; }
  table.data-table.hover tr:hover td { background: transparent; }
  .data-table .status-sel { height: 34px; }
  .total-row { background: #f6f8fb !important; }
  .total-row td[colspan] { grid-column: auto; }
  /* report group tables stay real tables but compact */
  .rep-card table.data-table { display: table !important; }
  .rep-card table.data-table tbody { display: table-row-group !important; }
  .rep-card table.data-table tr { display: table-row !important; box-shadow: none; border: 0; padding: 0; margin: 0; }
  .rep-card table.data-table tr:first-child { display: table-row !important; }
  .rep-card table.data-table td { display: table-cell !important; padding: 6px 4px !important; border-bottom: 1px solid var(--line) !important; font-size: 13px; }
  .rep-card table.data-table td::before { display: none !important; }
  .rep-card table.data-table td:first-child { padding-right: 4px !important; font-size: 13px; }
  .rep-card table.data-table th { padding: 6px 4px; font-size: 10.5px; }
  .rep-card .bar-cell { width: 18%; }

}
@media (min-width: 701px) and (max-width: 900px) {
  table.data-table:not(.fields-table) tbody, table.data-table:not(.fields-table) { display: grid !important; grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .rep-card table.data-table { display: table !important; }
  table.data-table:not(.fields-table) tr:first-child:has(th) { display: none; }
}
@media (max-width: 1100px) {
  .ed-title small, .ed-title .muted { display: none; }
  .ed-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 34vw; }
  .ed-state { white-space: nowrap; }
}
@media (max-width: 1100px) {
  .ed-top .grow { display: none; }
  .ed-title { flex: 1 1 auto; min-width: 0; }
  .ed-title b { max-width: none; }
  .filters .search { flex: 1 1 260px; }
}

/* =====================================================================
   App look: logo, install button, quotation cards, bottom navigation
   ===================================================================== */
.brand-logo { width: 38px; height: 38px; border-radius: 10px; background: #fff; object-fit: contain; flex: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
#topbar .brand-logo { width: 32px; height: 32px; border-radius: 8px; }
.auth-brand .brand-logo { width: 46px; height: 46px; border-radius: 12px; box-shadow: 0 2px 10px rgba(15, 28, 43, .2); }
.nav-install { margin: 8px 12px 0; height: 38px; justify-content: center; background: rgba(255, 255, 255, .06); border: 1px dashed rgba(255, 255, 255, .25); color: #d5e4f3; }
.nav-install:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .45); color: #fff; }
@media (max-width: 1100px) and (min-width: 701px) { #sidebar .nav-install { margin: 8px 8px 0; padding: 0; } #sidebar .nav-install span { display: none; } }

.inst-app { display: flex; gap: 14px; align-items: center; padding: 12px; background: #f6f8fb; border-radius: 12px; margin-bottom: 14px; }
.inst-app img { width: 58px; height: 58px; border-radius: 14px; box-shadow: var(--shadow); }
.inst-app small { display: block; color: var(--muted); }
.inst-step { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0; }
.inst-step > span { width: 26px; height: 26px; border-radius: 50%; background: var(--pri); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }

.report-period { flex-wrap: wrap; gap: 6px 8px; }
.rp-count { font-weight: 600; font-size: 12.5px; color: #0a5f9f; background: #e3f0fc; border-radius: 20px; padding: 2px 10px; }

.mob-only { display: none; }
#bottomnav { display: none; }

/* ---------- cards list (tablet portrait + phone) ---------- */
@media (max-width: 900px) {
  .desk-only { display: none !important; }
  .mob-only { display: grid; }
  .dash-list { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .dash-list > .card-head { padding: 4px 2px 10px; }
  .qlist { grid-template-columns: 1fr 1fr; gap: 12px; }
  .qc { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 14px 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .06); cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-width: 0; transition: transform .12s, box-shadow .12s; -webkit-tap-highlight-color: transparent; }
  .qc:active { transform: scale(.985); box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
  .qc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .qc-no { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .qc-no b { font-size: 14.5px; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .qc-status { display: inline-flex; align-items: center; gap: 3px; border: 0; border-radius: 20px; padding: 3px 9px 3px 11px; font: 600 12px "Segoe UI", system-ui, sans-serif; cursor: pointer; flex: none; }
  span.qc-status { padding-right: 11px; cursor: default; }
  .qc-cust { font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1.3; margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .qc-part { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .qc-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid #eef1f5; }
  .qc-amt { font-weight: 800; font-size: 15.5px; color: #0f3557; white-space: nowrap; }
  .qc-meta { flex: 1; min-width: 0; text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .qc-more { width: 34px; height: 34px; margin: -6px -6px -6px 0; border: 0; background: transparent; border-radius: 10px; color: var(--muted); display: grid; place-items: center; cursor: pointer; flex: none; }
  .qc-more:active { background: #eef1f6; }
  .qc-revs { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; border: 0; background: #f1f6fb; color: var(--pri-d); border-radius: 8px; padding: 4px 8px; font: 600 12px "Segoe UI", system-ui, sans-serif; margin-top: 6px; cursor: pointer; }
  .qc-total { flex-direction: row; justify-content: space-between; align-items: center; background: #0f3557; color: #fff; cursor: default; border: 0; }
  .qc-total b { font-size: 16px; }
}
@media (max-width: 700px) {
  .qlist { grid-template-columns: 1fr; gap: 10px; }
}

/* ---------- bottom navigation (phones) ---------- */
@media (max-width: 700px) {
  #bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; position: fixed; left: 0; right: 0; bottom: 0; z-index: 940; height: calc(62px + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom); background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(15, 28, 43, .08); backdrop-filter: blur(10px); }
  #bottomnav a, #bottomnav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 62px; border: 0; background: none; color: #7a8698; font: 600 11px "Segoe UI", system-ui, sans-serif; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  #bottomnav svg { width: 23px; height: 23px; }
  #bottomnav .on { color: var(--pri); }
  #bottomnav .on svg { stroke-width: 2.4; }
  #bottomnav .bn-new { align-self: start; justify-self: center; width: 56px; height: 56px; margin-top: -18px; border-radius: 18px; background: linear-gradient(135deg, #1c9be6, #0a5f9f); color: #fff; box-shadow: 0 8px 20px rgba(11, 132, 216, .45); }
  #bottomnav .bn-new svg { width: 26px; height: 26px; }
  #bottomnav .bn-new:active { transform: scale(.94); }
  body.auth-mode #bottomnav, body.editor-mode #bottomnav { display: none; }
  #view { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
  body.editor-mode #view { padding-bottom: 0; }
  #tbNew { display: none; }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  body.editor-mode #toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .pw-banner { bottom: calc(72px + env(safe-area-inset-bottom)); }
  /* home: big button is already in the bottom bar */
  .dash-top .hero-new { display: none; }
  .dash-top { margin-bottom: 12px; }
  .page-head p { display: none; }
}

/* ---------- installed app (standalone window) ---------- */
@media (display-mode: standalone) {
  .nav-install { display: none !important; }
  body { overscroll-behavior-y: none; }
}@media (max-width: 700px) { #menuBtn { display: none; } #topbar { padding-left: 16px; } }

/* =====================================================================
   Inquiry statuses, tiles, period filter, downloads, customers, sending
   ===================================================================== */
.st-open { background: #e7f3fc; color: #0a68ad; }
.st-sent { background: #ede9fe; color: #5b3fc4; }
.st-hold { background: #fff4e0; color: #9a5b00; }
.st-won { background: #e3f6ec; color: #0b7a43; }
.st-lost { background: #fdecea; color: #b42318; }
select.enq-status { font-weight: 700; border-color: transparent; }

.dash-top2 { grid-template-columns: minmax(240px, 300px) 1fr; align-items: stretch; }
.status-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stile { display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 10px 12px; cursor: pointer; font: inherit; color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s, transform .12s; min-width: 0; }
.stile:hover { border-color: #b8d7f0; }
.stile:active { transform: scale(.98); }
.stile-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: #eef1f6; color: #4b586b; }
.stile-txt { min-width: 0; }
.stile-txt b { display: block; font-size: 20px; line-height: 1.1; }
.stile-txt small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stile.on { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(11, 132, 216, .18); }
.tl-all .stile-ic { background: var(--pri-l); color: var(--pri); }
.tl-month .stile-ic { background: #f1ecfe; color: #6e45e2; }
.tl-open .stile-ic { background: #e7f3fc; color: #0a68ad; }
.tl-sent .stile-ic { background: #ede9fe; color: #5b3fc4; }
.tl-hold .stile-ic { background: #fff4e0; color: #c77700; }
.tl-won .stile-ic { background: #e3f6ec; color: #0b7a43; }
.tl-lost .stile-ic { background: #fdecea; color: #b42318; }
.result-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 10px; font-size: 13px; color: var(--muted); }
.result-info b { color: var(--ink); }

.period { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line2); border-radius: 8px; padding: 0 4px 0 10px; color: var(--muted); }
.period select { border: 0; box-shadow: none !important; width: auto; min-width: 140px; padding-left: 2px; height: 34px; background: transparent; }
.period-custom { display: inline-flex; align-items: center; gap: 4px; }
.period-custom input { width: 140px; height: 30px; border-radius: 6px; }
.btn-download { border-color: #b8d7f0; color: var(--pri-d); }
.btn-download:hover { background: var(--pri-l); }

/* customer editor */
.cust-ed .ce-title { display: flex; align-items: center; gap: 6px; font-size: 14px; margin: 16px 0 8px; color: #0f3557; }
.ce-list { display: flex; flex-direction: column; gap: 10px; }
.ce-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fafbfd; display: flex; flex-direction: column; gap: 8px; }
.ce-item .fld { margin-bottom: 0; }
.ce-head { display: flex; align-items: center; justify-content: space-between; }
.ce-n { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.ce-list > .btn { align-self: flex-start; }
.multi { display: flex; flex-direction: column; gap: 6px; }
.multi-row { display: flex; gap: 6px; align-items: center; }
.multi-row input { flex: 1; min-width: 0; }
.link-btn.small { font-size: 12.5px; padding: 0; }
.sub-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 14px 0 10px; padding-top: 12px; border-top: 1px dashed var(--line2); }

/* send cards in the editor */
.send-group { margin-bottom: 12px; }
.send-head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: #3e4a5c; margin-bottom: 8px; }
.send-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.send-card { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font: inherit; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.send-card:hover { border-color: #25d366; box-shadow: 0 6px 16px rgba(37, 211, 102, .15); }
.send-card.sc-mail:hover { border-color: var(--pri); box-shadow: 0 6px 16px rgba(11, 132, 216, .15); }
.send-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.sc-wa .send-ic { background: #e7f9ee; color: #128c4b; }
.sc-mail .send-ic { background: #e7f0fd; color: #1e5bb8; }

/* share dialogs */
.sh-label { font-size: 12.5px; font-weight: 600; color: #3e4a5c; margin-bottom: 6px; }
.sh-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.sh-pick { display: flex; align-items: center; gap: 12px; text-align: left; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; cursor: pointer; font: inherit; color: var(--ink); }
.sh-pick small { display: block; color: var(--muted); }
.sh-pick.sel { border-color: #25d366; background: #f2fcf6; }
.sh-radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #c3cbd8; flex: none; }
.sh-pick.sel .sh-radio { border-color: #25d366; background: radial-gradient(#25d366 45%, #fff 50%); }
.chk-pick input { width: 18px; height: 18px; }
.sh-acts { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.sh-act { display: flex; align-items: center; gap: 12px; text-align: left; border: 1px solid var(--line2); border-radius: 12px; background: #fff; padding: 10px 12px; cursor: pointer; font: inherit; color: var(--ink); }
.sh-act small { display: block; color: var(--muted); font-size: 12px; }
.sh-act:hover { border-color: var(--pri); background: #f7fbff; }
.sh-act-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; background: #eef1f6; color: #4b586b; }
.sh-act.sh-wa .sh-act-ic { background: #25d366; color: #fff; }
.sh-act.sh-wa { border-color: #b7ebc9; }
.sh-act.sh-share .sh-act-ic { background: #0b84d8; color: #fff; }
.sh-act.sh-mail .sh-act-ic { background: #1e5bb8; color: #fff; }
.sh-act.sh-mail { border-color: #c7d9f5; }
.sh-note { margin: 10px 0 0; }

/* activity */
.chip.act-send { background: #e7f9ee; color: #128c4b; }
.chip.act-download { background: #e7f0fd; color: #1e5bb8; }
.chip.act-delete { background: #fdecea; color: #b42318; }
.chip.act-quote { background: #f1ecfe; color: #5b3fc4; }
.act-table td:last-child { max-width: 560px; }

/* cards: extra lines */
.qc-sub { font-size: 12.5px; color: #4b586b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qc-contact { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #3e4a5c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- responsive for the new parts ---------- */
@media (max-width: 1280px) {
  .dash-top2 { grid-template-columns: 1fr; }
  .dash-top2 .hero-new { display: none; }
}
@media (max-width: 900px) {
  .status-tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .period { flex: 1 1 100%; }
  .period select { flex: 1; }
}
@media (max-width: 700px) {
  .status-tiles { display: flex; overflow-x: auto; gap: 8px; margin: 0 -14px; padding: 2px 14px 6px; scroll-snap-type: x proximity; scrollbar-width: none; }
  .status-tiles::-webkit-scrollbar { display: none; }
  .stile { flex: none; width: 132px; scroll-snap-align: start; padding: 10px; flex-direction: column; align-items: flex-start; gap: 6px; }
  .stile-ic { width: 30px; height: 30px; border-radius: 8px; }
  .stile-txt b { font-size: 19px; }
  .stile-txt small { white-space: normal; line-height: 1.25; }
  .period { flex-wrap: wrap; padding: 4px 6px 4px 10px; }
  .period select { height: 36px; font-size: 16px; }
  .period-custom { width: 100%; padding-bottom: 4px; }
  .period-custom input { flex: 1; width: auto; height: 40px; }
  .page-head .btn-download { flex: 0 0 auto; }
  .send-grid { grid-template-columns: 1fr; }
  .sh-act { padding: 12px; }
  .cust-ed .form-row2 { grid-template-columns: 1fr; gap: 8px; }
  .ce-item { padding: 10px; }
  .multi-row input { height: 44px; }
  .result-info { margin-top: 0; }
}body.editor-mode #sidebar .nav-install span { display: none; }
body.editor-mode #sidebar .nav-install { margin: 8px 8px 0; padding: 0; }
.stile-txt small { white-space: normal; line-height: 1.2; }
@media (max-width: 700px) { .ed-top .btn-primary span { display: none; } .ed-top .btn-primary { width: 44px; padding: 0; } }
.rev-badge { white-space: nowrap; }
@media (max-width: 900px) { .qc-top { flex-wrap: wrap; row-gap: 6px; } .qc-no b { overflow: visible; text-overflow: clip; } }

/* =====================================================================
   v3 fixes: sidebar never taller than the screen, compact filter bar,
   inquiries, tighter phone layout
   ===================================================================== */
/* desktop: the page itself never scrolls – only the content area (fixes the white strip at the bottom) */
#sidebar { height: 100vh; height: 100dvh; overflow: hidden; }
#sidebar nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
#sidebar .sb-foot { flex: none; }
@media (min-width: 701px) { html, body { overflow: hidden; } }
@media (min-width: 701px) and (max-height: 820px) {
  #sidebar .brand { padding-top: 12px; padding-bottom: 10px; }
  #sidebar nav { padding-top: 6px; gap: 0; }
  #sidebar nav a { padding-top: 7px; padding-bottom: 7px; }
  #sidebar .nav-head { padding-top: 8px; }
  #sidebar .nav-new, #sidebar .nav-install { margin-top: 6px; height: 34px; }
  #sidebar .sb-foot { padding-top: 8px; padding-bottom: 8px; }
}

.st-closed { background: #eceff3; color: #4b586b; }
.tl-closed .stile-ic { background: #eceff3; color: #4b586b; }
.due { color: #b42318; font-weight: 700; }
.enq-box { background: #f6f9fc; border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 0; margin-bottom: 4px; }
.enq-box .form-row3 { grid-template-columns: 1fr 1fr 1fr; }
.enq-box .fld-wide { grid-column: span 1; }
.qc-quote { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border: 1px solid #b8d7f0; background: var(--pri-l); color: var(--pri-d); border-radius: 8px; font: 600 12px "Segoe UI", system-ui, sans-serif; cursor: pointer; flex: none; }
.tiles-wrap { min-width: 0; }

/* filter bar */
.fbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.fb-main { display: flex; gap: 10px; flex: 1 1 320px; min-width: 0; max-width: 420px; }
.fb-main .search { flex: 1; max-width: none; }
.fb-more { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.fb-more > select { width: auto; min-width: 160px; }
.fb-toggle { display: none; position: relative; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 1px solid var(--line2); border-radius: 10px; background: #fff; color: #3e4a5c; font: 600 13.5px "Segoe UI", system-ui, sans-serif; cursor: pointer; flex: none; }
.fb-toggle.has { border-color: var(--pri); color: var(--pri-d); background: var(--pri-l); }
.fb-badge { font-style: normal; min-width: 18px; height: 18px; border-radius: 9px; background: var(--pri); color: #fff; font-size: 11px; display: none; place-items: center; padding: 0 5px; }
.fb-toggle.has .fb-badge { display: grid; }
.report-filters .fbar { margin-top: 2px; }

/* ---------- phones: compact, app-like ---------- */
@media (max-width: 700px) {
  #view { padding: 66px 12px calc(84px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 10px; gap: 8px; flex-wrap: nowrap; align-items: center; }
  .page-head h1 { font-size: 20px; }
  .page-head > div:first-child { min-width: 0; flex: 1; }
  .head-actions { width: auto; flex-wrap: nowrap; gap: 6px; }
  .head-actions .btn { flex: none; height: 36px; padding: 0 10px; font-size: 13px; }
  .head-actions .btn-download span { display: none; }
  .head-actions .btn-download { width: 38px; padding: 0; justify-content: center; }

  /* filter bar: search + Filters button in one slim row */
  .fbar { gap: 0; margin-bottom: 10px; }
  .fb-main { flex: 1 1 100%; max-width: none; gap: 8px; }
  .fbar .search, .fb-main input[type=search] { height: 40px; font-size: 15px; border-radius: 10px; }
  .fb-toggle { display: inline-flex; }
  .fb-more { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 8px; margin-top: 8px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
  .fbar.open .fb-more { display: flex; }
  .fb-more > select, .fb-more .period { width: 100%; min-width: 0; height: 40px; font-size: 15px; }
  .fb-more .period select { height: 38px; font-size: 15px; }
  .fbar .filters, .fbar.filters { flex-wrap: wrap; }

  /* status tiles: small chips in one swipeable row */
  .tiles-wrap { margin: 0 -12px 10px; }
  .status-tiles { margin: 0; padding: 2px 12px 4px; gap: 8px; }
  .stile { width: auto; min-width: 104px; max-width: 150px; padding: 8px 10px; flex-direction: row; align-items: center; gap: 8px; border-radius: 12px; box-shadow: none; }
  .stile-ic { width: 26px; height: 26px; border-radius: 7px; }
  .stile-ic svg { width: 15px; height: 15px; }
  .stile-txt b { font-size: 16px; }
  .stile-txt small { font-size: 11px; line-height: 1.15; }
  .dash-top, .dash-top2 { margin-bottom: 4px; }
  .result-info { margin: 0 0 8px; font-size: 12.5px; }

  /* cards a bit tighter */
  .qc { padding: 12px 12px 10px; border-radius: 14px; }
  .qc-cust { font-size: 15.5px; margin-top: 2px; }
  .qc-foot { margin-top: 6px; padding-top: 8px; }

  /* reports */
  .report-filters { padding: 10px 10px 0; margin-bottom: 12px; }
  .preset-bar { margin: 0 -10px 10px; padding: 0 10px 2px; gap: 6px; }
  .preset { padding: 6px 12px; font-size: 12.5px; }
  .report-period { font-size: 13px; }
  .report-out .stat { padding: 10px 12px; }
  .report-out .stat-v { font-size: 16px; }
  .report-out .stat-l { font-size: 11.5px; }
  .head-actions .btn span { white-space: nowrap; }

  /* inquiry editor */
  .enq-box { padding: 10px 10px 0; }
  .enq-box .form-row3 { grid-template-columns: 1fr 1fr; gap: 0 8px; }
  .enq-box .fld-wide { grid-column: 1 / -1; }
}
@media (max-width: 380px) {
  .head-actions .btn-primary span { display: none; }
  .head-actions .btn-primary { width: 38px; padding: 0; justify-content: center; }
}.tiles-wrap { margin-bottom: 12px; }
.dash-top2 .tiles-wrap { margin-bottom: 0; }

/* activity log on phones: compact 2-line rows */
@media (max-width: 900px) {
  table.act-table tr { grid-template-columns: 1fr auto; gap: 3px 10px; padding: 10px 12px; margin-bottom: 8px; border-radius: 12px; }
  table.act-table td::before { display: none !important; }
  table.act-table td:nth-child(1) { order: 4; grid-column: 1 / -1; font-size: 11.5px !important; color: var(--muted); padding: 0 !important; }
  table.act-table td:nth-child(2) { order: 1; font-size: 14px; }
  table.act-table td:nth-child(3) { order: 2; justify-self: end; }
  table.act-table td:nth-child(4) { order: 3; grid-column: 1 / -1; font-size: 13px; color: #3e4a5c; }
}

/* phone / e-mail lists (customer & inquiry forms) */
.multi { display: flex; flex-direction: column; gap: 8px; }
.multi-row { position: relative; display: flex; align-items: center; }
.multi-row .multi-ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #8a96a8; display: grid; place-items: center; pointer-events: none; }
.multi-row input { flex: 1; min-width: 0; padding-left: 36px !important; }
.multi-row.has-rm input { padding-right: 38px !important; }
.multi-row .multi-rm { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: #9aa5b4; display: grid; place-items: center; cursor: pointer; }
.multi-row .multi-rm:hover { background: #fdecea; color: var(--danger); }
.multi-row:focus-within .multi-ic { color: var(--pri); }
.multi-add { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 12px; border: 1px dashed #b8d7f0; border-radius: 8px; background: #f7fbff; color: var(--pri-d); font: 600 12.5px "Segoe UI", system-ui, sans-serif; cursor: pointer; }
.multi-add:hover { background: var(--pri-l); border-style: solid; }
@media (max-width: 700px) { .multi-row .multi-rm { width: 36px; height: 36px; } .multi-add { height: 38px; } }

/* fields & dropdown table: readable column widths */
.fields-table { min-width: 1080px; }
.fields-table td:nth-child(2) input { min-width: 150px; }
.fields-table td:nth-child(3) input { min-width: 190px; }
.fields-table td:nth-child(4) select { min-width: 150px; }
.fields-table td:nth-child(5) { min-width: 170px; }
.fields-table td:nth-child(5) .btn { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; }
.fields-table .w-unit input { min-width: 64px; }

/* phones: long page titles (product fields, company) put the buttons on their own row */
@media (max-width: 700px) {
  .page-head { flex-wrap: wrap; }
  .page-head > div:first-child { flex: 1 1 170px; }
  .page-head h1 { overflow-wrap: anywhere; line-height: 1.2; }
  .head-actions { margin-left: auto; }
  .kvlist .kv-row { grid-template-columns: 1fr auto auto; }
  .kvlist .kv-row > input:nth-child(2) { grid-column: 1; grid-row: 2; }
}
/* active menu item: left bar drawn with a pseudo element */
#sidebar nav a.active { box-shadow: none; position: relative; }
#sidebar nav a.active::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; background: #2bb8f0; }
/* tablets: give the quotation number room in the editor top bar */
@media (max-width: 1100px) {
  .ed-top > a.btn-ghost span { display: none; }
}

/* ---------- price table editor (step "Price & terms") ---------- */
.pt-card { border: 1px solid #cfe0f1; border-radius: 14px; background: linear-gradient(180deg, #f5faff 0, #fff 120px); margin: 4px 0 16px; overflow: hidden; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.pt-title { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px 10px; }
.pt-title b { display: block; font-size: 15px; color: #0f2c47; }
.pt-title small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.4; margin-top: 2px; }
.pt-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--pri); color: #fff; flex: none; box-shadow: 0 4px 10px rgba(11, 132, 216, .25); }
.pt-list { display: flex; flex-direction: column; gap: 8px; padding: 2px 12px 4px; }
.pt-item { border: 1px solid var(--line); border-radius: 11px; background: #fff; transition: box-shadow .15s, border-color .15s; }
.pt-item.open { border-color: #b9d6f0; box-shadow: 0 4px 14px rgba(15, 44, 71, .08); }
.pt-item.off { background: #f7f8fa; }
.pt-item.off .pt-name b, .pt-item.off .pt-n { color: #9aa5b3; }
.pt-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; min-height: 52px; }
.pt-n { width: 22px; height: 22px; border-radius: 50%; background: var(--pri-l); color: var(--pri-d); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; flex: none; }
.pt-machine .pt-n { background: var(--pri); color: #fff; }
.pt-name { flex: 1; min-width: 0; }
.pt-name b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-name small { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-tag { font-style: normal; font-size: 10.5px; font-weight: 700; margin-left: 8px; padding: 1px 7px; border-radius: 20px; background: #f1f3f6; color: #6b7686; vertical-align: 1px; }
.pt-tag.on { background: #e6f6ec; color: #0f7a3f; }
.pt-amt { font-weight: 700; font-size: 13.5px; color: #0f2c47; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pt-amt.incl { color: #0f7a3f; background: #e6f6ec; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.pt-amt.muted { color: #9aa5b3; font-weight: 600; font-size: 12px; }
.pt-chev { color: #8a96a6; display: grid; place-items: center; transition: transform .2s; flex: none; }
.pt-item.open .pt-chev { transform: rotate(180deg); }
.pt-body { padding: 4px 14px 12px; border-top: 1px dashed var(--line); }
.pt-body textarea { min-height: 44px; }
.pt-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0 10px; }
.pt-grid .fld { margin-bottom: 8px; }
.pt-grid input, .pt-grid select { width: 100%; min-width: 0; }
.pt-ro { height: 36px; display: flex; align-items: center; padding: 0 10px; border-radius: 7px; background: #eef7ee; border: 1px solid #cfe8d2; color: #145c2e; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-note { margin: 2px 0 0; }
.pt-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.pt-acts .grow { flex: 1; }
.pt-foot { padding: 8px 12px 12px; }
.pt-add { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border: 1.5px dashed #9cc4e6; border-radius: 11px; background: #f7fbff; color: var(--pri-d); font: 600 13.5px "Segoe UI", system-ui, sans-serif; cursor: pointer; }
.pt-add:hover { background: var(--pri-l); border-color: var(--pri); }
.pt-totals { background: #0f2c47; color: #dbe7f3; padding: 12px 16px 14px; display: grid; gap: 4px; }
.pt-tot { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.pt-tot b { color: #fff; font-variant-numeric: tabular-nums; }
.pt-grand { font-size: 16px; padding-top: 6px; margin-top: 4px; border-top: 1px solid rgba(255, 255, 255, .18); }
.pt-grand span { color: #fff; font-weight: 700; }
.pt-grand b { color: #7fd3ff; }
.pt-words { font-size: 11.5px; color: #a9bdd2; font-style: italic; }
.switch.sm { width: 34px; height: 20px; }
.switch.sm .slider::before { width: 14px; height: 14px; }
.switch.sm input:checked + .slider::before { transform: translateX(14px); }
.pt-hint { background: #f5faff; border: 1px solid #d6e6f5; border-radius: 10px; padding: 10px 12px 12px; margin-bottom: 8px; }
.pt-hint p { margin: 0 0 8px; color: #3c4a5c; font-size: 13px; }

/* standard texts under a long-text field */
.quick-picks { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.quick-picks > span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.qp { max-width: 100%; border: 1px solid #cfe0f1; background: #f5faff; color: var(--pri-d); border-radius: 20px; padding: 3px 10px; font: 600 11.5px "Segoe UI", system-ui, sans-serif; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qp:hover { background: var(--pri-l); border-color: var(--pri); }
.qp-clear { background: #fff; color: var(--muted); border-color: var(--line2); }

/* inquiry reference in step 1 */
.ref-box { background: #f6f9fc; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 2px; margin: 2px 0 12px; }
.ref-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; color: #0f2c47; margin-bottom: 8px; flex-wrap: wrap; }
.ref-head small { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.pharma-note { display: block; margin-top: 4px; color: #0f7a3f !important; font-weight: 600; }
.enq-hint { display: flex; gap: 6px; align-items: center; margin: 0 0 10px; }
.ind-badge { display: inline-block; margin-left: 8px; font-size: 10.5px; font-weight: 700; padding: 1px 8px; border-radius: 20px; background: #efe7fb; color: #6a3fb5; vertical-align: 2px; }

@media (max-width: 700px) {
  .pt-list { padding: 2px 8px 4px; }
  .pt-top { padding: 10px; gap: 8px; }
  .pt-n { display: none; }
  .pt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pt-tag { display: none; }
  .ref-box .form-row3 { grid-template-columns: 1fr 1fr; }
  .ref-box .form-row3 > :last-child { grid-column: 1 / -1; }
  .pt-title { padding: 12px 12px 8px; }
}
@media (min-width: 701px) and (max-width: 1100px) {
  .pt-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.pt-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pt-grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pt-price-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #f6faf6; border: 1px solid #dcecdc; border-radius: 9px; padding: 6px 6px 6px 12px; margin: 2px 0 4px; }
.pt-price-line > span { font-size: 12.5px; font-weight: 600; color: #3c4a5c; }
.pt-price-line small { font-weight: 400; color: var(--muted); }
.pt-price-line .pt-ro { height: 32px; background: #fff; }
@media (max-width: 700px) {
  .pt-grid.g3, .pt-grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pt-grid.g3 > :nth-child(3) { grid-column: 1 / -1; }
}

/* ---------- new statuses ---------- */
.st-approval { background: #fff1e6; color: #b5470b; }
.st-openq { background: #e6f7f7; color: #0e7470; }
.tl-approval .stile-ic { background: #fff1e6; color: #c2540a; }
.tl-openq .stile-ic { background: #e6f7f7; color: #0e7470; }
.st-dot.st-approval { background: #e8781f; } .st-dot.st-openq { background: #13a19b; }

/* ---------- "Since x days" ---------- */
.since { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: #5d6b7c; background: #f1f4f8; border-radius: 20px; padding: 2px 8px 2px 6px; white-space: nowrap; line-height: 1.5; }
.since svg { flex: none; opacity: .8; }
.since-warn { color: #9a5b00; background: #fff4e0; }
.since-late { color: #b42318; background: #fdecea; }
.since-row { margin-top: 5px; }
.st-remark { display: block; max-width: 220px; margin-top: 3px; font-size: 11.5px; color: #5d6b7c; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qc-since { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 2px; min-width: 0; }
.qc-since .st-remark { margin: 0; flex: 1; min-width: 0; max-width: none; }
.lbl-since { margin-left: 8px; font-weight: 400; }
.lbl-since .since { font-size: 10.5px; padding: 1px 7px 1px 5px; }
.qcount { font-style: normal; background: var(--pri-l); color: var(--pri-d); border-radius: 10px; padding: 0 6px; margin-left: 4px; font-size: 11px; }

/* status control in the quotation editor */
.st-ctl-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.st-ctl-row > .fld { flex: 1 1 220px; margin-bottom: 8px; }
.st-ctl-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding-bottom: 12px; min-width: 0; max-width: 100%; }
.st-hist-box { margin: 2px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfd; }
.st-hist-box > summary { cursor: pointer; padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: #3c4a5c; display: flex; align-items: center; gap: 6px; list-style: none; }
.st-hist-box > summary::-webkit-details-marker { display: none; }
.st-hist-box[open] > summary { border-bottom: 1px solid var(--line); }
.st-hist { padding: 8px 12px 4px; display: flex; flex-direction: column; gap: 9px; max-height: 260px; overflow: auto; }
.st-hist-row { display: flex; gap: 10px; align-items: flex-start; }
.st-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex: none; background: #9aa5b3; }
.st-dot.st-open { background: #0b84d8; } .st-dot.st-sent { background: #6e45e2; } .st-dot.st-hold { background: #e98a00; }
.st-dot.st-won { background: #0f9d58; } .st-dot.st-lost { background: #d92d20; } .st-dot.st-closed { background: #6b7686; }
.st-hist-txt { font-size: 12.5px; min-width: 0; }
.st-hist-rm { color: #3c4a5c; font-style: italic; margin-top: 1px; overflow-wrap: anywhere; }
.remark-dlg .remark-to { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- home: three big buttons ---------- */
.home { max-width: 1080px; margin: 0 auto; padding-top: 8px; }
.home-hello h1 { font-size: 26px; letter-spacing: -.3px; }
.home-hello p { margin: 4px 0 22px; }
.home-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.home-card { position: relative; display: flex; flex-direction: column; gap: 16px; min-height: 230px; padding: 24px 22px 20px; border-radius: 18px; background: #fff; border: 1px solid var(--line); box-shadow: 0 2px 4px rgba(16, 24, 40, .04), 0 10px 26px rgba(16, 24, 40, .07); color: var(--ink); text-decoration: none !important; overflow: hidden; transition: transform .15s, box-shadow .15s, border-color .15s; }
.home-card::after { content: ""; position: absolute; right: -40px; top: -40px; width: 150px; height: 150px; border-radius: 50%; background: var(--hc-tint); opacity: .7; }
.home-card:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(16, 24, 40, .05), 0 18px 36px rgba(16, 24, 40, .12); border-color: var(--hc); }
.home-card:active { transform: scale(.985); }
.hc-inq { --hc: #0b84d8; --hc-tint: #e7f3fc; --hc-sh: rgba(11, 132, 216, .32); }
.hc-quo { --hc: #6e45e2; --hc-tint: #f1ecfe; --hc-sh: rgba(110, 69, 226, .32); }
.hc-ord { --hc: #0f9d58; --hc-tint: #e3f6ec; --hc-sh: rgba(15, 157, 88, .3); }
.hc-ic { position: relative; z-index: 1; width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center; color: #fff; background: var(--hc); box-shadow: 0 8px 18px var(--hc-sh); }
.hc-body { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.hc-body b { font-size: 24px; letter-spacing: -.3px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hc-body small { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.hc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.hc-chips .chip { font-size: 11.5px; }
.hc-go { position: absolute; right: 18px; bottom: 18px; z-index: 1; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--hc-tint); color: var(--hc); transition: transform .15s; }
.home-card:hover .hc-go { transform: translateX(3px); }
.home-card.is-soon .hc-ic { filter: saturate(.75); }
em.soon { font-style: normal; font-size: 10.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; padding: 2px 8px; border-radius: 20px; background: #fff4e0; color: #9a5b00; vertical-align: 2px; }
#sidebar nav a em.soon { margin-left: auto; background: rgba(255, 196, 77, .16); color: #ffcf70; font-size: 9.5px; padding: 1px 6px; }
.soon-card { max-width: 560px; margin: 30px auto; text-align: center; padding: 40px 28px 30px; }
.soon-ic { width: 92px; height: 92px; margin: 0 auto 16px; border-radius: 26px; display: grid; place-items: center; background: #e3f6ec; color: #0f9d58; }
.soon-card h2 { font-size: 24px; margin-bottom: 8px; }
.soon-card p { margin: 0 0 8px; }
.soon-card .btn-row { margin-top: 18px; }

@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; gap: 12px; }
  .home-card { flex-direction: row; align-items: center; min-height: 0; padding: 18px 16px; gap: 14px; border-radius: 16px; }
  .hc-ic { width: 54px; height: 54px; border-radius: 15px; flex: none; }
  .hc-body { padding-right: 34px; }
  .hc-body b { font-size: 20px; }
  .hc-go { width: 32px; height: 32px; right: 12px; bottom: auto; top: 50%; margin-top: -16px; }
  .home-card::after { width: 110px; height: 110px; right: -30px; top: -30px; }
}
@media (max-width: 700px) {
  .home-hello h1 { font-size: 21px; }
  .home-hello p { margin-bottom: 14px; font-size: 13px; }
  .hc-body small { font-size: 12.5px; }
  .st-remark { max-width: 160px; }
}

/* ---------- Settings > Database ---------- */
.db-card h3 { display: flex; align-items: center; gap: 8px; }
.db-now { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; margin-bottom: 10px; }
.db-now b { display: block; font-size: 14px; }
.db-now small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.db-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; color: #fff; }
.db-lite { background: #0b84d8; }
.db-my { background: #0e7470; }
.db-counts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.db-counts > div { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; }
.db-counts b { display: block; font-size: 18px; line-height: 1.2; }
.db-counts small { color: var(--muted); font-size: 11.5px; }
.db-result { margin: 4px 0 6px; }
.db-result .notice { margin: 8px 0 0; }
.db-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: 1; }
.db-help { margin-top: 12px; font-size: 13px; }
.db-help summary { cursor: pointer; font-weight: 600; color: var(--pri-d); }
.db-help ol { margin: 8px 0 0; padding-left: 20px; color: #3c4a5c; }
.db-help li { margin-bottom: 4px; }
@media (max-width: 700px) {
  .db-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .db-actions { justify-content: stretch; }
  .db-actions .btn { flex: 1 1 100%; justify-content: center; }
}
.q-ref { display: flex; align-items: center; gap: 3px; margin-top: 5px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.qc-meta .q-ref { margin-top: 0; }
.qc-meta .q-ref { white-space: normal; line-height: 1.3; }

/* =====================================================================
   No sideways scrolling anywhere
   ===================================================================== */
/* lists: the status column and the quotation reference never make a table wider than the page */
.data-table .st-remark { width: 0; min-width: 100%; max-width: none; }
.data-table .q-ref { white-space: normal; line-height: 1.3; }
.data-table select.status-sel { width: 100%; min-width: 118px; max-width: 160px; }
@media (min-width: 701px) and (max-width: 1280px) {
  .dash-list .data-table td, .dash-list .data-table th { padding-left: 8px; padding-right: 8px; }
  .dash-list .data-table .btn-sm { padding: 0 9px; }
}
/* quotation editor: the five steps always fit the left pane */
.stepper { overflow-x: hidden; }
.step { flex: 0 1 auto; min-width: 0; padding: 7px 8px; gap: 6px; }
.step-l { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.step.active { flex-shrink: 0; }

/* phones: status tiles in a neat grid instead of a sideways strip */
@media (max-width: 700px) {
  .tiles-wrap { margin: 0 0 10px; }
  .status-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; overflow: visible; margin: 0; padding: 0; }
  .stile { width: auto; min-width: 0; max-width: none; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 9px; border-radius: 11px; box-shadow: none; }
  .stile-ic { display: none; }
  .stile-txt { width: 100%; }
  .stile-txt b { font-size: 17px; }
  .stile-txt small { font-size: 10.5px; line-height: 1.2; white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.4em; }
  .stile.on { box-shadow: 0 0 0 2px rgba(11, 132, 216, .25); }
  /* report period chips wrap onto lines */
  .preset-bar { flex-wrap: wrap; overflow: visible; margin: 0 0 10px; padding: 0; }
}
@media (min-width: 1101px) {
  .stepper { gap: 2px; padding: 10px 8px; }
  .step { padding: 6px 7px; gap: 5px; font-size: 13px; letter-spacing: -.1px; }
  .step-n { width: 22px; height: 22px; font-size: 11.5px; }
}
