:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172554;
  --text-muted: #4b5f85;
  --line: #d6e1f1;
  --brand: #1d4ed8;
  --brand-2: #1e40af;
  --header: #0f172a;
  --header-2: #1e293b;
  --success: #16a34a;
  --warn: #ca8a04;
  --danger: #dc2626;
  --info: #0284c7;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: linear-gradient(180deg, #eef3fb 0%, var(--bg) 40%, #f7f9fd 100%);
}

.site-header {
  background: linear-gradient(130deg, var(--header), var(--header-2));
  color: #fff;
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
  padding: 0.95rem 1.2rem 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-shell {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  gap: 1.1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
}

.brand-logo {
  height: 38px;
  width: auto;
  display: block;
}

.brand-app {
  font-size: 0.93rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #bfdbfe;
}

.main-nav {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #dbeafe;
  font-size: 0.85rem;
}

.user-meta form {
  margin: 0;
}

.main-nav a {
  color: #dbeafe;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 650;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.main-nav a:hover,
.main-nav a:focus-visible {
  color: #fff;
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(147, 197, 253, 0.38);
  outline: none;
}

.header-subtitle {
  max-width: 1280px;
  margin: 0.6rem auto 0;
  color: #bfdbfe;
  font-size: 0.83rem;
}

.container {
  max-width: 1280px;
  margin: 1.25rem auto 1.75rem;
  padding: 0 1rem;
}

.page-shell {
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 1rem;
}

.site-footer {
  max-width: 1280px;
  margin: 0 auto 1rem;
  color: #64748b;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 1.05rem;
  flex-wrap: wrap;
}

.auth-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.auth-card {
  width: 100%;
  max-width: 440px;
}

.auth-form {
  max-width: 100%;
}

.twofa-qr-card {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
}

.twofa-qr-image {
  width: 220px;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.4rem;
}

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

h2,
h3,
h4 {
  margin: 0 0 0.7rem;
  color: #0f2a5f;
}

h2 {
  font-size: 1.45rem;
}

h3 {
  font-size: 1.15rem;
  margin-top: 1rem;
}

h4 {
  font-size: 1.02rem;
}

.page-subtle {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.metric-card {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.metric-label {
  color: var(--text-muted);
  font-size: 0.84rem;
  margin-bottom: 0.35rem;
}

.metric-value {
  color: #0b2e72;
  font-size: 1.52rem;
  font-weight: 800;
}

.card,
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.form-card {
  display: grid;
  gap: 0.75rem;
  max-width: 620px;
}

label {
  color: #1e3a70;
  font-weight: 700;
  font-size: 0.9rem;
}

input,
select {
  width: 100%;
  color: #1f2937;
  padding: 0.64rem 0.7rem;
  border: 1px solid #bfd0e6;
  border-radius: 10px;
  font-size: 0.96rem;
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid #93c5fd;
  outline-offset: 0;
  border-color: #60a5fa;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.data-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: #fff;
}

.data-table th,
.data-table td {
  padding: 0.74rem;
  border-bottom: 1px solid #e4edf8;
  text-align: left;
  vertical-align: middle;
  font-size: 0.92rem;
}

.data-table th {
  color: #254276;
  font-size: 0.81rem;
  text-transform: uppercase;
  letter-spacing: 0.035em;
}

.data-table thead {
  background: #f0f6ff;
}

.compact-table th,
.compact-table td {
  padding: 0.56rem 0.62rem;
}

.data-table tbody tr {
  transition: background-color 140ms ease;
}

.data-table tbody tr:hover {
  background: #f7fbff;
}

.row-status-not_started {
  background: #f8fafc;
}

.row-status-in_progress {
  background: #fffbeb;
}

.row-status-complete {
  background: #f0fdf4;
}

.row-low-stock {
  background: #fff7ed;
}

.row-schedule-override {
  background: #fef3c7;
}

.btn {
  display: inline-block;
  border: 1px solid #3b82f6;
  background: #fff;
  color: #1d4ed8;
  border-radius: 10px;
  padding: 0.64rem 0.95rem;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.btn:hover,
.btn:focus-visible {
  background: #eff6ff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  outline: none;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand-2);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--brand-2);
}

.btn-large {
  min-width: 130px;
  padding: 0.78rem 1.15rem;
}

.btn-xl {
  min-width: 185px;
  padding: 0.95rem 1.3rem;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-not_started,
.badge-pending {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

.badge-in_progress,
.badge-active {
  background: #fef9c3;
  border-color: #facc15;
  color: #92400e;
}

.badge-complete {
  background: #dcfce7;
  border-color: #22c55e;
  color: #166534;
}

.badge-priority-normal {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e3a8a;
}

.badge-priority-rush {
  background: #fee2e2;
  border-color: #f87171;
  color: #991b1b;
}

.badge-low-stock,
.badge-readiness-short,
.badge-txn-issue {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

.badge-good-stock,
.badge-readiness-ready,
.badge-txn-receive {
  background: #dcfce7;
  border-color: #22c55e;
  color: #166534;
}

.badge-readiness-partial,
.badge-txn-adjust {
  background: #fef9c3;
  border-color: #eab308;
  color: #854d0e;
}

.badge-txn-return {
  background: #e0f2fe;
  border-color: #0ea5e9;
  color: #075985;
}

.badge-txn-count {
  background: #f3e8ff;
  border-color: #c084fc;
  color: #6b21a8;
}

.badge-role {
  background: #e0e7ff;
  border-color: #818cf8;
  color: #3730a3;
}

.badge-profit {
  background: #dcfce7;
  border-color: #22c55e;
  color: #166534;
}

.badge-override-manual {
  background: #ffedd5;
  border-color: #fb923c;
  color: #9a3412;
}

.badge-override-auto {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #0c4a6e;
}

.stage-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.stage-item {
  background: #fff;
  border: 1px solid var(--line);
  border-left-width: 8px;
  border-radius: 12px;
  padding: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.stage-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stage-name-row {
  display: flex;
  align-items: center;
  gap: 0.58rem;
  flex-wrap: wrap;
}

.stage-name {
  font-weight: 800;
  color: #0f2a5f;
}

.stage-meta {
  display: flex;
  gap: 0.85rem;
  margin-top: 0.36rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.stage-pending {
  border-left-color: #94a3b8;
}

.stage-active {
  border-left-color: #eab308;
  background: #fffbeb;
}

.stage-complete {
  border-left-color: #22c55e;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.72rem;
  margin-bottom: 0.55rem;
  color: #1f3b72;
}

.progress-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
}

.quick-action-row,
.action-row {
  margin-top: 0.82rem;
  margin-bottom: 0.3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
  align-items: end;
}

.inline-form-action {
  display: flex;
  align-items: flex-end;
}

.schedule-inline-panel {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.55rem;
  min-width: 460px;
}

.finance-stack {
  display: grid;
  gap: 0.5rem;
  max-width: 520px;
}

.finance-stack-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

.finance-stack-row-total {
  background: #ecfeff;
  border-color: #67e8f9;
}

.metric-up {
  color: #15803d;
}

.metric-down {
  color: #b91c1c;
}

.finance-chart-grid {
  display: grid;
  gap: 0.75rem;
}

.finance-export-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.finance-chart-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.finance-canvas {
  width: 100%;
  display: block;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.finance-canvas-lg {
  height: 270px;
}

.finance-canvas-sm {
  height: 220px;
}

.finance-legend {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  color: #475569;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.swatch-revenue {
  background: #0ea5e9;
}

.swatch-gross {
  background: #22c55e;
}

.swatch-material {
  background: #f59e0b;
}

.swatch-labor {
  background: #3b82f6;
}

.swatch-overhead {
  background: #8b5cf6;
}

.swatch-margin {
  background: #ef4444;
}

@media (max-width: 920px) {
  .finance-canvas-lg {
    height: 230px;
  }

  .finance-canvas-sm {
    height: 190px;
  }
}

@media (max-width: 680px) {
  .finance-canvas-lg {
    height: 200px;
  }

  .finance-canvas-sm {
    height: 170px;
  }
}

@media (max-width: 920px) {
  .header-subtitle {
    display: none;
  }

  .page-shell {
    padding: 0.75rem;
  }

  .btn-xl {
    min-width: 150px;
  }
}

@media (max-width: 680px) {
  .main-nav {
    width: 100%;
  }

  .main-nav a {
    font-size: 0.82rem;
    padding: 0.42rem 0.58rem;
  }

  .site-footer {
    font-size: 0.75rem;
  }

  .data-table {
    min-width: 680px;
  }

  .stage-item {
    flex-direction: column;
    align-items: flex-start;
  }
}
