:root {
  --app-bg: #f4f7f9;
  --sidebar: #19324a;
  --sidebar-active: #2f80ed;
  --ink: #17212b;
  --muted: #6b7785;
  --line: #dce3ea;
  --panel: #ffffff;
  --success: #2e7d59;
  --warning: #a66a00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 440px) 1fr;
  background:
    linear-gradient(90deg, rgba(18, 34, 48, 0.92), rgba(18, 34, 48, 0.42)),
    url("./assets/kulfi-cart.jpeg") center/cover;
}

.login-panel {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
}

.login-copy {
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: end;
  padding: 56px;
}

.brand-mark {
  width: 112px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #ffffff;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 43, 0.1);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--sidebar);
  color: #ffffff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
}

.sidebar-brand .brand-mark {
  width: 92px;
  height: 46px;
  background: #ffffff;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-link-app {
  width: 100%;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
}

.nav-parent {
  justify-content: flex-start;
}

.nav-parent .nav-chevron {
  margin-left: auto;
  font-size: 0.85rem;
  transition: transform 0.16s ease;
}

.nav-group.open .nav-chevron {
  transform: rotate(180deg);
}

.nav-link-app.active-parent {
  background: rgba(47, 128, 237, 0.32);
  color: #ffffff;
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 4px 16px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.nav-link-app.nav-child {
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.94rem;
}

.nav-link-app.nav-child i {
  font-size: 0.55rem;
}

.nav-link-app:hover,
.nav-link-app.active {
  background: var(--sidebar-active);
  color: #ffffff;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 68px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.city-selector {
  min-width: 160px;
}

.content {
  padding: 28px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel-pad {
  padding: 18px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stat-card i {
  color: var(--sidebar-active);
}

.table-wrap {
  overflow-x: auto;
}

.table {
  margin-bottom: 0;
}

.table th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  vertical-align: middle;
  white-space: nowrap;
}

.action-cell {
  width: 112px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.form-grid .wide {
  grid-column: span 2;
}

.sales-collection-row {
  grid-column-start: 1;
}

.stock-entry-table .stock-qty {
  max-width: 180px;
}

.sales-entry-table .sales-count {
  width: 96px;
}

.sales-summary {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}

.chart-frame {
  height: 320px;
  min-height: 260px;
}

.review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.9fr);
  gap: 20px;
  align-items: start;
}

.review-total-line {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 5px 0;
}

.factory-bill-table th {
  background: #d7d7d7;
  color: #111111;
  font-size: 0.95rem;
  text-transform: none;
}

.factory-bill-table .balance-cell {
  background: #fff200;
  color: #111111;
  font-size: 1.2rem;
}

.factory-bill-print-title {
  margin-bottom: 14px;
}

.factory-bill-print-title h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.factory-bill-print-title div {
  color: var(--muted);
  font-size: 0.9rem;
}

.bulk-invoice {
  max-width: 860px;
  margin: 0 auto 24px;
}

.bulk-invoice-header {
  align-items: flex-start;
  border-bottom: 2px solid #111827;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding-bottom: 16px;
}

.bulk-invoice-header h2 {
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.bulk-invoice-meta {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.bulk-invoice-meta div,
.bulk-invoice-totals div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bulk-invoice-meta span,
.bulk-invoice-totals span,
.bulk-invoice-footer {
  color: var(--muted);
  font-size: 0.82rem;
}

.bulk-invoice-totals {
  margin-left: auto;
  max-width: 340px;
}

.bulk-invoice-totals div {
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-direction: row;
  justify-content: space-between;
  padding: 8px 0;
}

.bulk-invoice-grand {
  border-bottom: 2px solid #111827 !important;
  border-top: 2px solid #111827;
  font-size: 1.05rem;
}

.bulk-invoice-footer {
  border-top: 1px solid var(--border);
  margin-top: 28px;
  padding-top: 12px;
  text-align: right;
}

.salary-date-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.profit-loss-table {
  max-width: 860px;
}

.profit-loss-table .report-section th {
  background: #e9eef4;
  color: #111111;
  text-transform: uppercase;
  letter-spacing: 0;
}

.profit-loss-table .report-total th,
.profit-loss-table .net-row th {
  background: #f6f8fa;
}

.profit-loss-table .net-row th {
  font-size: 1.05rem;
}

.daily-sales-summary-table th,
.daily-sales-summary-table td {
  border: 1px solid #d7dde4;
  min-width: 124px;
  padding: 8px 10px;
}

.daily-sales-summary-table {
  border-collapse: collapse;
}

.daily-sales-summary-table thead th,
.daily-sales-summary-table tfoot th {
  background: #f6f8fa;
}

.summary-footer {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 18px;
}

.summary-footer div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.audit-history-table th,
.audit-history-table td {
  white-space: normal;
}

.badge-active {
  background: rgba(46, 125, 89, 0.12);
  color: var(--success);
}

.badge-inactive {
  background: rgba(166, 106, 0, 0.12);
  color: var(--warning);
}

.alert-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  width: min(420px, calc(100vw - 32px));
}

.mobile-menu {
  display: none;
}

@media (max-width: 980px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-copy {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .sidebar.open {
    display: flex;
    position: fixed;
    z-index: 1200;
    inset: 0 auto 0 0;
    width: 280px;
    box-shadow: 0 0 0 100vw rgba(0, 0, 0, 0.42);
  }

  .mobile-menu {
    display: inline-grid;
  }

  .topbar {
    padding: 0 16px;
  }

  .content {
    padding: 18px;
  }

  .stat-grid,
  .form-grid,
  .review-grid,
  .summary-footer {
    grid-template-columns: 1fr;
  }

  .form-grid .wide {
    grid-column: span 1;
  }

  .sales-collection-row {
    grid-column-start: auto;
  }
}

@media (max-width: 560px) {
  .login-panel {
    padding: 28px 20px;
  }

  .section-header {
    flex-direction: column;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }

  body {
    background: #ffffff;
  }

  .sidebar,
  .topbar,
  .no-print,
  .alert-host {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .content {
    padding: 0;
  }

  .print-area {
    width: 100%;
  }

  .panel {
    border: 0;
    box-shadow: none;
  }

  .table-wrap {
    overflow: visible;
  }

  .factory-bill-report-content {
    page-break-inside: auto;
  }

  .factory-bill-table {
    width: 100%;
    font-size: 10.5pt;
    page-break-inside: auto;
  }

  .factory-bill-table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .factory-bill-table thead {
    display: table-header-group;
  }

  .factory-bill-table tfoot {
    display: table-footer-group;
  }

  .factory-bill-print-title {
    display: block;
  }

  body.print-bulk-invoice .content > :not(.bulk-invoice-print-area) {
    display: none !important;
  }

  body.print-bulk-invoice .bulk-invoice {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  body.print-bulk-invoice .bulk-invoice-meta {
    grid-template-columns: repeat(4, 1fr);
  }
}
