/* =============================================================
   FORM KIT - tokens and components for the data-entry screens
   (Production orders, Settings and their modals).

   Flat surfaces, one accent, colour reserved for status. Every
   value comes from a --hp-* token so the screens stay consistent
   with each other; screens outside this kit keep base.css tokens.
   ============================================================= */

:root {
  --hp-surface: #0f1829;
  --hp-surface-2: #131f35;
  --hp-field: #0a1222;
  --hp-border: #22304a;
  --hp-border-strong: #3b4d6b;
  --hp-text: #e7e9ed;
  --hp-text-2: #aab4c3;
  --hp-text-3: #8a96a8;
  --hp-accent: #2f6fe4;
  --hp-accent-hover: #3d7cf0;
  --hp-accent-fg: #ffffff;
  --hp-accent-soft: rgba(47, 111, 228, 0.16);
  --hp-accent-text: #8db4ff;
  --hp-ok: #4ade80;
  --hp-ok-soft: rgba(74, 222, 128, 0.12);
  --hp-warn: #f5a524;
  --hp-warn-soft: rgba(245, 165, 36, 0.13);
  --hp-danger: #f87171;
  --hp-danger-soft: rgba(248, 113, 113, 0.13);
  --hp-muted-soft: rgba(255, 255, 255, 0.06);
  --hp-focus: rgba(95, 150, 255, 0.35);
  --hp-radius: 8px;
  --hp-radius-lg: 12px;
}

/* ---------- Page ---------- */
.hp-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  color: var(--hp-text);
  font-size: 14px;
  line-height: 1.45;
}

.hp-page-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--hp-text);
}

.hp-page-head p {
  margin: 4px 0 0;
  color: var(--hp-text-2);
}

.hp-num { font-variant-numeric: tabular-nums; }

.hp-sr-only,
.hp-hidden-control {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

/* ---------- Card ---------- */
.hp-card {
  background: var(--hp-surface);
  border: 1px solid var(--hp-border);
  border-radius: var(--hp-radius-lg);
}

.hp-card__head {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hp-card__head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--hp-text);
}

.hp-card__body { padding: 0 24px; }

.hp-card__foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 24px;
  border-top: 1px solid var(--hp-border);
  background: var(--hp-surface-2);
  border-radius: 0 0 var(--hp-radius-lg) var(--hp-radius-lg);
}

/* ---------- Field groups ---------- */
.hp-fs {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 0;
  border-top: 1px solid var(--hp-border);
}

.hp-fs:first-child { border-top: 0; }

.hp-fs__title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hp-text-3);
}

.hp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.hp-grid--fill { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.hp-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.hp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  position: relative;
}

.hp-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--hp-text);
}

.hp-req { color: var(--hp-danger); margin-left: 2px; }

.hp-help {
  font-size: 12px;
  color: var(--hp-text-3);
}

/* ---------- Inputs ---------- */
.hp-input,
.hp-select {
  height: 40px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--hp-border-strong);
  border-radius: var(--hp-radius);
  background: var(--hp-field);
  color: var(--hp-text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea.hp-input {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
}

.hp-input::placeholder { color: var(--hp-text-3); }

.hp-input:hover:not([readonly]):not(:disabled),
.hp-select:hover:not(:disabled) { border-color: var(--hp-text-3); }

.hp-input:focus,
.hp-select:focus {
  border-color: var(--hp-accent);
  box-shadow: 0 0 0 3px var(--hp-focus);
}

/* Read-only and disabled fields look like values, not like boxes waiting for input. */
.hp-input[readonly],
.hp-input:disabled {
  background: var(--hp-surface-2);
  border-style: dashed;
  color: var(--hp-text-2);
  cursor: not-allowed;
}

.hp-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a96a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.hp-select option { background: var(--hp-surface); color: var(--hp-text); }

.hp-input-wrap { position: relative; }

.hp-input-wrap .hp-input--icon-left { padding-left: 36px; }
.hp-input-wrap .hp-input--suffix { padding-right: 56px; }

.hp-input-wrap__icon,
.hp-input-wrap__suffix {
  position: absolute;
  top: 0;
  height: 40px;
  display: flex;
  align-items: center;
  color: var(--hp-text-3);
  pointer-events: none;
}

.hp-input-wrap__icon { left: 12px; }
.hp-input-wrap__icon svg { width: 16px; height: 16px; }
.hp-input-wrap__suffix { right: 12px; font-size: 13px; }

/* ---------- Buttons ---------- */
.hp-btn {
  height: 40px;
  padding: 0 16px;
  border-radius: var(--hp-radius);
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.hp-btn svg { width: 16px; height: 16px; flex: none; }

.hp-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--hp-focus); }

.hp-btn--primary { background: var(--hp-accent); color: var(--hp-accent-fg); }
.hp-btn--primary:hover:not(:disabled) { background: var(--hp-accent-hover); }

.hp-btn--secondary {
  background: transparent;
  border-color: var(--hp-border-strong);
  color: var(--hp-text);
}
.hp-btn--secondary:hover:not(:disabled) { background: var(--hp-muted-soft); }

