* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.45;
}

/* Topbar */
.topbar {
  background: #0f172a;
  color: #f8fafc;
  border-bottom: 1px solid #1e293b;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-pill {
  font-size: 11px;
  font-weight: 600;
  background: #1e293b;
  color: #94a3b8;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #334155;
}

.brand-sub {
  font-size: 12px;
  color: #94a3b8;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.meta-chip {
  font-size: 12px;
  background: #1e293b;
  color: #cbd5e1;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #450a0a;
  color: #fecaca;
  border: 1px solid #dc2626;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.alert-chip:hover {
  background: #7f1d1d;
}

.alert-chip.ok {
  background: #064e3b;
  color: #a7f3d0;
  border-color: #059669;
}

.alert-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
}

.alert-chip.ok .dot {
  background: #10b981;
}

/* Main container */
.container {
  max-width: 1320px;
  margin: 20px auto 48px auto;
  padding: 0 24px;
}

/* KPI Strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.kpi-foot {
  font-size: 12px;
  color: #64748b;
}

/* Tabs */
.tabs-bar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid #cbd5e1;
  margin-bottom: 20px;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  text-decoration: none;
  color: #475569;
  font-weight: 600;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s ease;
}

.tab-link:hover {
  color: #0f172a;
  background: #e2e8f0;
  border-radius: 6px 6px 0 0;
}

.tab-link.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: #ffffff;
  border-radius: 6px 6px 0 0;
}

.tab-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #334155;
}

.tab-badge.warn {
  background: #fee2e2;
  color: #b91c1c;
}

.tab-badge.ok {
  background: #dcfce7;
  color: #15803d;
}

/* Panels & Layouts */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 390px;
  gap: 20px;
  align-items: start;
}

.khata-layout {
  display: grid;
  grid-template-columns: 1fr 370px;
  gap: 20px;
  align-items: start;
}

.panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.panel-desc {
  margin: 3px 0 0 0;
  font-size: 12px;
  color: #64748b;
}

.search-box input {
  width: 240px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
}

/* Category Pills */
.category-pills {
  padding: 12px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cat-pill {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cat-pill.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.r {
  text-align: right !important;
}

.c {
  text-align: center !important;
}

.sku-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #64748b;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 6px;
}

.prod-name {
  font-weight: 600;
  color: #0f172a;
}

.prod-cat {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.hsn-badge {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #334155;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

.gst-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

/* Stock & Status Pills */
.stock-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.stock-pill.in {
  background: #dcfce7;
  color: #15803d;
}

.stock-pill.low {
  background: #fef3c7;
  color: #b45309;
}

.stock-pill.out {
  background: #fee2e2;
  color: #b91c1c;
}

.status-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-pill.completed {
  background: #dcfce7;
  color: #15803d;
}

.status-pill.pending {
  background: #fef3c7;
  color: #b45309;
}

.status-pill.cancelled {
  background: #fee2e2;
  color: #b91c1c;
}

/* Qty Stepper */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.qty-btn {
  border: none;
  background: #f8fafc;
  color: #334155;
  width: 28px;
  height: 28px;
  font-weight: 700;
  cursor: pointer;
}

.qty-btn:hover {
  background: #e2e8f0;
}

.qty-stepper input[type=number] {
  width: 44px;
  height: 28px;
  border: none;
  border-left: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  -moz-appearance: textfield;
}

/* POS Drawer & Forms */
.drawer-body {
  padding: 18px 20px;
}

.form-group {
  margin-bottom: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 5px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: #0f172a;
}

.promo-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.promo-chip {
  font-size: 11px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f1f5f9;
  color: #334155;
  border: 1px dashed #94a3b8;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.promo-chip:hover {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1d4ed8;
}

.field-hint {
  font-size: 12px;
  margin-top: 4px;
}

.field-hint.ok {
  color: #15803d;
}

.field-hint.err {
  color: #b91c1c;
}

/* Cart Preview Box */
.cart-preview-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.cart-preview-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  margin-bottom: 8px;
}

.cart-items-empty {
  font-size: 12px;
  color: #64748b;
  padding: 8px 0;
}

.cart-mini-item {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px dashed #e2e8f0;
}

.cart-totals {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #cbd5e1;
}

.cart-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #475569;
  margin-bottom: 5px;
}

.cart-row.discount-row {
  color: #15803d;
}

.cart-row.grand-row {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #cbd5e1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #0f172a;
  color: #ffffff;
}

.btn-secondary:hover {
  background: #1e293b;
}

.btn-ghost {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

.btn-ghost:hover {
  background: #e2e8f0;
}

.btn-danger-outline {
  background: #fff;
  color: #dc2626;
  border-color: #fca5a5;
  padding: 4px 9px;
  font-size: 12px;
}

.btn-danger-outline:hover {
  background: #fef2f2;
}

.btn-link {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 5px;
  text-decoration: none;
  font-weight: 600;
}

.btn-link:hover {
  background: #dbeafe;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* Filter Bar */
.filter-bar {
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}

.filter-item label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 4px;
}

.filter-item input,
.filter-item select {
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

/* Messages */
#msg,
#orders-action-msg,
#khata-msg {
  margin-top: 12px;
  border-radius: 6px;
  font-size: 13px;
}

#orders-action-msg,
#khata-msg {
  margin: 12px 20px;
}

.ok {
  padding: 10px 14px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #14532d;
}

.err {
  padding: 10px 14px;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #7f1d1d;
}

/* Settlements Feed */
.divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 18px 0;
}

.sub-heading {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin: 0 0 10px 0;
}

.settlements-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settlement-card {
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
}

.settlement-card-top {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: #0f172a;
}

.settlement-card-sub {
  color: #64748b;
  margin-top: 3px;
}

@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .pos-layout,
  .khata-layout {
    grid-template-columns: 1fr;
  }
}
