/* ============================================================
   iSteel Stock Mailer — industrial dispatch console
   Brand: orange #ff6900 / wordmark navy, from isteel.au
   Type:  Barlow Condensed (display) · Barlow (body) · IBM Plex Mono (data)
   ============================================================ */

:root {
  --orange:      #ff6900;
  --orange-deep: #d95800;
  --navy:        #133a63;
  --navy-ink:    #0d2440;
  --navy-soft:   #1c4a7c;
  --paper:       #eceef0;
  --panel:       #fbfcfd;
  --ink:         #1b2732;
  --ink-soft:    #51606d;
  --steel:       #c7cfd6;
  --steel-light: #e2e7ea;
  --ok:          #1e7d32;
  --warn:        #8a6100;
  --err:         #b03030;
  --info:        #1c4f9c;

  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body:    "Barlow", "Segoe UI", sans-serif;
  --mono:    "IBM Plex Mono", "Consolas", monospace;

  --hazard: repeating-linear-gradient(
    -45deg,
    var(--orange) 0 14px,
    var(--navy-ink) 14px 28px
  );
}

* { box-sizing: border-box; }

html { scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--body);
  font-size: 15px;
  color: var(--ink);
  /* blueprint-grid paper */
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(19, 58, 99, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19, 58, 99, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ---- hazard stripe across the very top ---- */
.hazard {
  height: 6px;
  background: var(--hazard);
}

/* ============================================================
   Masthead — dark steel, diagonal orange cut like isteel.au
   ============================================================ */
.masthead {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.4rem;
  background:
    repeating-linear-gradient(
      -55deg,
      rgba(255, 255, 255, 0.022) 0 2px,
      transparent 2px 9px
    ),
    linear-gradient(180deg, var(--navy) 0%, var(--navy-ink) 100%);
  color: #fff;
  overflow: hidden;
}
/* the diagonal orange wedge, echoing the website header */
.masthead::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: clamp(120px, 22vw, 300px);
  background:
    repeating-linear-gradient(
      -55deg,
      rgba(255, 255, 255, 0.06) 0 2px,
      transparent 2px 10px
    ),
    linear-gradient(180deg, var(--orange) 0%, var(--orange-deep) 100%);
  clip-path: polygon(38% 0, 100% 0, 100% 100%, 0 100%);
  pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 0.9rem; min-width: 0; }
.brand-mark {
  height: 44px;
  width: auto;
  /* inverted logo PNG is full-width canvas; crop to the roundel */
  object-fit: cover;
  object-position: left center;
  aspect-ratio: 1 / 1;
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-text strong {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.brand-text span {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #ffb27a;
  margin-top: 0.28rem;
  white-space: nowrap;
}

.mast-right {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 1.1rem;
}
.mast-meta {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}
.logout {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  padding: 0.32rem 0.85rem;
  transition: background 0.15s, color 0.15s;
}
.logout:hover { background: #fff; color: var(--navy-ink); }

/* ============================================================
   Tabs — job-card index tabs
   ============================================================ */
.tabs {
  display: flex;
  gap: 0.4rem;
  max-width: 860px;
  width: 100%;
  margin: 1.6rem auto 0;
  padding: 0 1rem;
}
.tab {
  appearance: none;
  border: 1px solid var(--steel);
  border-bottom: 0;
  background: var(--steel-light);
  color: var(--ink-soft);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.02rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 0.55rem 1.15rem 0.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  position: relative;
  top: 1px;
  transition: background 0.12s, color 0.12s;
}
.tab-no {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  color: var(--orange-deep);
}
.tab:hover { background: #fff; color: var(--navy); }
.tab.active {
  background: var(--panel);
  color: var(--navy);
  border-color: var(--steel);
  box-shadow: inset 0 3px 0 var(--orange);
}
.tab.active .tab-no { color: var(--orange); }

/* ============================================================
   Panels — spec-sheet cards with drawing corner ticks
   ============================================================ */
main {
  max-width: 860px;
  width: 100%;
  margin: 0 auto 2.2rem;
  padding: 0 1rem;
  flex: 1;
}
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--steel);
  box-shadow: 0 1px 0 rgba(13, 36, 64, 0.06), 0 10px 24px -18px rgba(13, 36, 64, 0.35);
  padding: 1.5rem 1.7rem 1.7rem;
}
/* engineering-drawing corner marks */
.panel::before,
.panel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
}
.panel::before {
  top: 5px; left: 5px;
  border-top: 2px solid var(--orange);
  border-left: 2px solid var(--orange);
}
.panel::after {
  bottom: 5px; right: 5px;
  border-bottom: 2px solid var(--orange);
  border-right: 2px solid var(--orange);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0 0 1.3rem;
}
.doc-no {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: #fff;
  background: var(--navy);
  padding: 0.28rem 0.5rem;
  flex: none;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.45rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy);
  white-space: nowrap;
}
/* dimension-line rule running to the edge */
.panel-rule {
  flex: 1;
  height: 1px;
  background: var(--steel);
  position: relative;
}
.panel-rule::before,
.panel-rule::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 1px;
  height: 7px;
  background: var(--steel);
}
.panel-rule::before { left: 0; }
.panel-rule::after { right: 0; }

