/* ==========================================================================
   Base & Layout (Wienerberger UK Default Theme + CSS Variables for Custom Themes)
   ========================================================================== */
:root {
  --red: #d51317;
  --top-bg: #1d1d1b;
  --top-tx: #ffffff;
  --btn: #d51317;
  --btn-tx: #ffffff;
  --bg: #f5f4f2;
  --card: #ffffff;
  --tx: #1d1d1b;
  --mut: #666562;
  --line: #dcdad6;
  --head: #efedea;
  --link: #d51317;
  --hov: #f9f8f6;
  --grey: #2d2d2b;
  --radius: 2px;
  --font: "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

.top {
  background: var(--top-bg);
  color: var(--top-tx);
  border-bottom: 4px solid var(--red);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.top h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.crumb-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: var(--top-tx);
  letter-spacing: 0.02em;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  background: transparent;
  color: var(--top-tx);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 14px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .2);
  filter: none;
}

/* ---------- Profile Icon & Dropdown Menu ---------- */
.profile-menu-wrap {
  position: relative;
  margin-left: 4px;
}

.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .1);
  color: var(--top-tx);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  margin: 0;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.profile-btn:hover {
  background: rgba(255, 255, 255, .18);
  border-color: var(--red);
  filter: none;
}

.profile-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.profile-chevron {
  font-size: 11px;
  opacity: .85;
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 240px;
  background: var(--card);
  color: var(--tx);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
  padding: 6px 0;
  z-index: 200;
}

.profile-info {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.profile-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--tx);
}

.profile-role {
  font-size: 11px;
  color: var(--mut);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: var(--tx);
  border: 0;
  border-radius: 0;
  padding: 10px 14px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}

.dropdown-item:hover {
  background: var(--hov);
  color: var(--red);
  filter: none;
}

.dropdown-item.danger:hover {
  background: #fdecec;
  color: #c62828;
}

.dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.wrap {
  padding: 20px 24px;
  max-width: 1440px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--red);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  margin: 40px auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .05);
}

.card.wide {
  max-width: 560px;
}

.card h2 {
  margin-top: 0;
  color: var(--tx);
  font-weight: 700;
  letter-spacing: -0.01em;
}

label {
  display: block;
  margin: 12px 0 4px;
  font-weight: 600;
  font-size: 13px;
}

input, select, textarea, button {
  font: inherit;
  color: var(--tx);
  box-sizing: border-box;
}

input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(213, 19, 23, .12);
}

button {
  background: var(--btn);
  border: 1px solid transparent;
  color: var(--btn-tx);
  border-radius: var(--radius);
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.01em;
  margin-top: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .1s ease, filter .18s ease;
}

button:hover:not(:disabled) {
  filter: brightness(0.92);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .12);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.err {
  color: #d51317;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.hidden { display: none; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.m-0 { margin: 0 !important; }
.mt-4 { margin-top: 4px !important; }
.mt-8 { margin-top: 8px !important; }
.mt-12 { margin-top: 12px !important; }
.mt-16 { margin-top: 16px !important; }
.mb-6 { margin-bottom: 6px !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.w-auto { width: auto !important; }
.w-fit { width: fit-content !important; }
.mut { color: var(--mut); }
.mut-sm { color: var(--mut); font-size: 13px; }
.mut-xs { color: var(--mut); font-size: 12px; }
.btn-grey { background: #5a5a58 !important; color: #fff !important; }
.btn-danger { background: #c62828 !important; color: #fff !important; border-color: #c62828 !important; }
.inline-check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; white-space: nowrap; }
.inline-check input { width: auto; }
.row-wrap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ra-link { color: var(--link); cursor: pointer; text-decoration: underline; margin-right: 8px; font-weight: 600; }

/* ==========================================================================
   Filters, Tabs & Risk Register
   ========================================================================== */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0 16px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 16px;
}

.tab {
  background: var(--head);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 9px 18px;
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  color: var(--mut);
  font-weight: 500;
  margin-top: 0;
}

.tab.on {
  background: var(--card);
  color: var(--red);
  font-weight: 700;
  border-top: 3px solid var(--red);
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .03);
}

.reg {
  width: 100%;
  border-collapse: collapse;
}

.reg th {
  background: var(--grey);
  color: #fff;
  border-bottom: 3px solid var(--red);
  padding: 11px 10px;
  cursor: pointer;
  user-select: none;
  text-align: left;
  font-size: 13px;
  letter-spacing: 0.01em;
}

.reg td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.reg tbody tr {
  cursor: pointer;
  transition: background .1s ease;
}

.reg tbody tr:nth-child(even) {
  background: var(--hov);
}

.reg tbody tr:hover {
  background: rgba(213, 19, 23, .05);
}

.reg .sr th {
  background: var(--head);
  border-bottom: 1px solid var(--line);
  padding: 6px;
}

.sr input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--card);
}