.hp-btn--ghost { background: transparent; color: var(--hp-text-2); }
.hp-btn--ghost:hover:not(:disabled) { background: var(--hp-muted-soft); color: var(--hp-text); }

.hp-btn--danger { background: transparent; color: var(--hp-danger); }
.hp-btn--danger:hover:not(:disabled) { background: var(--hp-danger-soft); }

.hp-btn--solid-danger { background: #dc2626; color: #fff; }
.hp-btn--solid-danger:hover:not(:disabled) { background: #ef4444; }

.hp-btn--run { background: var(--hp-ok-soft); color: var(--hp-ok); }
.hp-btn--run:hover:not(:disabled) { background: rgba(74, 222, 128, 0.2); }

.hp-btn--sm { height: 32px; padding: 0 10px; font-size: 13px; }

.hp-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Segmented control and chips ---------- */
.hp-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--hp-border);
  border-radius: 10px;
  background: var(--hp-field);
}

.hp-seg button {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--hp-text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.hp-seg button:hover { color: var(--hp-text); }

.hp-seg button.is-active {
  background: var(--hp-surface-2);
  color: var(--hp-text);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--hp-border-strong);
}

.hp-seg--lg button { height: 36px; padding: 0 18px; font-size: 14px; }

.hp-fs > .hp-seg { align-self: flex-start; }

.hp-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.hp-chip {
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--hp-border-strong);
  background: transparent;
  color: var(--hp-text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.hp-chip:hover { color: var(--hp-text); }

.hp-chip.is-active {
  background: var(--hp-text);
  border-color: var(--hp-text);
  color: var(--hp-surface);
  font-weight: 600;
}

/* ---------- Status pills ---------- */
.hp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.hp-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.hp-pill--running { background: var(--hp-ok-soft); color: var(--hp-ok); }
.hp-pill--pending { background: var(--hp-muted-soft); color: var(--hp-text-2); }
.hp-pill--stopped { background: var(--hp-warn-soft); color: var(--hp-warn); }
.hp-pill--completed { background: var(--hp-accent-soft); color: var(--hp-accent-text); }
.hp-pill--cancelled { background: var(--hp-muted-soft); color: var(--hp-text-3); }

.hp-role {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ---------- Tables ---------- */
.hp-table-box {
  overflow-x: auto;
  border-top: 1px solid var(--hp-border);
}

table.hp-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

table.hp-table th {
  padding: 10px 12px;
  background: var(--hp-surface-2);
  border-bottom: 1px solid var(--hp-border);
  color: var(--hp-text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

table.hp-table td {
  padding: 12px;
  border-bottom: 1px solid var(--hp-border);
  color: var(--hp-text);
  font-size: 14px;
  font-weight: 400;
  vertical-align: middle;
}

table.hp-table th:first-child,
table.hp-table td:first-child { padding-left: 24px; }

table.hp-table th:last-child,
table.hp-table td:last-child { padding-right: 24px; }

table.hp-table tbody tr:hover td { background: var(--hp-surface-2); }

table.hp-table .hp-c { text-align: center; }
table.hp-table .hp-r { text-align: right; }

.hp-cell-sub {
  font-size: 12px;
  color: var(--hp-text-3);
}

.hp-empty-cell {
  text-align: center !important;
  color: var(--hp-text-3) !important;
  padding: 32px 12px !important;
}

/* ---------- Progress ---------- */
.hp-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hp-progress__bar {
  flex: 1;
  height: 6px;
  min-width: 60px;
  background: var(--hp-muted-soft);
  border-radius: 999px;
  overflow: hidden;
}

.hp-progress__bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--hp-accent);
}

.hp-progress--done .hp-progress__bar span { background: var(--hp-ok); }

.hp-progress__pct {
  min-width: 44px;
  text-align: right;
  font-size: 12px;
  color: var(--hp-text-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- Table footer and pagination ---------- */
.hp-table-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 24px;
  font-size: 13px;
  color: var(--hp-text-3);
}

.hp-pagination {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hp-pagination .page-link,
.hp-pagination .paginate-btn {
  min-width: 32px;
  width: auto;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--hp-radius);
  border: 1px solid var(--hp-border);
  background: transparent;
  color: var(--hp-text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  box-shadow: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hp-pagination .page-link:hover,
.hp-pagination .paginate-btn:hover {
  color: var(--hp-text);
  background: var(--hp-muted-soft);
  border-color: var(--hp-border-strong);
}

.hp-pagination .page-link.active,
.hp-pagination .paginate-btn.active {
  background: var(--hp-accent);
  border-color: var(--hp-accent);
  color: var(--hp-accent-fg);
  font-weight: 600;
}

.hp-pagination .page-link.disabled,
.hp-pagination .paginate-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Modals that hold forms ---------- */
.hp-modal-card {
  background: var(--hp-surface) !important;
  border: 1px solid var(--hp-border-strong) !important;
  border-radius: var(--hp-radius-lg) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5) !important;
}

.hp-modal-card .alarm-modal-title {
  color: var(--hp-text);
  font-size: 16px;
  font-weight: 700;
}

.hp-modal-card .alarm-modal-header { border-bottom-color: var(--hp-border); }

.hp-modal-card .alarm-modal-footer {
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--hp-border);
}