/* ============================================================
   Form fields
   ============================================================ */
.field { display: block; margin: 1.05rem 0 0; }
.field-label,
legend {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--navy);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="datetime-local"],
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
  font-family: var(--body);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--steel);
  border-radius: 0;
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #9aa7b1; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .dropzone:focus-within {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}
input[type="datetime-local"] {
  width: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
}

/* ---- PDF dropzone: the load manifest plate ---- */
.dropzone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.95rem 1.1rem;
  background:
    linear-gradient(180deg, #f4f7f9 0%, #ecf0f3 100%);
  border: 1.5px dashed var(--steel);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--orange); background: #fff; }
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.dz-glyph {
  width: 30px;
  height: 30px;
  fill: var(--navy);
  flex: none;
  opacity: 0.9;
}
.dz-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
#file-name {
  font-family: var(--mono);
  font-size: 0.83rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#file-name.has-file { color: var(--navy); font-weight: 600; }
.dz-sub {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #93a1ac;
}

/* ---- recipients manifest ---- */
fieldset {
  border: 1px solid var(--steel);
  border-radius: 0;
  margin: 1.25rem 0 0;
  padding: 0.75rem 1rem 0.9rem;
  background: #fff;
}
legend {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0;
  padding: 0 0.45rem;
}
legend label.inline {
  margin: 0;
  font-family: var(--body);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-soft);
}
.recipient-list {
  max-height: 230px;
  overflow-y: auto;
  columns: 2;
  column-gap: 1.6rem;
  font-size: 0.9rem;
}
.recipient-list label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 400;
  margin: 0;
  padding: 0.26rem 0.1rem;
  break-inside: avoid;
  border-bottom: 1px dashed var(--steel-light);
}
.r-co {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--navy);
  flex: none;
}
.r-email { color: var(--ink-soft); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; }
.recipient-list::-webkit-scrollbar { width: 10px; }
.recipient-list::-webkit-scrollbar-track { background: var(--steel-light); }
.recipient-list::-webkit-scrollbar-thumb { background: var(--steel); border: 2px solid var(--steel-light); }
.recipient-list::-webkit-scrollbar-thumb:hover { background: var(--orange); }

input[type="checkbox"] {
  accent-color: var(--orange);
  width: 15px;
  height: 15px;
  flex: none;
}

label.inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ink);
}
.schedule-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}

/* ============================================================
   Buttons — press-brake blocks
   ============================================================ */
