:root {
  --erp-ink: #132238;
  --erp-muted: #66758a;
  --erp-navy: #0b2743;
  --erp-navy-2: #103653;
  --erp-blue: #20a8dc;
  --erp-blue-dark: #0877a7;
  --erp-teal: #16a59a;
  --erp-bg: #f3f6f9;
  --erp-card: #ffffff;
  --erp-line: #dfe6ed;
  --erp-warn: #e99a25;
  --erp-danger: #d94b5a;
  --erp-success: #248a63;
  --erp-shadow: 0 10px 30px rgba(15, 39, 65, .07);
  --erp-radius: 15px;
}

html,
body {
  min-height: 100%;
}

body {
  background: var(--erp-bg);
  color: var(--erp-ink);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: .925rem;
}

a {
  color: var(--erp-blue-dark);
  text-decoration: none;
}

a:hover {
  color: var(--erp-blue);
}

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

.erp-sidebar {
  background: linear-gradient(165deg, var(--erp-navy) 0%, #071b31 100%);
  color: rgba(255, 255, 255, .86);
  height: 100vh;
  overflow-y: auto;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.erp-brand {
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  display: flex;
  gap: 12px;
  min-height: 76px;
  padding: 15px 20px;
}

.erp-brand img {
  background: #fff;
  border-radius: 9px;
  height: 38px;
  object-fit: contain;
  padding: 5px;
  width: 108px;
}

.erp-brand small {
  color: rgba(255, 255, 255, .58);
  display: block;
  font-size: .67rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.erp-brand strong {
  color: #fff;
  display: block;
  font-size: .86rem;
}

.erp-nav {
  padding: 14px 12px 28px;
}

.erp-nav-title {
  align-items: center;
  color: rgba(255, 255, 255, .38);
  cursor: pointer;
  display: flex;
  font-size: .64rem;
  font-weight: 700;
  justify-content: space-between;
  letter-spacing: .14em;
  margin: 20px 11px 7px;
  padding: 4px 0;
  text-transform: uppercase;
}

.erp-nav-title::-webkit-details-marker {
  display: none;
}

.erp-nav-title::marker {
  content: "";
}

.erp-nav-title i {
  font-size: .65rem;
  transition: transform .18s ease;
}

.erp-nav-group[open] .erp-nav-title i {
  transform: rotate(180deg);
}

.erp-nav-items {
  display: grid;
}

.erp-nav-link {
  align-items: center;
  border-radius: 10px;
  color: rgba(255, 255, 255, .72);
  display: flex;
  gap: 11px;
  margin: 3px 0;
  padding: 10px 12px;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}

.erp-nav-link i {
  color: #76d1f2;
  font-size: 1.02rem;
  width: 20px;
}

.erp-nav-link:hover,
.erp-nav-link.active {
  background: rgba(32, 168, 220, .17);
  color: #fff;
  transform: translateX(2px);
}

.erp-nav-link.active {
  box-shadow: inset 3px 0 0 var(--erp-blue);
}

.erp-main {
  min-width: 0;
}

.two-factor-qr {
  background: #fff;
  border: 1px solid var(--erp-line);
  border-radius: 14px;
  height: auto;
  max-width: 260px;
  padding: 12px;
  width: 100%;
}

.erp-topbar {
  align-items: center;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--erp-line);
  display: flex;
  height: 76px;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.erp-page-title {
  color: var(--erp-ink);
  font-size: 1.22rem;
  font-weight: 750;
  margin: 0;
}

.erp-breadcrumb {
  color: var(--erp-muted);
  font-size: .76rem;
}

.erp-content {
  margin: 0 auto;
  max-width: 1680px;
  padding: 26px 28px 48px;
}

.erp-user {
  align-items: center;
  display: flex;
  gap: 10px;
}

.erp-avatar {
  align-items: center;
  background: linear-gradient(135deg, var(--erp-blue), var(--erp-teal));
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.erp-card,
.card {
  background: var(--erp-card);
  border: 1px solid rgba(215, 225, 234, .92);
  border-radius: var(--erp-radius);
  box-shadow: var(--erp-shadow);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--erp-line);
  padding: 18px 20px;
}

.card-body {
  padding: 20px;
}

.erp-stat {
  min-height: 132px;
  overflow: hidden;
  padding: 20px;
  position: relative;
}

.erp-stat::after {
  background: var(--erp-blue);
  border-radius: 50%;
  content: "";
  height: 88px;
  opacity: .08;
  position: absolute;
  right: -18px;
  top: -24px;
  width: 88px;
}

.erp-stat-label {
  color: var(--erp-muted);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.erp-stat-value {
  color: var(--erp-navy);
  font-size: 1.68rem;
  font-weight: 780;
  letter-spacing: -.025em;
  margin-top: 8px;
}

.erp-stat-note {
  color: var(--erp-muted);
  font-size: .76rem;
  margin-top: 6px;
}

.erp-stat-icon {
  align-items: center;
  background: rgba(32, 168, 220, .11);
  border-radius: 11px;
  color: var(--erp-blue-dark);
  display: flex;
  font-size: 1.15rem;
  height: 39px;
  justify-content: center;
  position: absolute;
  right: 18px;
  top: 18px;
  width: 39px;
}

.table {
  --bs-table-bg: transparent;
  border-color: var(--erp-line);
  color: var(--erp-ink);
  margin-bottom: 0;
}

.table thead th {
  background: #f8fafc;
  border-bottom-width: 1px;
  color: #526278;
  font-size: .69rem;
  font-weight: 750;
  letter-spacing: .055em;
  padding: 12px 14px;
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody td {
  padding: 13px 14px;
  vertical-align: middle;
}

.table-hover > tbody > tr:hover > * {
  --bs-table-bg-state: #f4faff;
}

.form-label {
  color: #405169;
  font-size: .78rem;
  font-weight: 700;
  margin-bottom: 7px;
}

.form-control,
.form-select {
  border-color: #cfd9e2;
  border-radius: 9px;
  min-height: 43px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--erp-blue);
  box-shadow: 0 0 0 .2rem rgba(32, 168, 220, .13);
}

.btn {
  border-radius: 9px;
  font-weight: 650;
  min-height: 40px;
  padding: .55rem .9rem;
}

.btn-primary {
  --bs-btn-bg: var(--erp-blue-dark);
  --bs-btn-border-color: var(--erp-blue-dark);
  --bs-btn-hover-bg: #05648f;
  --bs-btn-hover-border-color: #05648f;
}

.btn-success {
  --bs-btn-bg: var(--erp-success);
  --bs-btn-border-color: var(--erp-success);
}

.badge {
  border-radius: 20px;
  font-size: .68rem;
  letter-spacing: .025em;
  padding: .48em .72em;
}

.status-draft,
.status-pending {
  background: #fff3d8;
  color: #865b09;
}

.status-approved,
.status-paid,
.status-delivered,
.status-active,
.status-completed {
  background: #dff5eb;
  color: #126344;
}

.status-rejected,
.status-cancelled,
.status-overdue,
.status-failed {
  background: #fde4e7;
  color: #9c2635;
}

.status-open,
.status-partial,
.status-processing {
  background: #dff2fb;
  color: #08668d;
}

.erp-filters {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(200px, 1.8fr) repeat(3, minmax(130px, .8fr)) auto;
}

.erp-empty {
  color: var(--erp-muted);
  padding: 54px 20px;
  text-align: center;
}

.erp-empty i {
  color: #a9b8c7;
  display: block;
  font-size: 2.2rem;
  margin-bottom: 10px;
}

.erp-form-section {
  border-bottom: 1px solid var(--erp-line);
  margin-bottom: 22px;
  padding-bottom: 18px;
}

.erp-form-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

.erp-form-section h3 {
  font-size: .93rem;
  font-weight: 750;
  margin-bottom: 15px;
}

.erp-kv {
  display: grid;
  gap: 0;
  grid-template-columns: minmax(130px, .7fr) 1.7fr;
}

.erp-kv dt,
.erp-kv dd {
  border-bottom: 1px solid var(--erp-line);
  margin: 0;
  padding: 11px 0;
}

.erp-kv dt {
  color: var(--erp-muted);
  font-size: .78rem;
  font-weight: 650;
}

.erp-kv dd {
  color: var(--erp-ink);
}

.erp-action-tile {
  background: #f8fafc;
  border: 1px solid var(--erp-line);
  border-radius: 12px;
  color: var(--erp-ink);
  display: block;
  padding: 16px;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

a.erp-action-tile:hover {
  border-color: rgba(32, 168, 220, .55);
  box-shadow: 0 8px 24px rgba(15, 39, 65, .08);
  transform: translateY(-1px);
}

.erp-metric {
  background: #fff;
  border: 1px solid var(--erp-line);
  border-radius: 13px;
  box-shadow: var(--erp-shadow);
  display: flex;
  flex-direction: column;
  min-height: 106px;
  padding: 18px;
}

.erp-metric span {
  color: var(--erp-muted);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.erp-metric strong {
  color: var(--erp-navy);
  font-size: 1.35rem;
  margin-top: 8px;
}

.erp-status {
  border-radius: 20px;
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .025em;
  padding: .48em .72em;
  text-transform: uppercase;
}

.erp-status-pass,
.erp-status-active,
.erp-status-approved,
.erp-status-paid,
.erp-status-delivered,
.erp-status-completed,
.erp-status-success {
  background: #dff5eb;
  color: #126344;
}

.erp-status-fail,
.erp-status-rejected,
.erp-status-cancelled,
.erp-status-overdue,
.erp-status-failed,
.erp-status-critical {
  background: #fde4e7;
  color: #9c2635;
}

.erp-status-open,
.erp-status-partial,
.erp-status-processing,
.erp-status-in_progress,
.erp-status-sent {
  background: #dff2fb;
  color: #08668d;
}

.erp-status-draft,
.erp-status-pending,
.erp-status-hold,
.erp-status-conditional,
.erp-status-unpaid {
  background: #fff3d8;
  color: #865b09;
}

.erp-timeline {
  border-left: 2px solid var(--erp-line);
  list-style: none;
  margin: 0 0 0 8px;
  padding: 0 0 0 20px;
}

.erp-timeline > li {
  margin-bottom: 20px;
  position: relative;
}

.erp-timeline > li::before {
  background: var(--erp-teal);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--erp-line);
  content: "";
  height: 12px;
  left: -27px;
  position: absolute;
  top: 4px;
  width: 12px;
}

.audit-json {
  background: #091a2d;
  border-radius: 10px;
  color: #d8eef8;
  font-size: .75rem;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.best-rotation {
  border: 2px solid rgba(22, 165, 154, .55);
  box-shadow: 0 12px 32px rgba(22, 165, 154, .11);
}

.health-check {
  border-left: 4px solid var(--erp-line);
}

.health-ok {
  border-left-color: var(--erp-success);
}

.health-fail {
  border-left-color: var(--erp-danger);
}

.health-icon {
  align-items: center;
  border-radius: 50%;
  display: inline-flex;
  flex: 0 0 40px;
  font-size: 1.25rem;
  height: 40px;
  justify-content: center;
}

.health-ok .health-icon {
  background: #dff5eb;
  color: #126344;
}

.health-fail .health-icon {
  background: #fde4e7;
  color: #9c2635;
}

.customer-surface .erp-sidebar {
  background: linear-gradient(165deg, #0b3c52 0%, #08293c 100%);
}

.progress {
  height: 7px;
}

.progress-bar {
  background: linear-gradient(90deg, var(--erp-blue), var(--erp-teal));
  width: 0;
}

[data-signature-canvas] {
  background: #fff;
  display: block;
  touch-action: none;
}

.erp-login-page {
  align-items: center;
  background:
    radial-gradient(circle at 15% 10%, rgba(32, 168, 220, .18), transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(22, 165, 154, .16), transparent 35%),
    linear-gradient(140deg, #071b31, #123a58);
  display: flex;
  min-height: 100vh;
  padding: 28px;
}

.erp-login-card {
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .28);
  margin: auto;
  max-width: 440px;
  overflow: hidden;
  width: 100%;
}

.erp-login-head {
  border-bottom: 1px solid var(--erp-line);
  padding: 28px 30px 20px;
}

.erp-login-head img {
  height: 52px;
  object-fit: contain;
  width: 180px;
}

.erp-login-body {
  padding: 28px 30px 32px;
}

.erp-login-portal {
  color: var(--erp-blue-dark);
  font-size: .73rem;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.crew-surface .btn,
.crew-surface .form-control,
.crew-surface .form-select {
  min-height: 50px;
}

.crew-surface .erp-action-tile {
  align-items: center;
  display: flex;
  font-size: 1rem;
  gap: 12px;
  min-height: 90px;
  padding: 18px;
}

.crew-surface .erp-action-tile i {
  color: var(--erp-blue-dark);
  font-size: 1.45rem;
}

.erp-line-items .line-item {
  background: #f8fafc;
  border: 1px solid var(--erp-line);
  border-radius: 12px;
  margin-bottom: 10px;
  padding: 14px;
}

.erp-print-only {
  display: none;
}

.erp-print-logo {
  height: 48px;
  object-fit: contain;
  width: 180px;
}

@media (max-width: 1100px) {
  .erp-shell {
    grid-template-columns: 1fr;
  }
  .erp-sidebar {
    bottom: 0;
    left: -290px;
    position: fixed;
    top: 0;
    transition: left .22s ease;
    width: 270px;
  }
  body.nav-open .erp-sidebar {
    left: 0;
  }
  body.nav-open::after {
    background: rgba(5, 18, 31, .48);
    content: "";
    inset: 0;
    position: fixed;
    z-index: 1025;
  }
  .erp-sidebar {
    z-index: 1040;
  }
  .erp-filters {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 767px) {
  .erp-topbar {
    height: 68px;
    padding: 0 16px;
  }
  .erp-content {
    padding: 18px 13px 40px;
  }
  .erp-user-text {
    display: none;
  }
  .erp-page-title {
    font-size: 1.05rem;
  }
  .erp-filters {
    grid-template-columns: 1fr;
  }
  .card-body,
  .card-header {
    padding: 16px;
  }
  .erp-kv {
    grid-template-columns: 1fr;
  }
  .erp-kv dt {
    border-bottom: 0;
    padding-bottom: 0;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
    font-size: 11px;
  }
  .erp-sidebar,
  .erp-topbar,
  .no-print,
  .btn,
  .erp-filters {
    display: none !important;
  }
  .erp-shell {
    display: block;
  }
  .erp-content {
    max-width: none;
    padding: 0;
  }
  .erp-card,
  .card {
    border: 0;
    box-shadow: none;
  }
  .erp-print-only {
    display: block;
  }
}
