:root {
  --ink: #17212f;
  --muted: #657184;
  --line: #dfe5ee;
  --panel: #ffffff;
  --bg: #eef3f7;
  --teal: #0f766e;
  --teal-dark: #104f4b;
  --amber: #c47a12;
  --red: #c2413a;
  --blue: #2563eb;
  --shadow: 0 24px 70px rgba(24, 38, 55, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(196, 122, 18, 0.12), transparent 30%),
    var(--bg);
}

.factory-visual {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 620px;
  padding: 34px;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(rgba(16, 32, 44, 0.44), rgba(16, 32, 44, 0.72)),
    url("https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?auto=format&fit=crop&w=1600&q=80") center / cover;
  box-shadow: var(--shadow);
}

.visual-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  opacity: 0.18;
  pointer-events: none;
}

.visual-grid span {
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
}

.brand-block,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--teal), var(--blue));
}

.brand-block p,
.brand-block strong {
  position: relative;
  z-index: 1;
  display: block;
  margin: 0;
}

.brand-block p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.brand-block strong {
  margin-top: 3px;
  font-size: 18px;
}

.factory-copy {
  position: relative;
  z-index: 1;
  max-width: 760px;
}

.factory-copy h1 {
  max-width: 850px;
  margin: 0;
  font-size: clamp(40px, 6vw, 76px);
  line-height: 0.96;
  letter-spacing: 0;
}

.factory-copy p {
  max-width: 660px;
  margin: 22px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 18px;
  line-height: 1.6;
}

.plant-card {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: end;
  width: min(100%, 440px);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(6, 15, 24, 0.58);
  backdrop-filter: blur(14px);
}

.plant-card span {
  color: rgba(255, 255, 255, 0.7);
}

.plant-card strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

.mini-bars {
  display: flex;
  align-items: end;
  gap: 8px;
  height: 82px;
}

.mini-bars i {
  width: 13px;
  border-radius: 3px 3px 0 0;
  background: #38bdf8;
}

