:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e2ec;
  --soft: #f3f7fa;
  --panel: #ffffff;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #f59e0b;
  --danger: #dc2626;
  --ok: #15803d;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: #edf4f7;
}

body.is-loading .app-shell {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  place-items: center;
  background: rgba(237, 244, 247, 0.72);
  backdrop-filter: blur(4px);
}

.loading-overlay.active {
  display: grid;
}

.loading-card {
  min-width: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px 34px;
  background: #ffffff;
  box-shadow: 0 20px 55px rgba(15, 23, 42, 0.18);
  color: var(--ink);
  text-align: center;
  font-size: 32px;
  font-weight: 900;
}

.startup-main-loading {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 28px;
}

.startup-main-loading p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.startup-loader-card {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px 32px;
  background: #ffffff;
  box-shadow: var(--shadow);
  text-align: center;
  font-size: 30px;
  font-weight: 900;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.is-submitting,
button.is-submitting:disabled,
form.is-submitting button:not([type]),
form.is-submitting button[type="submit"],
form.is-submitting input[type="submit"] {
  background: #f59e0b;
  color: #111827;
  opacity: 1;
  cursor: wait;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}

button.is-submitting::after,
form.is-submitting button:not([type])::after,
form.is-submitting button[type="submit"]::after {
  content: "";
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-left: 8px;
  border: 2px solid rgba(17, 24, 39, 0.35);
  border-top-color: #111827;
  border-radius: 999px;
  vertical-align: -0.1em;
  animation: submit-spin 0.75s linear infinite;
}

@keyframes submit-spin {
  to {
    transform: rotate(360deg);
  }
}

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

.sidebar {
  background: #102a43;
  color: #f8fafc;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #22d3ee;
  display: grid;
  place-items: center;
  color: #0f172a;
  font-weight: 800;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: #ffffff;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p,
.user-chip p {
  margin: 2px 0 0;
  color: #bfd7ea;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  min-height: 42px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  color: #e5eef7;
  background: transparent;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  margin-top: 24px;
  display: grid;
  gap: 10px;
}

.main {
  min-width: 0;
  padding: 22px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 24px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 700;
}

.btn.secondary {
  background: #e2e8f0;
  color: #17202a;
}

.btn.warn {
  background: var(--danger);
}

.btn.ghost {
  background: transparent;
  color: #e5eef7;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn.is-submitting,
.btn.is-submitting:disabled,
form.is-submitting .btn:not([type]),
form.is-submitting .btn[type="submit"],
form.is-submitting input[type="submit"] {
  background: #f59e0b;
  color: #111827;
  opacity: 1;
  cursor: wait;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}

.grid {
  display: grid;
  gap: 14px;
}

.stats {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.compact-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 14px;
}

.compact-stats .stat {
  box-shadow: none;
  background: #f8fafc;
}

.compact-table table {
  min-width: 520px;
}

.performance-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.performance-list div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.performance-list span,
.pagination-bar {
  color: var(--muted);
  font-size: 13px;
}

.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.section-actions input {
  min-height: 40px;
}

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

.stat {
  padding: 16px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 27px;
}

.section {
  margin-top: 16px;
}

.dashboard-modules {
  margin-bottom: 18px;
}

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

.module-card {
  position: relative;
  min-height: 102px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #0f766e, #0b5f59);
  color: #ffffff;
  padding: 18px 14px;
  text-align: center;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.12);
  isolation: isolate;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.module-card::after {
  content: "";
  position: absolute;
  top: -36px;
  right: -18px;
  width: 128px;
  height: 128px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  z-index: -1;
}

.module-card strong {
  position: relative;
  z-index: 1;
  line-height: 1.2;
}

.module-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
}

.module-icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.module-card-customers {
  background: linear-gradient(135deg, #0f766e, #15803d);
}

.module-card-orders {
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
}

.module-card-deliveries {
  background: linear-gradient(135deg, #0e7490, #0f766e);
}

.module-card-trips {
  background: linear-gradient(135deg, #7c3aed, #0f766e);
}

.module-card-inventory {
  background: linear-gradient(135deg, #166534, #16a34a);
}

.module-card-billing {
  background: linear-gradient(135deg, #b45309, #dc2626);
}

.module-card-employees,
.module-card-salary {
  background: linear-gradient(135deg, #6d28d9, #a21caf);
}

.module-card-ledger {
  background: linear-gradient(135deg, #1e3a8a, #0369a1);
}

.module-card-reports {
  background: linear-gradient(135deg, #334155, #2563eb);
}

.module-card-settings {
  background: linear-gradient(135deg, #7f1d1d, #92400e);
}

.module-card:hover,
.module-card:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.18);
  outline: none;
}

.subnav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.customer-tabs-card {
  margin-bottom: 16px;
  padding: 10px;
}

.customer-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.customer-tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  background: #f8fafc;
  color: var(--ink);
  font-weight: 800;
}

.customer-tab.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.section-head h3 {
  margin: 0;
  font-size: 17px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: #f8fafc;
}

tr.highlight-row td {
  background: #fef3c7;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  font-weight: 700;
}

.pill.due {
  background: #fee2e2;
  color: #991b1b;
}

.pill.ok {
  background: #dcfce7;
  color: #166534;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.form-group-title {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
}

.form-grid .form-group-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.billing-live-search {
  padding: 14px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.checkbox-field label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.checkbox-field input {
  width: auto;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.permission-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.permission-module,
.permission-tabs label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.permission-module {
  min-height: 28px;
  font-weight: 800;
}

.permission-tabs {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding-left: 22px;
}

.permission-tabs label {
  color: var(--muted);
}

.permission-tabs label.disabled {
  opacity: 0.55;
}

.permission-grid input {
  width: auto;
}

.salary-edit-table table {
  min-width: 1320px;
}

.salary-edit-table input {
  min-width: 98px;
  min-height: 34px;
  padding: 6px 8px;
}

.salary-edit-table span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.salary-revision-actions {
  padding: 12px 0 0;
}

.salary-subnav {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #edf4f7;
  padding: 0 0 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.salary-card-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.salary-history-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  padding: 14px 14px 0;
}

.salary-summary-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.salary-detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 0;
}

.salary-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.salary-card-head span,
.salary-breakdown span,
.salary-net span,
.salary-summary-card span,
.empty-state span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.salary-card-head strong,
.salary-breakdown strong,
.salary-summary-card strong {
  overflow-wrap: anywhere;
}

.salary-net {
  text-align: right;
  min-width: 110px;
}

.salary-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  padding: 12px;
}

.salary-breakdown div {
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  background: #f8fafc;
}

.empty-state {
  padding: 14px;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.due-filter {
  padding: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
}

.due-filter-type {
  grid-column: 1;
}

.due-filter-month {
  grid-column: 2;
}

.due-filter-from {
  grid-column: 1;
}

.due-filter-to {
  grid-column: 2;
}

.due-filter-action {
  grid-column: 3;
  align-self: end;
}

.payment-due-table td {
  vertical-align: middle;
}

.full {
  grid-column: 1 / -1;
}

.danger-zone {
  display: grid;
  gap: 8px;
  margin: 0 14px 14px;
  padding: 14px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
}

.danger-zone strong {
  color: var(--danger);
}

.danger-zone span {
  color: var(--muted);
  font-size: 13px;
}

.danger-zone .btn {
  justify-self: start;
}

.inline-edit-panel {
  margin: 0 14px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.inline-edit-panel .section-head {
  background: #eef6f5;
}

.employee-edit-row > td {
  padding: 0;
  background: #eef6f5;
}

.employee-edit-row .inline-edit-panel {
  margin: 0;
  border-width: 1px 0;
  border-radius: 0;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
  background: #0b3b4a;
}

.login-panel {
  background: white;
  padding: 48px 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
}

.login-brand img {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.login-panel h1 {
  margin: 0;
  font-size: 28px;
}

.login-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.login-copy {
  margin-bottom: 20px;
}

.login-copy h2 {
  margin: 0 0 8px;
  font-size: 23px;
}

.login-copy p {
  margin: 0;
}

.login-art {
  padding: 48px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background:
    linear-gradient(90deg, rgba(8, 47, 73, 0.85), rgba(13, 148, 136, 0.62)),
    url("assets/logo.png");
  background-size: cover;
  background-position: center;
  position: relative;
}

.login-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 47, 73, 0.15), rgba(8, 47, 73, 0.82));
}

.login-art-content {
  position: relative;
  max-width: 760px;
}

.login-art span {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-art h2 {
  margin: 0;
  font-size: 38px;
  line-height: 1.15;
}

.hint {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.compact-hint {
  padding: 8px 10px;
}

.form-alert {
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
  color: #991b1b;
  padding: 10px 12px;
  font-weight: 700;
}

.search-results {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.delivery-customer-results {
  max-height: 280px;
}

.sales-data-filter {
  padding: 14px;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.sales-filter-action {
  align-self: end;
}

.search-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.search-result span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.search-result[hidden] {
  display: none;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.money {
  font-weight: 800;
}

.alert-card {
  border-color: #fecaca;
  background: #fff7f7;
  margin-bottom: 16px;
}

.attention-row {
  background: #fff7f7;
}

.danger-text {
  color: var(--danger);
}

.mobile-menu {
  display: none;
}

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

  .sidebar {
    position: relative;
    height: auto;
  }

  .stats,
  .compact-stats,
  .two-col,
  .form-grid,
  .due-filter {
    grid-template-columns: 1fr;
  }

  .module-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .due-filter-type,
  .due-filter-month,
  .due-filter-from,
  .due-filter-to,
  .due-filter-action {
    grid-column: auto;
  }

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

  .login-page {
    grid-template-columns: 1fr;
  }

  .login-art {
    min-height: 320px;
  }
}

@media (max-width: 560px) {
  .module-card-grid {
    grid-template-columns: 1fr;
  }

  .main,
  .login-panel,
  .login-art {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar .btn,
  .toolbar select {
    flex: 1;
  }

  .salary-subnav .btn {
    flex: 1;
  }

  .salary-card-head {
    display: grid;
  }

  .salary-net {
    text-align: left;
  }

  .salary-breakdown,
  .salary-summary-card {
    grid-template-columns: 1fr;
  }
}
.customer-frequency-input {
  width: 5.5rem;
  min-width: 5.5rem;
  padding: 0.4rem 0.5rem;
}

.delivery-due-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.75rem 0 1rem;
}

.due-customer-activity-tabs {
  margin: 0 0 0.75rem;
}

.due-payment-range-grid {
  grid-template-columns: minmax(180px, 1.1fr) repeat(3, minmax(170px, 1fr)) auto;
  align-items: end;
}

.due-payment-range-grid .field {
  min-width: 0;
}

@media (max-width: 950px) {
  .due-payment-range-grid {
    grid-template-columns: 1fr;
  }
}

.delivery-due-key {
  border-radius: 999px;
  color: #422006;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
}

.delivery-due-row.due-soon > td,
.delivery-due-key.due-soon {
  background: #fef3c7;
}

.delivery-due-row.due-tomorrow > td,
.delivery-due-key.due-tomorrow {
  background: #fed7aa;
}

.delivery-due-row.due-now > td,
.delivery-due-key.due-now {
  background: #fecaca;
}
.pill.inactive { background: #e2e8f0; color: #475569; }
.inactive-customer-row > td { background: #f8fafc; color: #64748b; }

.demo-banner {
  align-items: center;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 10px;
  color: #9a3412;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
}
.demo-banner strong { background: #ea580c; border-radius: 999px; color: white; padding: 0.15rem 0.55rem; }
.demo-login-card { background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 12px; margin-bottom: 1rem; padding: 0.9rem; }
.demo-login-card h3 { margin: 0 0 0.65rem; }
.demo-account-grid { display: grid; gap: 0.55rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.demo-account { background: white; border: 1px solid #99f6e4; border-radius: 9px; color: #134e4a; cursor: pointer; display: flex; flex-direction: column; padding: 0.65rem; text-align: left; }
.demo-account:hover { border-color: #0d9488; box-shadow: 0 2px 8px rgb(15 118 110 / 14%); }
.demo-account span, .demo-account small { font-family: ui-monospace, monospace; }
@media (max-width: 560px) { .demo-account-grid { grid-template-columns: 1fr; } }