.id {
  color: var(--link);
  font-weight: 700;
}

.rfc {
  text-align: center;
  font-weight: 700;
  color: #000;
}

.pg {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  color: var(--mut);
}

.pg button {
  padding: 6px 12px;
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--tx);
  margin-top: 0;
}

/* ==========================================================================
   Assessment Sheet & PPE
   ========================================================================== */
.tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 4px 0 12px;
}

.tools button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--tx);
  cursor: pointer;
  border-radius: var(--radius);
  margin: 0;
}

.tools button:hover {
  border-color: var(--red);
  color: var(--red);
  filter: none;
}

.tools .dg {
  background: #c62828;
  color: #fff !important;
  border-color: #c62828 !important;
  margin-left: auto;
}

.sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  max-width: none;
  margin: 0 auto 16px;
  overflow-x: auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .04);
}

.sheet table {
  border: 1px solid var(--line);
  width: 100%;
  border-collapse: collapse;
}

.sheet td, .sheet th {
  border: 1px solid var(--line);
  padding: 5px 7px;
  vertical-align: top;
}

.banner {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  border: 1px solid var(--line);
  margin-bottom: 0;
  background: var(--card);
}

.banner div {
  padding: 20px 10px;
  text-align: center;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner .t {
  background: var(--red);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.banner-logo {
  height: 38px;
  max-width: 100%;
  object-fit: contain;
}

.print-logo {
  height: 30px;
  max-width: 100%;
  object-fit: contain;
}

.l {
  background: var(--head);
  color: var(--tx);
  font-weight: 600;
  text-align: center;
  vertical-align: middle !important;
  white-space: nowrap;
}

.sheet input, .sheet textarea, .sheet select {
  width: 100%;
  box-sizing: border-box;
  border: 0;
  background: transparent;
  padding: 4px;
}

.sheet h2 {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  margin: 20px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tx);
  border-bottom: 2px solid var(--red);
  padding-bottom: 4px;
}

.hz th {
  background: var(--grey);
  color: #fff;
  text-align: center;
  font-size: 12px;
}

.hz td.n {
  text-align: center;
  vertical-align: middle;
  width: 46px;
  min-width: 46px;
}

.hz td.rf {
  text-align: center;
  vertical-align: middle;
  font-weight: 700;
  width: 40px;
  color: #000;
}

.hz textarea {
  min-width: 190px;
  font-size: 12px;
}

.sm {
  background: var(--btn);
  color: var(--btn-tx);
  border: 1px solid transparent;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 8px;
}

.x {
  border: 0;
  background: none;
  color: var(--red);
  cursor: pointer;
  font-size: 18px;
}

.add {
  display: flex;
  gap: 6px;
  margin: 6px 0;
}

.add input {
  flex: 1;
}

.hz select[data-lib] {
  display: block;
  min-width: 190px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  margin-bottom: 4px;
}

.hz td {
  min-width: 120px;
  vertical-align: top;
}

.add select {
  width: auto;
}

.pa {
  background: var(--card);
  color: var(--mut);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 6px;
  cursor: pointer;
  font-weight: 500;
}

.pa.on {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.pab {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.ppe-g {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}

.ppe {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  background: var(--card);
  font-weight: 400;
  margin: 0;
}

.ppe.on {
  border-color: var(--red);
  background: #fdecec;
}

.ppe .ic {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1f4e9c;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.ppe input {
  display: none;
}

.ppg {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  border-top: 1px solid var(--line);
}

.ppt {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: center;
}

.ppt img {
  width: 56px;
  height: 56px;
  display: block;
  margin: 0 auto 8px;
}

.ppt > label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-weight: 500;
  margin: 0;
  color: var(--tx);
  font-size: 14px;
}

.ppt input, .pps input {
  width: auto;
}

.pps {
  text-align: left;
  font-size: 12px;
  margin-top: 6px;
  color: var(--mut);
}

.pps label {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-weight: 400;
  margin: 2px 0;
}

.ra-details {
  margin-top: 14px;
}

.ra-details summary {
  cursor: pointer;
  font-weight: 700;
  text-align: center;
  color: var(--mut);
}

.guidance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.guidance-card {
  border: 1px solid var(--line);
}

.guidance-head {
  background: var(--grey);
  color: #fff;
  text-align: center;
  padding: 8px;
  font-size: 13px;
}

.guidance-list {
  margin: 6px 0;
  padding-left: 20px;
  font-size: 12px;
}

/* ==========================================================================
   Home, Workflow Badges, Admin & Print
   ========================================================================== */
.home-wrap {
  max-width: 660px;
  margin: 24px auto;
  text-align: center;
}

.home-logo {
  max-width: 420px;
  width: 100%;
  max-height: 110px;
  object-fit: contain;
  margin-bottom: 10px;
}

.home-user {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--mut);
  margin-bottom: 20px;
  text-transform: uppercase;
}

.home-actions {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.act-legend {
  margin: 0 0 6px;
  font-size: 12px;
}

.act-legend span {
  padding: 2px 8px;
  margin-right: 4px;
  border-radius: var(--radius);
}

.act-over { background: #fde2e1; }
.act-soon { background: #fff1c7; }
.act-ok { background: #e3f6e3; }
.act-none { background: #f3f3f3; }

.act-scroll {
  max-height: 360px;
  overflow: auto;
}

.ok-msg {
  color: #1b5e20;
  margin: 0;
}

.big {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 20px 22px;
  font-size: 16px;
  text-align: left;
  background: var(--card);
  color: var(--tx);
  border: 1px solid var(--line);
  border-left: 5px solid var(--red);
  border-radius: var(--radius);
  cursor: pointer;
  margin: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
  transition: border-color .18s ease, box-shadow .18s ease, transform .15s ease;
}

.big-body {
  flex: 1;
}

.big-arrow {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--hov);
  border: 1px solid var(--line);
  color: var(--tx);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}

.big:hover:not(:disabled) {
  border-color: var(--red);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
  transform: translateY(-2px);
  filter: none;
}

.big:hover:not(:disabled) .big-arrow {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  transform: translateX(3px);
}

.big small {
  color: var(--mut);
  font-weight: 400;
  font-size: 13px;
}

.big:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.bdg {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-right: 6px;
}

.bdg.draft { background: #6c757d; }
.bdg.published { background: #2e7d32; }
.bdg.archived { background: #c62828; }

.arch-banner {
  background: #fde4e3;
  border: 1px solid #d9534f;
  color: #8b1a17;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-weight: 600;
}

.sig-tbl tr.rh-on td {
  background: #fff8e1;
}

.tools .wfb {
  margin: 0 6px 0 0;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 0;
  color: #fff !important;
  cursor: pointer;
  font-weight: 600;
  background: var(--btn);
}

.tools .wfb.ok { background: #2e7d32; }
.tools .wfb.warn { background: #b26a00; }

.oi {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}

.oi:hover {
  background: var(--hov);
}

.hs {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 16px;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .03);
}

.hs h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.due-over { color: #d51317; font-weight: 700; }
.due-soon { color: #b26a00; font-weight: 700; }

.reg th[data-sort] { cursor: pointer; }

.ppd-t {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 8px;
  margin: 4px 0;
  text-align: center;
  font-size: 12px;
  color: var(--mut);
}

.ppd-t img {
  width: 50px;
  height: 50px;
}

.ppd-c {
  field-sizing: content;
  min-height: 320px;
}

.admin-user-form {
  background: var(--hov);
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 30px;
  display: grid;
  gap: 10px;
  max-width: 600px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.admin-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.acc-box {
  border: 1px solid var(--line);
  border-left: 6px solid var(--red);
  margin: 12px 0;
  border-radius: var(--radius);
  background: var(--card);
}

.acc-sum {
  cursor: pointer;
  padding: 10px 12px;
  background: var(--head);
}

.acc-body {
  padding: 8px 12px 12px;
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 14px;
}

.logo-preview {
  border: 1px solid var(--line);
  padding: 14px;
  max-width: 520px;
  background: #fff;
  text-align: center;
  border-radius: var(--radius);
}

.logo-preview img {
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
}

.arch-pre {
  white-space: pre-wrap;
  margin: 0;
  font: inherit;
  background: var(--hov);
  padding: 8px;
}

/* ---------- Theme Customiser Controls ---------- */
.theme-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 18px;
}

.theme-preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  color: var(--tx);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.theme-preset-btn:hover {
  border-color: var(--red);
  filter: none;
}

.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .2);
  display: inline-block;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  max-width: 920px;
  margin-top: 10px;
}

.theme-field {
  background: var(--hov);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.theme-field label {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--mut);
}

.color-pick-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-pick-row input[type="color"] {
  width: 42px;
  height: 34px;
  padding: 2px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
}

.color-pick-row input[type="text"] {
  flex: 1;
  font-family: monospace;
  font-size: 13px;
}

#admin-members td { padding: 6px 5px; }
#admin-members th { padding: 8px 6px; }
#admin-members td:first-child { word-break: break-all; min-width: 150px; }
#admin-members [data-pf] { padding: 6px; }
#admin-members [data-pf="first_name"], #admin-members [data-pf="surname"] { min-width: 100px; }
#admin-members [data-pf="job_title"], #admin-members [data-pf="department"] { min-width: 120px; }
#admin-members [data-pf="site"] { min-width: 130px; }
#admin-members [data-pf="role"], #admin-members [data-pf="status"] { min-width: 95px; }
#admin-members [data-pf="reports_to"] { min-width: 150px; }

.tab .tc {
  display: flex;
  gap: 3px;
  justify-content: center;
  margin-top: 4px;
}

.tab .tc b {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.tab .tc .g { background: #4caf50; }
.tab .tc .a { background: #f0ad4e; }
.tab .tc .r { background: #d9534f; }

#print-area { display: none; }

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing { background: #fff !important; }
  body.printing #print-area { display: block; }
  #print-area * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-area .sheet.pr { max-width: none; border: 0; padding: 0; margin: 0; overflow: visible; page-break-after: always; break-after: page; font-size: 10.5px; box-shadow: none; }
  #print-area .sheet.pr:last-child { page-break-after: auto; break-after: auto; }
  #print-area tr, #print-area img { page-break-inside: avoid; break-inside: avoid; }
  #print-area .hz thead { display: table-header-group; }
  #print-area .hz td { min-width: 0; }
  #print-area .banner div { padding: 10px; }
  #print-area .banner .t { font-size: 24px; }
  #print-area details { display: block; }
}

#print-area .pt { white-space: pre-wrap; overflow-wrap: anywhere; }
#print-area .p-hz { table-layout: fixed; }
#print-area .p-hz td, #print-area .p-hz th { min-width: 0; font-size: 10px; padding: 3px; }
#print-area .p-pa { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px; }
#print-area .p-pa span { padding: 3px 8px; border: 1px solid var(--line); border-radius: var(--radius); }
#print-area .p-pa span.on { background: var(--red); color: #fff; border-color: var(--red); }
#print-area .p-ppe { display: inline-block; width: 46%; margin: 3px 1%; font-size: 10px; }
#print-area .p-ppe img { width: 44px; height: 44px; }
#print-area .p-foot { margin-top: 6px; font-size: 9px; color: #777; text-align: right; }
#print-area .p-warn { background: #d9534f; color: #fff; text-align: center; font-weight: 700; padding: 6px; margin-bottom: 6px; }
#print-area .sig-tbl td { height: 38px; }

/* ==========================================================================
   Signatures & Signature Matrix
   ========================================================================== */
.sig-img { height: 44px; max-width: 220px; background: #fff; display: block; }
.sig-meta { font-size: 12px; color: var(--mut); }
.sig-decl { border: 1px solid var(--line); padding: 8px 10px; margin-bottom: 0; border-bottom: 0; }
.sig-decl p { font-size: 12px; color: var(--mut); margin: 4px 0 0; }
.sig-tbl { width: 100%; border-collapse: collapse; }
.sig-tbl th { background: var(--grey); color: #fff; border-bottom: 2px solid var(--red); text-align: left; padding: 7px 8px; font-size: 13px; }
.sig-tbl td { border: 1px solid var(--line); padding: 4px 8px; height: 44px; }
.sig-ov { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.sig-dlg { background: var(--card); border-top: 4px solid var(--red); border-radius: var(--radius); padding: 18px; width: 100%; max-width: 560px; text-align: left; max-height: 100%; overflow: auto; }
.sig-dlg h3 { margin: 0 0 8px; padding-right: 36px; }
.sig-dlg { position: relative; }
.sig-dlg .dlg-x { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--mut); font-size: 18px; line-height: 32px; cursor: pointer; }
.sig-dlg .dlg-x:hover, .sig-dlg .dlg-x:focus-visible { background: var(--head); color: var(--tx); }
.sig-dlg * { box-sizing: border-box; }
.sig-dlg canvas { width: 100%; height: 180px; border: 1px dashed var(--line); background: #fff; touch-action: none; display: block; margin: 10px 0; }
.sig-dlg .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sig-dlg .row button { width: auto; margin: 0; }
.sig-dlg label { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.sig-dlg label input { width: auto; margin-top: 3px; }
.mx-filters { display: flex; gap: 10px; flex-wrap: wrap; max-width: 640px; }
.mx-filters > div { flex: 1; min-width: 200px; }
.mx-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); }
.mx-tbl { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.mx-tbl th, .mx-tbl td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 5px 8px; white-space: nowrap; }
.mx-tbl thead th { position: sticky; top: 0; background: var(--head); z-index: 2; vertical-align: top; text-align: center; }
.mx-tbl .mx-name { position: sticky; left: 0; background: var(--card); z-index: 1; text-align: left; min-width: 180px; }
.mx-tbl thead .mx-name { z-index: 3; background: var(--head); }
.mx-desc { white-space: normal; min-width: 120px; max-width: 160px; font-weight: 400; font-size: 12px; margin: 2px auto; }
.mx-tbl tr.user td { border-top: 2px solid var(--line); }
/* hierarchy view: account holders bold + shaded by level, a strong line above each top-level group, team members lighter */
.mx-tree .tree { display: flex; align-items: flex-start; gap: 6px; }
.mx-tree .tree-arm { color: var(--mut); font-weight: 400; }
.mx-tree tr.user .tree-name { font-weight: 700; }
.mx-tree tr.user.lvl-0 td.mx-name { background: var(--head); }
.mx-tree tr.user.lvl-0 td { border-top: 3px solid var(--grey); }
.mx-tree tr.user.lvl-1 td.mx-name { background: color-mix(in srgb, var(--head) 60%, var(--card)); }
.mx-tree tr.user.lvl-2 td.mx-name, .mx-tree tr.user.lvl-3 td.mx-name { background: color-mix(in srgb, var(--head) 30%, var(--card)); }
.mx-tree tr.tm .tree-name { color: var(--tx); }
.team-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 7px; border-radius: 999px; background: var(--grey); color: #fff; vertical-align: 1px; }
.mx-col a { color: var(--link); cursor: pointer; text-decoration: underline; }
.mx-mail { font-size: 11px; padding: 3px 6px; margin-top: 4px; }
.mx { text-align: center; }
.mx.ok { background: #dff3df; color: #1b5e20; }
.mx.old { background: #fff1cc; color: #8a5a00; }
.mx.no { background: #fde4e3; color: #b0130f; }
.mx.na { background: #f1f1f1; color: #999; }

/* ---------- Sign-in landing (product description) ---------- */
.landing { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 32px; align-items: start; max-width: 1080px; margin: 24px auto; }
.landing .card { margin: 0; max-width: none; }
.landing-logo { display: block; width: 100%; max-width: 360px; margin: 0 0 12px; }
.landing-pitch h2 { margin: 8px 0; font-size: 26px; line-height: 1.2; }
.feat { padding-left: 18px; line-height: 1.5; }
.feat li { margin: 6px 0; }

/* ---------- Help: who can do what ---------- */
.roles-tbl { border-collapse: collapse; width: 100%; max-width: 820px; font-size: 14px; }
.roles-tbl th, .roles-tbl td { border: 1px solid var(--line); padding: 6px 8px; }
.roles-tbl th { background: var(--head); }
.roles-tbl td.yes, .roles-tbl td.no { text-align: center; width: 84px; font-weight: 700; }
.roles-tbl td.yes { color: #1e7d32; }
.roles-tbl td.no { color: var(--mut); }
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Phones and small tablets (portrait and landscape) ---------- */
.rotate-tip { display: none; }
@media (max-width: 820px) {
  .wrap { padding: 12px 10px; }
  .top { padding: 8px 10px; gap: 6px; }
  .top h1 { font-size: 16px; }
  .crumb-pill { display: none; }
  .top-nav { gap: 2px; }
  .nav-btn { padding: 6px 8px; white-space: nowrap; }
  .landing { grid-template-columns: 1fr; gap: 16px; margin: 8px auto; }
  .landing .card { order: -1; } /* returning users: sign in first, product description underneath */
  .landing-pitch h2 { font-size: 21px; }
  /* wide tables (wrapped in .tbl-scroll by app.js) keep a readable width and scroll sideways inside their box */
  .tbl-scroll > table:not(.roles-tbl) { min-width: 640px; }
  .roles-tbl td.yes, .roles-tbl td.no { width: 52px; }
  .roles-tbl { font-size: 13px; }
  .sheet { padding: 10px; }
  .card { padding: 16px; margin: 16px auto; }
  .home-wrap { margin: 12px auto; }
  /* 16px stops iPhones zooming in when a box is tapped */
  input, select, textarea { font-size: 16px; }
}
@media (max-width: 600px) and (orientation: portrait) {
  .rotate-tip { display: block; background: var(--head); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin: 0 0 10px; font-size: 13px; }
}

/* ---------- Work Instructions (master admins only, in development) ---------- */
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 700px) { .grid-3 { grid-template-columns: 1fr; } }
.twi-master { background: #fff4e5; border: 1px solid #f0c27b; color: #7a4a00; padding: 6px 10px; border-radius: var(--radius); margin-bottom: 10px; font-size: 13px; }
.twi-lock { background: #eef4ff; border: 1px solid #b6cdf3; padding: 6px 10px; border-radius: var(--radius); margin-bottom: 10px; font-size: 13px; }
.twi-status { margin-left: auto; align-self: center; font-size: 13px; }
.bdg.twi-draft { background: #6c757d; }
.bdg.twi-to_check { background: #b26a00; }
.bdg.twi-released { background: #2e7d32; }
.bdg.twi-archived { background: #c62828; }
.twi-warn { color: #9a5b00; font-size: 12px; margin-top: 2px; }
.twi-pts { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; }
@media (max-width: 900px) { .twi-pts { grid-template-columns: 1fr; } }
.twi-step-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 12px; }
.twi-step-h { background: var(--head); margin: -10px -10px 8px; padding: 6px 10px; }
.twi-pt { border-left: 3px solid var(--line); padding-left: 10px; margin: 8px 0 12px; }
.twi-pt-h, .twi-rs { display: flex; gap: 6px; align-items: flex-start; }
.twi-pt-h input { flex: 1; }
.twi-num { font-weight: 700; min-width: 34px; padding-top: 6px; }
.twi-rs { margin: 6px 0 0 34px; }
.twi-rs select { width: 150px; }
.twi-rs-t { flex: 1; }
.twi-sym { padding-top: 6px; }
.twi-pts-side { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; align-self: start; max-height: 80vh; overflow: auto; }
.twi-ra { margin-bottom: 12px; }
.twi-ra-hz { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 6px; }
.twi-ctl { display: flex; flex-direction: column; gap: 4px; font-size: 13px; margin: 6px 0; }
.twi-ctl select { width: auto; max-width: 170px; font-size: 12px; }
.twi-sheet table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.twi-sheet th, .twi-sheet td { border: 1px solid #9a9a9a; padding: 4px 6px; font-size: 12px; vertical-align: middle; }
.twi-sheet th { background: var(--red); color: #fff; font-weight: 600; }
.twi-sheet .twi-meta th { background: #d9d9d9; color: #222; }
.twi-sheet .twi-c { text-align: center; }
.twi-sheet .twi-step-c { text-align: center; }
.twi-sheet .twi-logo { width: 140px; text-align: center; }
.twi-sheet .twi-logo img { max-width: 130px; max-height: 50px; }
.twi-legend span { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; white-space: nowrap; }
.twi-legend svg { vertical-align: middle; }
.twi-draftbar { background: #c62828; color: #fff; text-align: center; font-weight: 700; padding: 4px; margin-top: 6px; }
#print-area .twi-sheet th, #print-area .twi-sheet td { font-size: 10px; padding: 3px 4px; }

/* ---------- Side project: Safety Concerns + Action Log (master admins only) ---------- */
.sc-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 8px 0; }
.sc-tile { border: 1px solid var(--line); border-left: 5px solid #1f78d1; border-radius: var(--radius); padding: 8px 10px; font-size: 13px; color: var(--mut); background: var(--card); }
.sc-tile b { display: block; font-size: 24px; color: var(--tx); }
.sc-tile.over { border-left-color: #c62828; }
.sc-tile.high { border-left-color: #e65100; }
.sc-tile.psif { border-left-color: #1d1d1b; }
.sc-tile.ok { border-left-color: #2e7d32; }
.sc-prio { display: inline-block; padding: 1px 8px; border-radius: 10px; color: #fff; font-size: 12px; font-weight: 600; }
.sc-prio.sc-low { background: #2e7d32; }
.sc-prio.sc-medium { background: #e69100; }
.sc-prio.sc-high { background: #c62828; }
.sc-psif { background: #1d1d1b; color: #fff; font-size: 11px; padding: 1px 5px; border-radius: 3px; font-weight: 700; }
.sc-radio { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin-right: 14px; }
.sc-radio input { width: auto; margin: 0; }
.sc-photo { max-width: 100%; max-height: 340px; border: 1px solid var(--line); border-radius: var(--radius); display: block; }
.sc-flag { background: #fff4e5; border: 1px solid #f0c27b; color: #7a4a00; padding: 6px 10px; border-radius: var(--radius); }
.sc-head { display: flex; justify-content: space-between; gap: 10px; background: #e65100; color: #fff; font-weight: 700; padding: 10px 14px; border-radius: var(--radius) var(--radius) 0 0; font-size: 16px; }
.sc-head.closed { background: #2e7d32; }
.sc-dt { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.sc-dt th, .sc-dt td { border: 1px solid var(--line); padding: 6px 8px; font-size: 13px; text-align: left; vertical-align: top; }
.sc-dt th { background: var(--head); width: 14%; }
.sc-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; }
.sc-body:has(> .sc-text:only-child) { grid-template-columns: 1fr; }
@media (max-width: 800px) { .sc-body { grid-template-columns: 1fr; } }
.sc-text .pt { white-space: pre-wrap; }
.sc-addact { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.sc-filters select, .sc-filters input:not([type=checkbox]) { width: auto; min-width: 150px; margin: 0; }
