/* ============================================================================
   Shared FX Utilities look & feel — matches the Annual Leave app so every
   internal tool feels like one system (same palette, type, buttons, cards,
   tables, banners).
   ============================================================================ */

:root {

  /* Kept for any older rules still referencing these names */
  --card: #ffffff;
  --text: var(--ink);
  --text-muted: var(--grey);
  --success: var(--green);
  --danger: var(--red);
  --warning: var(--amber);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.muted { color: var(--grey); font-size: 0.92em; }

/* ---------- Buttons ---------- */

button, .btn {
  font-family: inherit;
  font-size: 0.95em;
  border-radius: var(--radius);
  border: none;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

button.primary, .btn.primary, .btn-primary {
  background: var(--action);
  border-color: var(--action);
  color: #fff;
}
button.primary:hover, .btn.primary:hover, .btn-primary:hover { background: var(--action-hover); }

.btn-ghost { background: transparent; color: var(--navy); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--grey-light); }

button.danger, .btn-danger { color: var(--red); border-color: var(--red); background: #fff; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Sign-in screen ---------- */

.signin-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 100%);
}

.signin-screen .login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.signin-screen img.logo-large { max-width: 160px; max-height: 70px; margin-bottom: 12px; }
.signin-screen h1 { font-size: 1.1em; margin: 0 0 2px; color: var(--navy); }
.signin-screen h2 { margin: 18px 0 4px; color: var(--ink); }
.signin-screen p { color: var(--grey); }
.signin-screen .btn-block { margin-top: 14px; }
#signin-error { margin-top: 12px; text-align: left; }

/* ---------- Header / top bar ---------- */

header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
}

header.app-header .brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

header.app-header img.logo { max-height: 34px; }

.topbar-title { font-weight: 700; color: var(--navy); }
.topbar-subtitle { font-size: 0.8em; color: var(--grey); }

.account-block {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.9em;
}

.account-block .user-name { color: var(--grey); }

/* ---------- Tabs ---------- */

nav.tab-bar {
  display: flex;
  gap: 4px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  overflow-x: auto;
}

nav.tab-bar button.tab-btn {
  background: none;
  border: none;
  padding: 12px 16px;
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  color: var(--grey);
  border-bottom: 3px solid transparent;
  border-radius: 0;
  white-space: nowrap;
}

nav.tab-bar button.tab-btn:hover { color: var(--navy); }

nav.tab-bar button.tab-btn.active {
  color: var(--action);
  border-bottom-color: var(--action);
  font-weight: 600;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Cards / forms ---------- */

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 { margin-top: 0; font-size: 1em; color: var(--navy); }
.card h3 { font-size: 1em; font-weight: 600; margin: 0 0 10px; color: var(--navy); }

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 14px;
}

.field { flex: 1 1 220px; display: flex; flex-direction: column; gap: 6px; }

.field label { font-size: 0.88em; font-weight: 600; color: #333; }

.field input, .field select, .field textarea {
  font-family: inherit;
  font-size: 0.95em;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.field textarea { resize: vertical; min-height: 70px; }

/* ---------- Tables ---------- */

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}

table.data-table th {
  text-align: left;
  background: var(--grey-light);
  color: #444;
  font-weight: 600;
  padding: 8px 10px;
}

table.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  vertical-align: top;
}

table.data-table tr:last-child td { border-bottom: none; }

/* ---------- Recipient checkboxes ---------- */

.recipient-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 4px 0;
}

.recipient-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95em;
  font-weight: normal;
}

/* ---------- Timesheet ---------- */

