/* -------- Tokens / Base -------- */
:root {
  --brand-600: #2d6fe6;
  --brand-700: #2057b8;
  --brand-800: #1a4694;
  --text-on: #ffffff;
  --shadow: 0 6px 20px rgba(16, 33, 70, .15);
  --card-bg: rgba(10, 25, 60, 0.9);
  --card-border: rgba(255, 255, 255, 0.08);
}

/* Global reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
}

body {
  background: url('https://www.dataplate.co.uk/images/dpscreen.png') no-repeat center center fixed;
  background-size: cover;
  margin: 0;
  padding: 0;
  color: #e0e6f0;
  padding-top: 96px; /* space for fixed navbar */
}

/* -------- Global link styling -------- */
a {
  color: #ffe66b;
}
a:hover,
a:focus-visible {
  color: #fff7a5;
  text-decoration: underline;
  outline: none;
}

/* -------- Navbar (Dataplate global) -------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  width: 100%;
  backdrop-filter: blur(10px);
}

.site-nav {
  width: 100%;
  font: 700 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text-on);
  background: linear-gradient(90deg, var(--brand-700), var(--brand-600));
  box-shadow: var(--shadow);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  width: 100%;
  padding: 0 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--text-on);
  font-weight: 800;
  letter-spacing: .2px;
  white-space: nowrap;
}

.brand-logo {
  width: 28px;
  height: 28px;
  display: inline-block;
  border-radius: 6px;
  background: url('https://www.dataplate.co.uk/images/dp.png') center/contain no-repeat;
}

.brand span {
  font-size: 20px;
}

.menu {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .25rem;
  margin: 0;
  padding: 0;
}

.menu a {
  display: inline-block;
  padding: 12px 16px;
  color: var(--text-on);
  text-decoration: none;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  transition: background-color .15s ease, transform .15s ease;
}

.menu a:hover,
.menu a:focus-visible {
  background: rgba(255, 255, 255, .15);
  outline: none;
}

.menu a:active {
  transform: translateY(1px);
}

.nav-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-on);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: rgba(255, 255, 255, .12);
  outline: none;
}

.nav-toggle svg {
  width: 22px;
  height: 22px;
}

.drawer {
  display: none;
}

@media (max-width: 800px) {
  .nav-inner {
    height: 56px;
    padding-right: calc(12px + env(safe-area-inset-right));
    padding-left: calc(12px + env(safe-area-inset-left));
  }

  .menu {
    display: none;
  }

  .drawer {
    display: block;
  }

  .nav-toggle {
    margin-right: 12px;
  }

  .drawer-panel {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #2057b8; /* solid */
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    text-align: left;
    z-index: 10000;
  }

  .drawer.open .drawer-panel {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .drawer ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .drawer a {
    display: block;
    padding: 16px 18px;
    background: #2057b8;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: .2px;
    text-align: left;
    font-size: 17px;
    line-height: 1.4;
    border-bottom: 1px solid rgba(255, 255, 255, .15);
  }

  .drawer a:hover,
  .drawer a:focus-visible {
    background: #1a4694;
    outline: none;
  }
}

/* -------- Layout -------- */
main {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto 2rem auto;
  backdrop-filter: blur(5px);
}

.hero-card {
  background: rgba(10, 30, 70, 0.95);
  border-radius: 16px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 0 22px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1.5rem;
  animation: fadeSlideUp 1.2s ease-out forwards;
  text-align: center;
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.hero-description {
  font-size: 0.98rem;
  color: #cfd6e6;
  max-width: 880px;
  margin: 0 auto 1rem auto;
}

.hero-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  justify-content: center;
}

/* -------- Buttons -------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.35rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color .16s ease, transform .12s ease, box-shadow .16s ease, border-color .16s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
  color: #fff;
  box-shadow: 0 8px 18px rgba(5, 17, 54, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(5, 17, 54, 0.45);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 4px 10px rgba(5, 17, 54, 0.4);
}

.btn-outline {
  background: rgba(7, 18, 44, 0.9);
  border-color: rgba(255, 255, 255, 0.22);
  color: #e0e6f0;
}

.btn-outline:hover {
  background: rgba(18, 42, 88, 0.95);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
  color: #e0e6f0;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.09);
}

/* -------- Status text -------- */
.status {
  text-align: center;
  font-size: 0.95rem;
  color: #cfd6e6;
  padding: 0.75rem 0.5rem;
}

/* -------- Cards -------- */
.cr-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 1rem 1rem 1.1rem 1rem;
  margin: 0.7rem 0;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.45);
  border: 1px solid var(--card-border);
  animation: fadeSlideUp 1.1s ease-out forwards;
}

.cr-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.6rem;
}

.cr-header-left {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.cr-icon {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.cr-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: invert(1) brightness(2);
}

.cr-heading-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cr-standard-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #b9c4df;
}

.cr-main-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: #f5f7ff;
}

.cr-subtitle {
  font-size: 0.9rem;
  color: #c0c9e0;
}

/* Help button */
.help-btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #e74c3c;
  background: rgba(192, 57, 43, 0.15);
  color: #ffd7d2;
  cursor: pointer;
  align-self: flex-start;
}

.help-btn:hover {
  background: rgba(231, 76, 60, 0.35);
}

/* -------- Tables (generic card tables) -------- */
.cr-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  background: rgba(2, 12, 36, 0.7);
  border-radius: 10px;
  overflow: hidden;
}

.cr-table th,
.cr-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
  text-align: left;
}