button[type="submit"], .btn-like {
  display: inline-block;
  margin-top: 1.2rem;
  padding: 0.62rem 1.7rem;
  background: var(--navy);
  color: #fff;
  border: 0;
  border-radius: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.28);
  transition: background 0.13s;
}
button[type="submit"]:hover, .btn-like:hover { background: var(--orange); }
button[type="submit"]:hover { box-shadow: inset 0 -3px 0 var(--orange-deep); }
button[type="submit"]:active, .btn-like:active { transform: translateY(1px); box-shadow: none; }
button[type="submit"]:disabled {
  background: var(--steel);
  color: #fff;
  box-shadow: none;
  cursor: default;
}
.btn-like { font-size: 0.88rem; }

/* ============================================================
   Rows / small forms
   ============================================================ */
.row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin: 0 0 0.9rem;
  flex-wrap: wrap;
}
.row input { flex: 1 1 180px; }
.row button, .row .btn-like { margin-top: 0; }
.import-row { margin-top: 0.2rem; }

.ghost-btn, .danger-btn {
  padding: 0.5rem 1.1rem;
  background: transparent;
  border-radius: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.ghost-btn { color: var(--navy); border: 1.5px solid var(--navy); }
.ghost-btn:hover { background: var(--navy); color: #fff; }
.danger-btn { color: var(--err); border: 1.5px solid var(--err); }
.danger-btn:hover:not(:disabled) { background: var(--err); color: #fff; }
.danger-btn:disabled { color: var(--steel); border-color: var(--steel); cursor: default; }

.search-row { margin-bottom: 0.7rem; }
#contact-search {
  font-family: var(--mono);
  font-size: 0.85rem;
  max-width: 380px;
}
.sel-col { width: 32px; text-align: center; }
.sel-col input { vertical-align: middle; }

/* ============================================================
   Tables — the steel ledger
   ============================================================ */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid var(--steel-light);
  white-space: nowrap;
}
td:nth-child(3) { white-space: normal; } /* subjects can wrap */
th {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--navy);
  border-bottom: 2px solid var(--navy);
}
tbody tr { transition: background 0.1s, box-shadow 0.1s; }
tbody tr:not(.detail-row):hover {
  background: #fff;
  box-shadow: inset 3px 0 0 var(--orange);
}
tr.dispatch-row { cursor: pointer; }
tr.dispatch-row.expanded {
  background: #fff;
  box-shadow: inset 3px 0 0 var(--orange);
}
tr.dispatch-row.expanded td { border-bottom-color: transparent; }

/* ---- job ticket (expanded dispatch details) ---- */
.detail-row td { padding: 0 0 1rem; white-space: normal; }
.ticket {
  border: 1px dashed var(--steel);
  border-left: 3px solid var(--orange);
  background: #fff;
  padding: 0.9rem 1.1rem 1rem;
  margin: 0.2rem 0 0.2rem 0.4rem;
}
.ticket.t-loading {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.t-label {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--navy);
  margin-bottom: 0.15rem;
}
.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem 1.2rem;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.t-block { margin-top: 0.9rem; }
.t-body { margin: 0; font-size: 0.9rem; white-space: pre-wrap; }
.t-recipients {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 1.6rem;
  font-size: 0.85rem;
}
.t-recipients li {
  padding: 0.2rem 0;
  border-bottom: 1px dashed var(--steel-light);
  break-inside: avoid;
}
.t-ids {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  word-break: break-all;
}
.ticket .t-error, p.t-error {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--err);
  margin: 0.9rem 0 0;
}
@media (max-width: 640px) {
  .t-recipients { columns: 1; }
}
#history-table td:first-child,
#history-table td:nth-child(5) {
  font-family: var(--mono);
  font-size: 0.78rem;
}
#history-table td:nth-child(4) {
  font-family: var(--mono);
  font-size: 0.82rem;
  text-align: center;
}
td button {
  border: 1px solid currentColor;
  background: none;
  color: var(--err);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  transition: background 0.12s, color 0.12s;
}
td button:hover { background: var(--err); color: #fff; }
td button.cancel { color: var(--warn); }
td button.cancel:hover { background: var(--warn); color: #fff; }
td button.tpl-edit { color: var(--navy); }
td button.tpl-edit:hover { background: var(--navy); color: #fff; }
td.tpl-body { white-space: normal; color: var(--ink-soft); font-size: 0.85rem; }

select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
  font-family: var(--body);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--steel);
  border-radius: 0;
}
select:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }
.field-hint { display: block; margin-top: 0.35rem; }
.tpl-cancel { margin-top: 1.2rem; margin-left: 0.5rem; }