.login-panel {
  max-width: 500px;
  margin: 0 auto;
  padding: 38px;
  border: 1px solid rgba(23, 33, 47, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-panel h2,
.topbar h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h2 {
  font-size: 36px;
}

.panel-subtitle {
  margin: 10px 0 28px;
  color: var(--muted);
  line-height: 1.6;
}

.form-control:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.login-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 13px;
}

.btn-brand {
  border: 0;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  box-shadow: 0 16px 30px rgba(15, 118, 110, 0.22);
}

.btn-brand:hover,
.btn-brand:focus {
  color: #fff;
  background: linear-gradient(135deg, #0d6f68, #0d4744);
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.sidebar-brand strong,
.sidebar-brand small {
  display: block;
}

.sidebar-brand small {
  margin-top: 3px;
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-list a {
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.nav-list a.active,
.nav-list a:hover {
  color: var(--teal-dark);
  background: rgba(15, 118, 110, 0.1);
}

.logout-button {
  margin-top: auto;
  padding: 13px 16px;
  border-radius: 8px;
  color: var(--red);
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  background: rgba(194, 65, 58, 0.1);
}

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

.topbar,
.panel-heading,
.topbar-actions {
  display: flex;
  align-items: center;
}

.topbar,
.panel-heading {
  justify-content: space-between;
  gap: 20px;
}

.topbar {
  margin-bottom: 24px;
}

.topbar h2 {
  font-size: 30px;
}

.topbar-actions {
  gap: 10px;
}

.icon-action {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.admin-chip {
  padding: 11px 16px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: var(--ink);
}

.metric-card,
.panel {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 38px rgba(24, 38, 55, 0.07);
}

.metric-card {
  padding: 22px;
}

.metric-card span,
.panel small {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 32px;
}

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

.panel-heading {
  margin-bottom: 20px;
}

.line-chart {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  gap: 16px;
  height: 260px;
  padding-top: 20px;
}

.line-chart span {
  position: relative;
  display: flex;
  justify-content: center;
  min-height: 52px;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, #14b8a6, #2563eb);
}

.line-chart b {
  position: absolute;
  bottom: -30px;
  color: var(--muted);
  font-size: 12px;
}

.alert-list,
.machine-list {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.alert-list li,
.machine-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.alert-list li:last-child,
.machine-list li:last-child {
  border-bottom: 0;
}

.alert-list b {
  color: var(--amber);
}

.table {
  min-width: 680px;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.active {
  color: var(--blue);
  background: rgba(37, 99, 235, 0.1);
}

.status.hold {
  color: var(--amber);
  background: rgba(196, 122, 18, 0.12);
}

.status.ready {
  color: var(--teal);
  background: rgba(15, 118, 110, 0.12);
}

.item-type-card strong {
  font-size: 28px;
}

.master-form .form-label,
.bom-form .form-label {
  color: var(--ink);
  font-size: 13px;
}

.raw-uom-fields {
  padding: 14px;
  border: 1px dashed rgba(15, 118, 110, 0.35);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.05);
}

.raw-uom-fields.is-muted {
  border-color: var(--line);
  background: #f8fafc;
}

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

.master-table {
  min-width: 920px;
}

.type-pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.type-raw {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.12);
}

.type-finished {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
}

.type-trading {
  color: #6d28d9;
  background: rgba(109, 40, 217, 0.1);
}

.type-packaging {
  color: #c47a12;
  background: rgba(196, 122, 18, 0.12);
}

.type-consumable {
  color: #c2413a;
  background: rgba(194, 65, 58, 0.1);
}

.bom-lines {
  display: grid;
  gap: 10px;
}

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

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

.component-stack span {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  background: #eef3f7;
}

.bulk-upload-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(24, 38, 55, 0.07);
}

.bulk-upload-band h3 {
  margin: 0;
  font-size: 20px;
}

.bulk-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.action-row form {
  margin: 0;
}

.upload-hint {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.sample-link {
  display: inline-flex;
  margin-bottom: 12px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.sample-link:hover {
  color: var(--teal);
  text-decoration: underline;
}

.bulk-inline {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.modal-content {
  border: 0;
  border-radius: 8px;
}

.finance-form {
  display: grid;
  gap: 10px;
}

.finance-table {
  min-width: 560px;
}

.finance-alert-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid rgba(196, 122, 18, 0.28);
  border-radius: 8px;
  background: rgba(196, 122, 18, 0.1);
}

.finance-alert-band h3 {
  margin: 0;
  font-size: 20px;
}

.finance-alert-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.finance-alert-list span {
  display: inline-flex;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 800;
  background: #fff;
}

.company-summary {
  display: flex;
  flex-direction: column;
}

.company-logo {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 12px 0 18px;
  border-radius: 8px;
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--teal), var(--blue));
}

.company-summary h3 {
  margin-bottom: 8px;
}

.company-summary p {
  color: var(--muted);
}

.company-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  font-size: 13px;
  font-weight: 800;
}

.company-facts span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.company-facts b {
  display: block;
  overflow-wrap: anywhere;
}

.company-form .form-label {
  color: var(--ink);
  font-size: 13px;
}

.store-table {
  min-width: 860px;
}

.store-filter {
  max-width: 520px;
  margin-bottom: 18px;
}

.store-filter .form-label {
  color: var(--ink);
  font-size: 13px;
}

.store-list {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.store-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.store-list li:last-child {
  border-bottom: 0;
}

.store-list b {
  color: var(--teal-dark);
}

.store-filter-row.is-hidden {
  display: none;
}

.warehouse-filter-row.is-hidden {
  display: none;
}

.flow-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.flow-strip span {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  font-size: 12px;
  font-weight: 700;
}

.flow-strip span::after {
  content: "  →";
  opacity: .7;
}

.flow-strip span:last-child::after {
  content: "";
}

.flow-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 430px;
}

.flow-actions form {
  margin: 0;
}

.flow-actions .form-control {
  min-width: 105px;
}

.flow-table {
  min-width: 940px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.quality-score {
  display: grid;
  place-items: center;
  min-height: 154px;
  margin-bottom: 16px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--ink), var(--teal-dark));
}

.quality-score strong {
  font-size: 44px;
}

.quality-score span {
  color: rgba(255, 255, 255, 0.72);
}

.progress-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
}

.progress-row i {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #edf2f7;
}

.progress-row b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.good {
  color: var(--teal) !important;
}

.warn {
  color: var(--amber) !important;
}

.danger {
  color: var(--red) !important;
}

.sales-page-stack { display: grid; gap: 24px; }
.sales-order-form { max-width: 1100px; }
.sales-items-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #e4e9ef; }
#salesLines { display: grid; gap: 12px; }
.sales-line { display: grid; grid-template-columns: minmax(280px, 1fr) 150px 170px 44px; align-items: end; gap: 12px; padding: 16px; border: 1px solid #dfe6ec; border-radius: 14px; background: #f8fafb; }
.sales-line label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.sales-line-remove .btn { width: 44px; height: 38px; padding: 0; font-size: 20px; }
.sales-register-panel td:nth-child(3) div + div { margin-top: 4px; padding-top: 4px; border-top: 1px dashed #dfe6ec; }
.purchase-lines-heading { display:flex; align-items:center; justify-content:space-between; margin-top:22px; padding-bottom:10px; border-bottom:1px solid #e4e9ef; }
#purchaseLines { display:grid; gap:12px; margin-top:12px; }
.purchase-order-line { display:grid; grid-template-columns:minmax(220px,1fr) minmax(240px,1.2fr) 150px 44px; gap:12px; align-items:end; padding:16px; border:1px solid #dfe6ec; border-radius:14px; background:#f8fafb; }
.purchase-order-line label { display:block; margin-bottom:6px; color:var(--muted); font-size:12px; font-weight:700; text-transform:uppercase; }
.remove-purchase-line { width:44px; height:38px; padding:0; font-size:20px; }
.grn-receive-line { margin:0 0 12px; padding:16px; border:1px solid #dfe6ec; border-radius:14px; background:#f8fafb; }

@media (max-width: 991px) {
  .factory-visual {
    min-height: 520px;
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    gap: 16px;
  }

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

@media (max-width: 760px) {
  .dashboard-main {
    padding: 16px;
  }

  .factory-visual {
    min-height: 480px;
    padding: 24px;
  }

  .login-panel {
    padding: 24px;
  }

  .login-meta,
  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .admin-chip {
    margin-left: auto;
  }

  .bulk-upload-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .sales-line { grid-template-columns: 1fr 1fr; }
  .sales-line-item { grid-column: 1 / -1; }
  .sales-line-remove { display: flex; align-items: flex-end; justify-content: flex-end; }
  .purchase-order-line { grid-template-columns:1fr 1fr; }
}

@media (max-width: 480px) {
  .factory-copy h1 {
    font-size: 38px;
  }

  .factory-copy p {
    font-size: 15px;
  }

  .plant-card {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .sales-line { grid-template-columns: 1fr; }
  .sales-line-item { grid-column: auto; }
}