.cr-table th {
  width: 260px;
  font-weight: 700;
  color: #d9e0f5;
  background: rgba(7, 26, 70, 0.9);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.cr-table tr:last-child th,
.cr-table tr:last-child td {
  border-bottom: none;
}

.cr-table input[type="text"],
.cr-table input[type="number"],
.cr-table select,
.cr-table textarea {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #f5f7ff;
  font-size: 0.9rem;
}

.cr-table textarea {
  resize: vertical;
  min-height: 60px;
}

.cr-table input::placeholder,
.cr-table textarea::placeholder {
  color: #9fa8c8;
}

.cr-table input:focus,
.cr-table select:focus,
.cr-table textarea:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 1px rgba(45, 111, 230, 0.6);
}

/* Notes blocks */
.cr-notes {
  margin-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cr-notes label {
  font-size: 0.85rem;
  color: #cfd6ee;
}

.cr-notes textarea {
  min-height: 70px;
  resize: vertical;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #f5f7ff;
  font-size: 0.9rem;
  width: 100%;
}

.cr-notes textarea:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 1px rgba(45, 111, 230, 0.6);
}

.inline-note {
  font-size: 0.78rem;
  color: #b7c2df;
  margin-top: 0.15rem;
}

/* Result badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-low {
  background: rgba(46, 204, 113, 0.18);
  border: 1px solid rgba(46, 204, 113, 0.6);
  color: #2ecc71;
}

.badge-med {
  background: rgba(241, 196, 15, 0.18);
  border: 1px solid rgba(241, 196, 15, 0.7);
  color: #f1c40f;
}

.badge-high {
  background: rgba(231, 76, 60, 0.18);
  border: 1px solid rgba(231, 76, 60, 0.7);
  color: #e74c3c;
}

/* Result block */
.result-block {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.result-block h4 {
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
  color: #f7f9ff;
}

.result-block ul {
  margin-left: 1rem;
  margin-top: 0.2rem;
}

.result-block li {
  margin-bottom: 0.15rem;
}

/* Diagram pre block */
.diagram-pre {
  background: rgba(2, 12, 36, 0.9);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  margin-top: 0.4rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.78rem;
  white-space: pre;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* -------- Bottom card -------- */
.footer-card {
  background: rgba(5, 22, 58, 0.95);
  border-radius: 14px;
  padding: 1rem 1.2rem;
  margin-top: 1.5rem;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
}

.footer-card span {
  font-size: 0.85rem;
  color: #cfd6e6;
}

/* -------- Modal (shared) -------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 30, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10050;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  max-width: 900px;
  max-height: 90vh;
  background: rgba(6, 20, 55, 0.98);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 1.3rem 1.6rem 1.2rem 1.6rem;
  position: relative;
  overflow: auto;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  border-radius: 999px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f5f7ff;
  cursor: pointer;
  font-size: 16px;
}

.modal-close-default {
  background: rgba(255, 255, 255, 0.06);
}

.modal-close-default:hover {
  background: rgba(255, 255, 255, 0.18);
}

.modal-close-red {
  background: #c0392b;
}

.modal-close-red:hover {
  background: #e74c3c;
}

.modal-title {
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 0.6rem;
}

.modal-body {
  font-size: 0.9rem;
  color: #dde4f8;
  line-height: 1.45;
}

.modal-body p {
  margin-bottom: 0.5rem;
}

.modal-body ul {
  margin: 0.2rem 0 0.5rem 1.2rem;
}

.modal-body-pre {
  white-space: pre-line;
}

/* -------- Animations -------- */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -------- Responsive tweaks -------- */
@media (max-width: 700px) {
  .hero-card {
    padding: 1.1rem 1rem;
  }

  .hero-title {
    font-size: 1.6rem;
  }

  .cr-table th {
    width: 190px;
  }
}

/* ----- Order processing: PO + dates on one line ----- */

/* Make the row flex */
#jobs-tabs .form-row-inline-3 {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 0.5rem;
  align-items: flex-end;
}

/* Stop children being forced full-width */
#jobs-tabs .form-row-inline-3 .form-field-inner {
  flex: 0 0 auto !important;
  width: auto !important;
}

/* Fix widths of the three inputs so they fit horizontally */
#jobs-tabs .form-row-inline-3 #job-order-no,
#jobs-tabs .form-row-inline-3 #job-order-date,
#jobs-tabs .form-row-inline-3 #job-due-date {
  width: 11rem !important;
  max-width: 11rem !important;
  box-sizing: border-box;
  flex: 0 0 11rem !important;
}

/* Mobile: stack nicely */
@media (max-width: 700px) {
  #jobs-tabs .form-row-inline-3 {
    flex-wrap: wrap !important;
  }

  #jobs-tabs .form-row-inline-3 .form-field-inner {
    flex: 1 1 100% !important;
  }

  #jobs-tabs .form-row-inline-3 #job-order-no,
  #jobs-tabs .form-row-inline-3 #job-order-date,
  #jobs-tabs .form-row-inline-3 #job-due-date {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 100% !important;
  }
}

/* ----- Sortable table headers ----- */
th.sortable {
  cursor: pointer;
}

th.sortable:hover {
  text-decoration: underline;
}

/* Optional arrow indicators */
th.sortable::after {
  content: "⇅";
  opacity: .4;
  margin-left: 6px;
  font-size: .7em;
}

th.sortable[data-sort-dir="asc"]::after {
  content: "▲";
  opacity: .9;
}

th.sortable[data-sort-dir="desc"]::after {
  content: "▼";
  opacity: .9;
}
