/* Business Manager Pro — Frontend CSS */
.bmp-root *, .bmp-root *::before, .bmp-root *::after { box-sizing: border-box; margin: 0; padding: 0; }

.bmp-root {
  font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #F3F4F8;
  color: #2D3748;
  min-height: 60vh;
  padding: 16px 0;
  --purple: #6C63FF; --purple-light: #EDE9FF; --purple-dark: #5A52D5;
  --green: #25D366;  --green-light: #E9F7EF;  --green-dark: #128C7E;
  --blue: #2196F3;   --blue-light: #E3F2FD;
  --orange: #FF9800; --orange-light: #FFF3E0;
  --red: #F44336;    --red-light: #FFEBEE;
  --teal: #00BCD4;   --teal-light: #E0F7FA;
  --bg: #F3F4F8; --card: #FFFFFF;
  --text: #2D3748;   --text-light: #718096;
  --border: #E2E8F0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

/* Spinner */
.bmp-spinner {
  width: 36px; height: 36px; border: 3px solid #E2E8F0;
  border-top-color: #6C63FF; border-radius: 50%;
  animation: bmp-spin 0.8s linear infinite; margin: 0 auto;
}
@keyframes bmp-spin { to { transform: rotate(360deg); } }

/* App wrapper */
.bmp-app { max-width: 1000px; margin: 0 auto; padding: 0 8px; }

/* Header */
.bmp-header { border-radius: 16px; padding: 20px 24px 16px; color: white; margin-bottom: 18px; transition: background 0.4s; }
.bmp-header.mode-dashboard { background: linear-gradient(135deg,#1a1a2e,#0f3460); box-shadow: 0 6px 20px rgba(15,52,96,0.4); }
.bmp-header.mode-sell      { background: linear-gradient(135deg,#25D366,#128C7E); box-shadow: 0 6px 20px rgba(37,211,102,0.3); }
.bmp-header.mode-purchase  { background: linear-gradient(135deg,#6C63FF,#9B59B6); box-shadow: 0 6px 20px rgba(108,99,255,0.3); }
.bmp-header.mode-parties  { background: linear-gradient(135deg,#11998e,#38ef7d); box-shadow: 0 6px 20px rgba(17,153,142,0.3); }
.bmp-header.mode-parties  .bmp-tab.active { color: #11998e; }
.bmp-header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.bmp-header-top h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.bmp-header-top .bmp-subtitle { font-size: 12px; opacity: 0.8; margin-top: 2px; }

/* Tabs */
.bmp-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.bmp-tab { padding: 7px 14px; border-radius: 30px; border: 2px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.1); color: white; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.bmp-tab:hover { background: rgba(255,255,255,0.25); }
.bmp-tab.active { background: white; border-color: white; }
.bmp-header.mode-dashboard .bmp-tab.active { color: #0f3460; }
.bmp-header.mode-sell      .bmp-tab.active { color: var(--green-dark); }
.bmp-header.mode-purchase  .bmp-tab.active { color: var(--purple); }
.bmp-header.mode-parties   { background: linear-gradient(135deg,#11998e,#38ef7d); box-shadow: 0 6px 20px rgba(17,153,142,0.3); }
.bmp-header.mode-parties   .bmp-tab.active { color: #11998e; }
.bmp-header.mode-items     .bmp-tab.active { color: var(--orange); }

/* Cards */
.bmp-card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.bmp-card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.bmp-card-title { font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; }
.bmp-card-body { padding: 16px 18px; }
.bmp-card-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--text-light); }

/* Toolbar */
.bmp-toolbar { background: var(--card); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 14px; }
.bmp-toolbar-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-light); margin-bottom: 8px; }
.bmp-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.bmp-divider { margin: 14px 0; border: none; border-top: 1px solid var(--border); }
.bmp-field { display: flex; flex-direction: column; flex: 1; min-width: 120px; }
.bmp-field label { font-size: 10px; font-weight: 700; color: var(--text-light); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.bmp-field input, .bmp-field select { padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; color: var(--text); background: var(--card); transition: border-color 0.2s; width: 100%; }
.bmp-field input:focus, .bmp-field select:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-light); }
.bmp-field.bmp-sm { flex: 0 0 100px; }
.bmp-field.bmp-sm input { text-align: right; }

/* Buttons */
.bmp-btn { padding: 9px 16px; border: none; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 5px; transition: all 0.2s; white-space: nowrap; flex-shrink: 0; }
.bmp-btn:hover { transform: translateY(-1px); }
.bmp-btn.bmp-purple  { background: var(--purple); color: white; } .bmp-btn.bmp-purple:hover  { background: var(--purple-dark); }
.bmp-btn.bmp-green   { background: var(--green);  color: white; } .bmp-btn.bmp-green:hover   { background: #1EB85C; }
.bmp-btn.bmp-blue    { background: var(--blue-light);   color: var(--blue);   } .bmp-btn.bmp-blue:hover   { background: #BBDEFB; }
.bmp-btn.bmp-orange  { background: var(--orange-light); color: var(--orange); } .bmp-btn.bmp-orange:hover { background: #FFE0B2; }
.bmp-btn.bmp-red     { background: var(--red-light);    color: var(--red);    } .bmp-btn.bmp-red:hover    { background: #FFCDD2; }
.bmp-btn.bmp-teal    { background: var(--teal-light);   color: var(--teal);   } .bmp-btn.bmp-teal:hover   { background: #B2EBF2; }
.bmp-btn.bmp-gray    { background: var(--border);       color: var(--text);   }
.bmp-btn.bmp-sm { padding: 5px 10px; font-size: 11px; border-radius: 6px; }
.bmp-file-input { display: none; }

/* Autocomplete */
.bmp-ac-wrap { position: relative; flex: 1; min-width: 120px; }
.bmp-ac-list { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1.5px solid var(--purple); border-top: none; border-radius: 0 0 8px 8px; max-height: 200px; overflow-y: auto; z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: none; }
.bmp-ac-list.show { display: block; }
.bmp-ac-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.bmp-ac-item:last-child { border-bottom: none; }
.bmp-ac-item:hover, .bmp-ac-item.active { background: var(--purple-light); }
.bmp-ac-name { font-weight: 500; color: var(--text); font-size: 13px; }
.bmp-ac-sub  { font-size: 11px; color: var(--text-light); margin-top: 1px; }

/* Collapsible */
.bmp-coll { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.bmp-coll-head { padding: 14px 18px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; user-select: none; transition: background 0.2s; }
.bmp-coll-head.purple { background: var(--purple-light); } .bmp-coll-head.purple:hover { background: #E0DCFF; }
.bmp-coll-head.green  { background: var(--green-light); }  .bmp-coll-head.green:hover  { background: #d0f0de; }
.bmp-coll-head.orange { background: var(--orange-light); } .bmp-coll-head.orange:hover { background: #FFE0B2; }
.bmp-coll-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.bmp-coll-title.purple { color: var(--purple); } .bmp-coll-title.green { color: var(--green-dark); } .bmp-coll-title.orange { color: var(--orange); }
.bmp-coll-icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; transition: transform 0.25s; }
.bmp-coll-icon svg { display: block; }
.bmp-coll-icon.open { transform: rotate(180deg); }
.bmp-coll-content { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; }
.bmp-coll-content.open { max-height: 3000px; }
.bmp-coll-body { padding: 18px; }

/* Order Cards */
.bmp-order-card { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 12px; border: 2px solid transparent; transition: box-shadow 0.2s; }
.bmp-order-card:hover { box-shadow: var(--shadow-md); }
.bmp-order-card.paid    { border-color: var(--green); }
.bmp-order-card.partial { border-color: var(--orange); }
.bmp-order-card.unpaid  { border-color: var(--red); }
.bmp-order-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.bmp-order-info h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.bmp-order-meta { font-size: 11px; color: var(--text-light); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; }
.bmp-order-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.bmp-items-compact { background: var(--bg); padding: 9px 12px; border-radius: 8px; margin: 8px 0; }
.bmp-items-toggle-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.bmp-items-toggle { font-size: 11px; color: var(--purple); font-weight: 600; }
.bmp-items-list { max-height: 0; overflow: hidden; transition: max-height 0.3s; }
.bmp-items-list.open { max-height: 600px; margin-top: 8px; }
.bmp-item-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; border-bottom: 1px solid var(--border); }
.bmp-item-row:last-child { border-bottom: none; }
.bmp-order-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; border-top: 1px solid var(--border); margin-top: 8px; flex-wrap: wrap; gap: 8px; }
.bmp-order-total { font-size: 15px; font-weight: 700; color: var(--green); }
.bmp-pay-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 10px; display: inline-flex; align-items: center; gap: 4px; }
.bmp-pay-badge.paid    { background: var(--green-light); color: var(--green-dark); }
.bmp-pay-badge.partial { background: var(--orange-light); color: #E65100; }
.bmp-pay-badge.unpaid  { background: var(--red-light);    color: var(--red); }
.bmp-pay-badge.bmp-sent   { background: #E3F2FD; color: #1565C0; }
.bmp-pay-badge.bmp-unsent { background: #F5F5F5; color: #757575; }

/* Party list */
.bmp-party-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg); border-radius: 8px; margin-bottom: 7px; transition: background 0.2s; }
.bmp-party-row:hover { background: #E8EAF0; }
.bmp-party-row.editing { background: var(--green-light); flex-wrap: wrap; gap: 8px; }
.bmp-party-info h4 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.bmp-party-info p  { font-size: 12px; color: var(--text-light); }
.bmp-party-actions { display: flex; gap: 5px; }
.bmp-party-edit-fields { display: flex; gap: 8px; flex: 1; width: 100%; }
.bmp-party-edit-fields input { flex: 1; padding: 7px 10px; border: 1.5px solid var(--green); border-radius: 7px; font-size: 12px; font-family: inherit; color: var(--text); }

/* Items table */
.bmp-tbl { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.bmp-tbl-head { background: var(--orange-light); padding: 10px 18px; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 130px; gap: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-light); border-bottom: 2px solid var(--orange); }
.bmp-tbl-row  { padding: 12px 18px; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 130px; gap: 10px; align-items: center; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.bmp-tbl-row:last-child { border-bottom: none; }
.bmp-tbl-row:hover { background: #FAFBFD; }
.bmp-tbl-edit { background: #FFF3E0 !important; padding: 10px 18px; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 130px; gap: 10px; align-items: center; border-bottom: 1px solid var(--border); }
.bmp-tbl-edit input, .bmp-tbl-edit select { padding: 6px 9px; border: 1.5px solid var(--orange); border-radius: 6px; font-size: 12px; font-family: inherit; color: var(--text); width: 100%; }
.bmp-tbl-actions { display: flex; gap: 5px; justify-content: flex-end; }

/* Stock badges */
.bmp-stock { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.bmp-stock.ok  { background: var(--green-light);  color: var(--green-dark); }
.bmp-stock.low { background: var(--orange-light); color: #E65100; }
.bmp-stock.out { background: var(--red-light);    color: var(--red); }
.bmp-stock.neg { background: #4a0010; color: #ff6b8a; font-weight: 700; }

/* GST */
.bmp-gst-badge { display: inline-flex; align-items: center; gap: 5px; background: var(--teal-light); color: var(--teal); font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 10px; }

/* Footer / summary */
.bmp-footer { background: var(--card); border-radius: 14px; padding: 16px 20px; box-shadow: var(--shadow); margin-top: 16px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }

/* Toggle switch */
.bmp-toggle-group { display: flex; align-items: center; gap: 7px; }
.bmp-toggle-label { font-size: 12px; font-weight: 500; color: var(--text-light); }
.bmp-toggle { position: relative; width: 40px; height: 22px; }
.bmp-toggle input { opacity: 0; width: 0; height: 0; }
.bmp-slider { position: absolute; cursor: pointer; inset: 0; background: #CBD5E0; border-radius: 22px; transition: 0.3s; }
.bmp-slider:before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.bmp-toggle input:checked + .bmp-slider { background: var(--purple); }
.bmp-toggle input:checked + .bmp-slider:before { transform: translateX(18px); }

/* Dashboard */
.bmp-dash-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 14px; }
.bmp-kpi { background: var(--card); border-radius: 14px; padding: 16px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; transition: box-shadow 0.2s, transform 0.2s; }
.bmp-kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.bmp-kpi-icon  { font-size: 20px; }
.bmp-kpi-val   { font-size: 22px; font-weight: 700; line-height: 1; letter-spacing: -0.5px; }
.bmp-kpi-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-light); }
.bmp-kpi-sub   { font-size: 11px; color: var(--text-light); }
.bmp-dash-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.bmp-dlist-row { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.bmp-dlist-row:last-child { border-bottom: none; }
.bmp-dlist-row:hover { background: var(--bg); }
.bmp-d-rank { font-size: 11px; font-weight: 700; color: var(--text-light); min-width: 20px; }
.bmp-d-name { font-size: 12px; font-weight: 500; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bmp-dbar-outer { flex: 1; background: var(--bg); border-radius: 3px; height: 6px; overflow: hidden; }
.bmp-dbar-inner { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.bmp-d-val { font-size: 12px; font-weight: 700; min-width: 50px; text-align: right; }
.bmp-dalert-row { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); }
.bmp-dalert-row:last-child { border-bottom: none; }
.bmp-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.bmp-dalert-stock { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 7px; }

/* Pagination */
.bmp-pagination { background: var(--card); border-radius: 14px; padding: 12px 18px; box-shadow: var(--shadow); margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.bmp-page-info  { font-size: 12px; color: var(--text-light); }
.bmp-page-ctrl  { background: var(--card); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); margin-top: 10px; display: none; justify-content: center; gap: 5px; flex-wrap: wrap; }
.bmp-page-ctrl.show { display: flex; }

/* Search bar */
.bmp-search { background: var(--card); border-radius: 14px; padding: 12px 18px; box-shadow: var(--shadow); margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.bmp-search input { flex: 1; border: none; outline: none; font-size: 13px; font-family: inherit; color: var(--text); background: transparent; }

/* Empty state */
.bmp-empty { text-align: center; padding: 40px 20px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.bmp-empty-icon { font-size: 36px; margin-bottom: 10px; }
.bmp-empty p { color: var(--text-light); font-size: 13px; }

/* Settings */
.bmp-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.bmp-settings-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 18px 14px; background: var(--bg); border-radius: 12px; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; text-align: center; }
.bmp-settings-card:hover { border-color: var(--purple); background: var(--purple-light); }
.bmp-settings-card-icon  { font-size: 24px; }
.bmp-settings-card-label { font-size: 12px; font-weight: 600; color: var(--text); }
.bmp-settings-card-desc  { font-size: 10px; color: var(--text-light); }

/* Toast */
.bmp-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: #2D3748; color: white; padding: 9px 18px; border-radius: 8px; font-size: 12px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.2); transition: transform 0.3s; pointer-events: none; z-index: 99999; white-space: nowrap; }
.bmp-toast.show { transform: translateX(-50%) translateY(0); }

/* Modal overlay */
.bmp-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99998; display: flex; align-items: center; justify-content: center; padding: 16px; }
.bmp-modal-box { background: white; border-radius: 16px; padding: 20px; max-width: 420px; width: 100%; box-shadow: 0 20px 40px rgba(0,0,0,0.3); max-height: 90vh; overflow-y: auto; }

/* Responsive */
@media (max-width: 640px) {
  .bmp-dash-grid { grid-template-columns: repeat(2,1fr); }
  .bmp-dash-row   { grid-template-columns: 1fr; }
  .bmp-row        { flex-direction: column; }
  .bmp-field, .bmp-field.bmp-sm, .bmp-ac-wrap { flex: 1; width: 100%; min-width: 0; }
  .bmp-field.bmp-sm input { text-align: left; }
  .bmp-row .bmp-btn { width: 100%; justify-content: center; }
  .bmp-tabs { width: 100%; }
  .bmp-tab  { flex: 1; text-align: center; padding: 6px 8px; font-size: 10px; }
  .bmp-header-top { flex-direction: column; align-items: flex-start; }
  .bmp-tbl-head, .bmp-tbl-row, .bmp-tbl-edit { grid-template-columns: 1fr; gap: 6px; }
  .bmp-tbl-head { display: none; }
  .bmp-tbl-actions { justify-content: flex-start; }
  .bmp-footer { flex-direction: column; align-items: stretch; }
  .bmp-order-head { flex-direction: column; gap: 8px; }
  .bmp-order-actions { flex-direction: column; width: 100%; }
  .bmp-order-actions .bmp-btn { width: 100%; justify-content: center; }
  .bmp-party-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .bmp-party-actions { width: 100%; }
  .bmp-party-actions .bmp-btn { flex: 1; justify-content: center; }
  .bmp-party-edit-fields { flex-direction: column; }
  .bmp-settings-grid { grid-template-columns: 1fr; }
}