/* ============================================================
   Status lines & stamps
   ============================================================ */
.status {
  font-family: var(--mono);
  font-size: 0.8rem;
  margin: 0.7rem 0 0;
  min-height: 1.25em;
}
.status.ok { color: var(--ok); }
.status.ok::before { content: "▣ "; }
.status.err { color: var(--err); }
.status.err::before { content: "▲ "; }

/* inspection-stamp badges */
.badge {
  display: inline-block;
  padding: 0.14rem 0.5rem;
  border: 1.5px solid currentColor;
  border-radius: 0;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.66rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  background: transparent;
}
.badge.scheduled { color: var(--warn); }
.badge.sending   { color: var(--info); }
.badge.sent      { color: var(--ok); }
.badge.failed    { color: var(--err); }
.badge.cancelled { color: var(--ink-soft); border-style: dashed; }

.tz-note {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-left: 3px solid var(--orange);
  padding-left: 0.5rem;
}
.tz-footnote {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0.9rem 0 0;
}
.status a.goto-history {
  color: var(--orange-deep);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.status a.goto-history:hover { color: var(--orange); }

/* ============================================================
   Confirmation dialog — the hold ticket
   ============================================================ */
#confirm-dialog {
  border: 1px solid var(--steel);
  border-top: 6px solid transparent;
  border-image: var(--hazard) 1;
  border-radius: 0;
  padding: 1.3rem 1.5rem 1.4rem;
  max-width: 430px;
  width: calc(100vw - 3rem);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 60px -18px rgba(13, 36, 64, 0.55);
}
#confirm-dialog::backdrop {
  background: rgba(13, 36, 64, 0.55);
  backdrop-filter: blur(1.5px);
}
.dialog-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}
.dialog-head .doc-no { background: var(--orange-deep); }
.dialog-head h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy);
}
#confirm-msg {
  margin: 0 0 1.2rem;
  font-size: 0.97rem;
  line-height: 1.5;
}
#confirm-msg strong { color: var(--orange-deep); }
.dialog-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.dialog-actions button {
  margin: 0;
  padding: 0.55rem 1.4rem;
  border: 0;
  border-radius: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
}
#confirm-go {
  background: var(--navy);
  color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.28);
}
#confirm-go:hover { background: var(--orange); box-shadow: inset 0 -3px 0 var(--orange-deep); }
#confirm-go:active { transform: translateY(1px); box-shadow: none; }
.dialog-actions .ghost {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--navy);
}
.dialog-actions .ghost:hover { background: var(--navy); color: #fff; }

/* ============================================================
   Baseplate footer
   ============================================================ */
.baseplate {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.baseplate span:first-child {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
  padding: 0.9rem 1rem 0.7rem;
}
.baseplate-stripe { height: 6px; background: var(--hazard); }

/* ============================================================
   Small screens
   ============================================================ */
@media (max-width: 640px) {
  .masthead { padding: 0.75rem 1rem; }
  .masthead::after { display: none; }
  .mast-meta { display: none; }
  .brand-text strong { font-size: 1.35rem; }
  .brand-mark { height: 38px; }
  .tabs { gap: 0.25rem; padding: 0 0.6rem; margin-top: 1.1rem; }
  .tab { padding: 0.5rem 0.7rem 0.45rem; font-size: 0.92rem; gap: 0.35rem; }
  main { padding: 0 0.6rem; }
  .panel { padding: 1.1rem 1rem 1.3rem; }
  .panel-head h2 { font-size: 1.2rem; }
  .recipient-list { columns: 1; }
}