.day-block { margin-bottom: 18px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.day-block .day-header {
  background: var(--grey-light);
  padding: 10px 16px;
  font-weight: 600;
  color: var(--navy);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.day-block .day-body { padding: 12px 16px; }
.job-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 10px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.job-row:last-child { border-bottom: none; padding-bottom: 0; }
.job-row .field { flex: 1 1 160px; }
.job-row .remove-job { flex: 0 0 auto; }
.day-total { font-size: 0.9em; color: var(--grey); margin-top: 4px; }

/* ---------- Timesheet claim lines (Round 9) ---------- */

.claims-block { flex: 1 1 100%; background: var(--grey-light); border-radius: 8px; padding: 12px 14px; margin-top: 4px; }
.claims-block > label { display: block; font-size: 0.88em; font-weight: 600; color: #333; margin-bottom: 8px; }
.claims-table { background: #fff; border-radius: 6px; overflow: hidden; margin-bottom: 10px; }
.claim-input-row { margin-bottom: 0; }
.claim-input-row .field { flex: 1 1 200px; }
.claim-edit-btn { margin-right: 6px; }

.attachment-picked {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 0.9em;
  background: #fff;
}
.attachment-picked span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-picked button { flex: 0 0 auto; padding: 4px 10px; font-size: 0.85em; }

/* ---------- Multi-file attachment picker (js/attachments.js) ---------- */

.attachment-picker { display: flex; flex-direction: column; gap: 8px; }
.attachment-list { display: flex; flex-direction: column; gap: 6px; }
.attachment-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 0.9em;
  background: #fff;
}
.attachment-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.attachment-chip-name em { color: var(--grey); font-style: italic; font-weight: normal; }
.attachment-chip button { flex: 0 0 auto; padding: 4px 10px; font-size: 0.85em; }
.attachment-file-input { font-size: 0.9em; }


/* ---------- Stores request line items ---------- */

.line-items-table input, .line-items-table select { width: 100%; }

/* ---------- Checklist (vehicle check) ---------- */

.checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item .item-label { flex: 1; font-size: 0.95em; }
.checklist-item .item-options { display: flex; gap: 8px; }
.checklist-item .item-options button {
  padding: 6px 14px;
  font-size: 0.9em;
}
.checklist-item .item-options button.selected.pass { background: var(--green); color: #fff; border-color: var(--green); }
.checklist-item .item-options button.selected.fail { background: var(--red); color: #fff; border-color: var(--red); }
.checklist-item .item-options button.selected.na { background: var(--grey); color: #fff; border-color: var(--grey); }

/* ---------- Banners ---------- */

.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.92em;
}
.banner.success { background: var(--green-bg); color: var(--green); }
.banner.error { background: var(--red-bg); color: var(--red); }
.banner.info { background: var(--blue-light); color: var(--navy); }
.banner.warning { background: var(--amber-bg); color: var(--amber); }

.hint { font-size: 0.85em; color: var(--grey); }

.section-tagline { font-size: 0.85em; color: var(--grey); font-style: italic; margin: -6px 0 12px; }

.empty-state { color: var(--grey); font-style: italic; padding: 12px 0; }

.section-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---------- My Daily Updates (Round 19) ---------- */

.link-btn {
  background: none;
  border: none;
  color: var(--navy);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 0.92em;
}
.link-btn:hover { color: var(--navy-dark); }

.detail-field { margin-bottom: 12px; }
.detail-label { font-size: 0.82em; color: var(--grey); margin-bottom: 2px; }
.detail-value { font-size: 0.95em; color: var(--ink); white-space: pre-wrap; }

.detail-linked-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 10px;
  background: var(--grey-light);
}

@media (max-width: 640px) {
  header.app-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  main { padding: 14px; }
}


/* ---------- Reinstatement status picker (Round 13) ---------- */
/* Single-select "radio" behaviour built the same way the Vehicle Check
   pass/fail/n-a pills already work (plain buttons toggling a "selected"
   class), rather than native <input type="radio">, so it can share the
   same visual language as the rest of the app. */

.reinstatement-picker { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.reinstatement-picker button {
  padding: 8px 14px;
  font-size: 0.9em;
  border-radius: 999px;
}
.reinstatement-picker button.selected[data-status="N/A"] {
  background: #fff; color: var(--text); border-color: var(--navy); font-weight: 700;
}
.reinstatement-picker button.selected[data-status="Permanent Reinstatement"] {
  background: var(--green); color: #fff; border-color: var(--green);
}
.reinstatement-picker button.selected[data-status="Interim Reinstatement"] {
  background: var(--orange); color: #fff; border-color: var(--orange);
}
.reinstatement-picker button.selected[data-status="Requires Reinstatement"] {
  background: var(--red); color: #fff; border-color: var(--red);
}

/* ---------- POI - Daily Completions (Round 13, FRM-278) ---------- */

.poi-item-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 10px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.poi-item-row:last-child { border-bottom: none; padding-bottom: 0; }
.poi-item-row .field { flex: 1 1 140px; }
.poi-item-row .remove-poi-item { flex: 0 0 auto; }
.poi-item-number { font-weight: 700; color: var(--navy); flex: 0 0 28px; align-self: center; }

/* The inline POI section embedded in Daily Update behind its tickbox —
   a visually distinct sub-card so it's clear it's a separate, optional
   block of the form rather than more Daily Update fields. */
.poi-embed-toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.poi-embed-section { background: var(--grey-light); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-top: 4px; margin-bottom: 14px; }
.poi-embed-section .card { margin-bottom: 0; }

/* ---------- POI / Reinstatement Notification (Round 15 rebuild) ----------
   Both forms are fixed-size grids (matching the physical Excel templates'
   own row/slot counts exactly, per Chris's decision), so there's no
   add/remove row chrome here — just compact grid/table layouts. */

.poi-engineers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.poi-engineer-slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--grey-light);
}
.poi-engineer-slot .field { flex: 1 1 auto; }

.poi-table-wrap, .reinstatement-table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.poi-table, .reinstatement-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px;
}
.poi-table th, .reinstatement-table th {
  background: var(--grey-light);
  color: var(--navy);
  font-size: 0.82em;
  font-weight: 600;
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.poi-table td, .reinstatement-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}
.poi-table tr:last-child td, .reinstatement-table tr:last-child td { border-bottom: none; }
.poi-table input, .reinstatement-table input, .reinstatement-table select {
  width: 100%;
  min-width: 90px;
  font-family: inherit;
  font-size: 0.88em;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.poi-row-num {
  color: var(--grey);
  font-size: 0.85em;
  text-align: center;
  width: 28px;
}
.reinstatement-tick-cell { text-align: center; }
.reinstatement-tick-cell input[type="checkbox"] { width: auto; min-width: 0; }

/* ---------- POI rows / Reinstatement sites shown one at a time (Round 17) ----------
   Both forms are still capped at the physical template's own row/slot
   count (26+26 for POI, 20 for Reinstatement sites) — Round 17 only
   changed how many of those are RENDERED at once: one to start, with an
   "+ Add" button revealing the next, rather than all of them up front. */
.poi-table-actions { display: flex; gap: 10px; align-items: center; margin: -6px 0 16px; }

.reinstatement-sites-list { margin-bottom: 10px; }
.reinstatement-site-block {
  background: var(--grey-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.reinstatement-site-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.reinstatement-site-header strong { color: var(--navy); }
.reinstatement-tick-row { gap: 18px; align-items: center; }
.reinstatement-tick-label { display: flex; align-items: center; gap: 6px; font-size: 0.9em; font-weight: 500; }
.reinstatement-tick-label input[type="checkbox"] { width: auto; }

/* Per-site Full/Interim Reinstatement picker (Round 17 — moved here from
   a single top-of-form field) reuses the same button/.selected mechanism
   as the Daily Update Reinstatement status picker above, with its own
   colour pair keyed on data-type rather than data-status. */
.reinstatement-picker button.selected[data-type="Full Reinstatement"] {
  background: var(--green); color: #fff; border-color: var(--green);
}
.reinstatement-picker button.selected[data-type="Interim Reinstatement"] {
  background: var(--orange); color: #fff; border-color: var(--orange);
}

/* The Users tab, when Access Control is the thing actually deciding.
   Amber rather than red: nothing is broken and nothing has gone wrong —
   the list is simply not the control any more, and somebody about to
   tick a box needs to know that before they tick it. */
.users-not-in-charge {
  border-left: 4px solid var(--amber);
  background: var(--amber-bg);
}
.users-not-in-charge h2 { color: var(--amber); }
