:root {
  --bg: #f3f6fb;
  --panel: rgba(255,255,255,.86);
  --panel-solid: #ffffff;
  --text: #102033;
  --muted: #667085;
  --line: #e5e9f0;
  --brand: #0f766e;
  --brand-2: #2563eb;
  --brand-soft: #e6f5f3;
  --warning: #d97706;
  --danger: #dc2626;
  --success: #059669;
  --shadow: 0 14px 40px rgba(15, 23, 42, .08);
  --radius: 18px;
  --radius-sm: 12px;
  --nav-width: 272px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at top left, rgba(37,99,235,.10), transparent 30%), radial-gradient(circle at top right, rgba(15,118,110,.13), transparent 28%), var(--bg);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--nav-width); padding: 22px 18px; background: rgba(12, 20, 34, .96); color: white; z-index: 20; display: flex; flex-direction: column; gap: 18px; }
.brand-card { display: flex; align-items: center; gap: 12px; padding: 10px 10px 18px; border-bottom: 1px solid rgba(255,255,255,.10); }
.logo-mark { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, #10b981, #2563eb); font-weight: 900; box-shadow: 0 10px 25px rgba(16,185,129,.30); }
.brand-title { font-weight: 850; letter-spacing: -.02em; }
.brand-subtitle { color: rgba(255,255,255,.62); font-size: 13px; margin-top: 2px; }
.nav-section-label { color: rgba(255,255,255,.45); font-size: 12px; padding: 4px 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.nav-btn { width: 100%; border: 0; color: rgba(255,255,255,.72); background: transparent; display: flex; align-items: center; gap: 12px; padding: 12px 13px; border-radius: 13px; text-align: left; font-weight: 750; transition: .18s; }
.nav-btn:hover, .nav-btn.active { color: #fff; background: rgba(255,255,255,.10); }
.nav-btn svg { width: 19px; height: 19px; opacity: .9; }
.sidebar-footer { margin-top: auto; padding: 14px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.10); border-radius: 18px; color: rgba(255,255,255,.72); font-size: 13px; }
.main { margin-left: var(--nav-width); width: calc(100% - var(--nav-width)); padding: 22px 26px 42px; }
.topbar { position: sticky; top: 0; z-index: 12; margin: -22px -26px 22px; padding: 16px 26px; backdrop-filter: blur(16px); background: rgba(243,246,251,.78); border-bottom: 1px solid rgba(229,233,240,.8); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-heading h1 { margin: 0; font-size: clamp(23px, 2vw, 32px); letter-spacing: -.04em; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.search { min-width: 280px; max-width: 420px; width: 32vw; position: relative; }
.search input { width: 100%; padding-left: 42px; }
.search .icon { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: #98a2b3; }
.card { background: var(--panel); border: 1px solid rgba(229,233,240,.9); box-shadow: var(--shadow); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title h2, .card-title h3 { margin: 0; font-size: 17px; letter-spacing: -.015em; }
.card-title p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: linear-gradient(180deg, #ffffff, #f8fbff); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: 0 12px 30px rgba(15, 23, 42, .06); }
.kpi .label { color: var(--muted); font-weight: 750; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { font-size: 28px; font-weight: 900; letter-spacing: -.04em; margin-top: 7px; }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: minmax(300px, .85fr) minmax(420px, 1.25fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(180px,1fr)); gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px; align-items: end; }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }
label { font-size: 12px; color: var(--muted); font-weight: 800; display: block; margin-bottom: 6px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 13px; padding: 12px 13px; outline: none; transition: .16s; }
input:focus, select:focus, textarea:focus { border-color: rgba(15,118,110,.60); box-shadow: 0 0 0 4px rgba(15,118,110,.10); }
textarea { resize: vertical; min-height: 120px; }
.btn { border: 0; border-radius: 13px; padding: 12px 15px; font-weight: 850; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: .16s; min-height: 44px; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--brand); color: white; }
.btn-blue { background: var(--brand-2); color: white; }
.btn-soft { background: #eef2f7; color: #344054; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-warning { background: #fff7ed; color: #9a3412; }
.btn-success { background: #dcfce7; color: #166534; }
.btn-sm { padding: 8px 10px; min-height: 35px; border-radius: 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 850; padding: 8px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: currentColor; box-shadow: 0 0 0 4px rgba(15,118,110,.12); }
.status-pill.offline { background: #fff7ed; color: #c2410c; }
.badge { display: inline-flex; align-items: center; justify-content: center; padding: 5px 9px; font-size: 12px; font-weight: 850; border-radius: 999px; white-space: nowrap; }
.badge-pending { color: #92400e; background: #fef3c7; }
.badge-delivered { color: #166534; background: #dcfce7; }
.badge-user { color: #344054; background: #eef2f7; }
.badge-danger { color: #991b1b; background: #fee2e2; }
.badge-success { color: #166534; background: #dcfce7; }
.badge-blue { color: #1d4ed8; background: #dbeafe; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid #edf1f7; vertical-align: top; font-size: 14px; }
th { color: #667085; background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 900; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfdff; }
.table-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.item-line { margin: 3px 0; font-size: 13px; color: #344054; }
.empty-state { padding: 26px; text-align: center; color: var(--muted); }
.screen { display: none; }
.screen.active { display: block; }
.drawer-toggle { display: none; }
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 10px; }
.toast { background: #0f172a; color: white; padding: 12px 14px; border-radius: 14px; box-shadow: var(--shadow); max-width: min(460px, calc(100vw - 36px)); font-size: 14px; }
.toast.error { background: #991b1b; }
.toast.success { background: #166534; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.50); display: none; align-items: center; justify-content: center; z-index: 80; padding: 18px; }
.modal-backdrop.show { display: flex; }
.modal { background: white; width: min(560px, 100%); border-radius: 22px; box-shadow: 0 24px 80px rgba(15,23,42,.24); padding: 20px; }
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--muted); margin: 0 0 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.phone-body { background: linear-gradient(180deg, #ecfdf5 0%, #f3f6fb 38%, #f8fafc 100%); padding-bottom: 82px; }
.mobile-shell { width: min(560px, 100%); margin: 0 auto; padding: 16px; }
.mobile-hero { background: linear-gradient(135deg, #0f766e, #1d4ed8); color: white; border-radius: 26px; padding: 20px; box-shadow: 0 18px 38px rgba(15,118,110,.20); }
.mobile-hero h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.mobile-hero p { margin: 5px 0 0; color: rgba(255,255,255,.78); }
.mobile-card { background: rgba(255,255,255,.92); border: 1px solid rgba(229,233,240,.9); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); margin-top: 14px; }
.mobile-card h2 { margin: 0 0 12px; font-size: 18px; }
.mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 14px 12px; background: rgba(255,255,255,.88); backdrop-filter: blur(18px); border-top: 1px solid var(--line); display: flex; justify-content: center; gap: 8px; }
.mobile-nav button { flex: 1; max-width: 170px; border: 0; background: transparent; color: #667085; border-radius: 16px; padding: 9px 8px; font-weight: 850; font-size: 12px; }
.mobile-nav button.active { color: var(--brand); background: var(--brand-soft); }
.cart-item { border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: white; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-top: 8px; }
.order-card { border: 1px solid var(--line); border-radius: 18px; padding: 14px; background: white; margin-top: 10px; }
.order-card .head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) { :root { --nav-width: 0px; } .sidebar { transform: translateX(-105%); transition: .22s; width: 285px; } body.nav-open .sidebar { transform: translateX(0); } .drawer-toggle { display: inline-flex; } .main { margin-left: 0; width: 100%; padding: 16px; } .topbar { margin: -16px -16px 16px; padding: 12px 16px; align-items: flex-start; flex-direction: column; } .top-actions { width: 100%; justify-content: stretch; } .search { width: 100%; min-width: 0; max-width: none; } .kpi-grid { grid-template-columns: 1fr 1fr; } .form-grid { grid-template-columns: 1fr; } .col-2, .col-3, .col-4, .col-5, .col-6, .col-8, .col-12 { grid-column: auto; } }
@media (max-width: 620px) { .kpi-grid { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr; } .card { padding: 14px; border-radius: 16px; } .card-title { align-items: flex-start; flex-direction: column; } .top-actions .btn, .top-actions .status-pill { width: 100%; } .modal-actions { flex-direction: column-reverse; } }

/* Salesman history compact expandable cards */
.history-order-card { border: 1px solid var(--line); border-radius: 16px; background: white; margin-top: 10px; overflow: hidden; }
.history-order-card summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.history-order-card summary::-webkit-details-marker { display: none; }
.history-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.history-main b { font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 58vw; }
.history-main span { color: var(--muted); font-size: 12px; }
.history-status { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.history-status .chev { width: 22px; height: 22px; border-radius: 999px; background: #f1f5f9; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-weight: 900; transition: transform .18s ease; }
.history-order-card[open] .history-status .chev { transform: rotate(180deg); }
.history-details { border-top: 1px solid var(--line); padding: 10px 14px 13px; background: #fbfdff; }
.history-details .item-line { padding: 4px 0; font-size: 13px; color: #334155; }
.history-total { margin-top: 8px; text-align: right; font-weight: 900; color: var(--ink); }


/* v11 party search in salesman order screen */
#smPartySearch { padding-right: 38px; }
#smPartySearch::placeholder { color: #98a2b3; }

/* v15 target setter cleanup */
.target-help-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap}
.target-note-pill{background:#ecfdf5;color:#0f6e56;border:1px solid #bbf7d0;border-radius:999px;padding:7px 12px;font-size:12px;font-weight:800}
.target-choice-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.target-choice-box{border:1px solid #dbe3ee;border-radius:16px;padding:16px;background:#fff;box-shadow:0 10px 24px rgba(15,23,42,.04)}
.target-category-box{background:linear-gradient(180deg,#ffffff,#f7fffc)}
.target-product-box{background:linear-gradient(180deg,#ffffff,#fffaf3)}
.target-choice-title{display:flex;gap:10px;align-items:center;margin-bottom:14px;padding-bottom:12px;border-bottom:1px solid #eef2f7}
.target-choice-title span{width:30px;height:30px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:#0f6e56;color:#fff;font-weight:900}
.target-product-box .target-choice-title span{background:#d85a30}
.target-choice-title b{display:block;font-size:15px;color:#0f172a}
.target-choice-title small{display:block;color:#64748b;font-size:12px;margin-top:2px}
@media(max-width:980px){.target-choice-grid{grid-template-columns:1fr}}

/* v17 salesman party selector: tap shows full party list, typing filters */
.party-combo-wrap { position: relative; }
.party-suggestions { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 45; max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 45px rgba(15,23,42,.16); padding: 6px; }
.party-suggestion-item { width: 100%; border: 0; background: #fff; text-align: left; padding: 11px 12px; border-radius: 12px; font-weight: 800; color: var(--ink); cursor: pointer; }
.party-suggestion-item:hover, .party-suggestion-item:focus { background: var(--brand-soft); color: var(--brand); outline: none; }
.party-suggestion-empty { padding: 14px; color: var(--muted); text-align: center; font-size: 13px; }

/* v18 product smart search in salesman order screen */
.product-combo-wrap { position: relative; }
.product-suggestions { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 44; max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 45px rgba(15,23,42,.16); padding: 6px; }
.product-suggestion-item { width: 100%; border: 0; background: #fff; text-align: left; padding: 11px 12px; border-radius: 12px; font-weight: 800; color: var(--ink); cursor: pointer; display:flex; justify-content:space-between; gap:10px; align-items:center; }
.product-suggestion-item:hover, .product-suggestion-item:focus { background: var(--brand-soft); color: var(--brand); outline: none; }
.product-suggestion-meta { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.product-suggestion-empty { padding: 14px; color: var(--muted); text-align: center; font-size: 13px; }

.filter-summary { min-height: 44px; display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; font-size: 13px; font-weight: 800; color: var(--muted); }
.compact-filter label { margin-bottom: 5px; }
.compact-order-cell { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 4px 0; }
.order-compact { font-size: 13px; color: #334155; line-height: 1.7; }
.order-compact span:not(.badge) { color: var(--muted); }
.order-expanded { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; }

/* v27 salesman estimated challan and WhatsApp actions */
.history-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.history-actions .btn { flex: 1 1 135px; }

.unit-mini{padding:8px 10px;border:1px solid var(--border);border-radius:12px;background:#f8fafc;font-weight:900;color:#0f172a;min-width:92px}
