:root {
  --red: #8B0101;
  --red-soft: rgba(139, 1, 1, 0.12);
  --red-ink: #a50101;
  --gray: #292929;
  --gray-soft: #333333;
  --bg: #0f0f0f;
  --bg-gradient: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 50%, #0f0f0f 100%);
  --surface: #1a1a1a;
  --surface-gradient: linear-gradient(145deg, #222222 0%, #1a1a1a 100%);
  --ink: #ffffff;
  --ink-1: #ffffff;
  --ink-2: #e0e0e0;
  --ink-3: #bfbfbf;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.12);
  --focus: #8B0101;
  --radius: 12px;
  --pad: 16px;
  --row-pad-y: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 15px rgba(139,1,1,0.25);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg-gradient);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
:lang(ar), .ar { font-family: "Noto Sans Arabic", "Inter", sans-serif; direction: rtl; }

/* ---- Top nav ---- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(26,26,26,0.92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
}
.brand {
  display: flex; align-items: baseline; gap: 10px;
  font-weight: 600; letter-spacing: -0.01em;
}
.brand .mark {
  width: 10px; height: 10px; border-radius: 2px; background: var(--red);
  display: inline-block; transform: translateY(1px);
}
.brand .ar { color: var(--ink-3); font-size: 12px; }
.topbar-nav {
  flex: 1; display: flex; gap: 2px; overflow-x: auto;
  scrollbar-width: thin;
}
.topbar-nav::-webkit-scrollbar { height: 4px; }
.topbar-nav::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.topbar-nav a {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 12.5px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.topbar-nav a:hover { background: var(--gray-soft); color: var(--ink); }
.topbar-nav a.active { color: var(--red); background: var(--red-soft); font-weight: 500; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }
.save-indicator {
  font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px;
}
.save-indicator .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #4CAF50;
}
.save-indicator.saving .dot { background: #F5A623; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

button, .btn {
  font-family: inherit; font-size: 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--ink-3); }
button.primary, .btn.primary {
  background: var(--red); color: white; border-color: var(--red);
}
button.primary:hover, .btn.primary:hover { background: var(--red-ink); border-color: var(--red-ink); }
button.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
button.ghost:hover { background: var(--gray-soft); }
button.small { padding: 3px 8px; font-size: 12px; }
button.danger-ghost { color: var(--red); border-color: transparent; background: transparent; }
button.danger-ghost:hover { background: var(--red-soft); }

/* ---- Document ---- */
.doc {
  max-width: 1280px; margin: 0 auto;
  padding: 32px 24px 120px;
}
.doc-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 18px; border-bottom: 1px solid var(--line);
}
.doc-title h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.015em; }
.doc-title .ar-title { font-size: 14px; color: var(--ink-3); direction: rtl; }

/* ---- Sections ---- */
section.sec { 
  margin-bottom: 40px; 
  scroll-margin-top: 76px; 
  background: var(--surface-gradient);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: slideUp 0.5s ease-out both;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
section.sec:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.sec-head {
  background: linear-gradient(135deg, #8B0101, #6b0000);
  color: white;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: relative; overflow: hidden;
}
.sec-head::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}
section.sec:hover .sec-head::after {
  transform: translateX(100%);
}
.sec-head .num {
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
  font-size: 11px;
  font-weight: 700;
  background: rgba(0,0,0,0.2);
  padding: 2px 6px;
  border-radius: 4px;
}
.sec-head .title-en { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.sec-head .title-ar { font-size: 14px; opacity: 0.85; direction: rtl; }
.sec-head-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.sec-sub {
  background: #2a2a2a;
  color: var(--ink);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.sec-sub .ar { font-size: 12px; color: var(--ink-3); }

.sec-body {
  background: var(--surface-gradient);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: var(--pad);
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

/* ---- Fields ---- */
.field-grid { display: grid; gap: 14px 18px; grid-template-columns: repeat(4, 1fr); }
.field-grid.two { grid-template-columns: repeat(2, 1fr); }
.field-grid.three { grid-template-columns: repeat(3, 1fr); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label {
  font-size: 11.5px;
  color: var(--ink-2);
  font-weight: 500;
  display: flex; gap: 6px; align-items: baseline;
}
.field label .ar {
  color: var(--ink-3); font-size: 11px; font-weight: 400;
}
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: rgba(0,0,0,0.2); color: var(--ink);
  padding: 10px 12px; border-radius: 8px; font-family: inherit; font-size: 13.5px;
  transition: all .2s; outline: none;
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--line-strong); background: rgba(0,0,0,0.25); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--red); background: rgba(0,0,0,0.3); box-shadow: 0 0 0 3px rgba(139,1,1,0.15); }
.field textarea { resize: none; field-sizing: content; min-height: 36px; line-height: 1.4; overflow: hidden; }

/* ---- Checkbox groups ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--bg);
}
.kpi-title { font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.kpi-title .ar { font-weight: 400; color: var(--ink-3); font-size: 11px; }
.kpi-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background .1s;
}
.kpi-opt:hover { background: var(--gray-soft); }
.kpi-opt input { margin: 0; cursor: pointer; accent-color: var(--red); }
.kpi-opt .status-good { color: #2d6a2d; font-weight: 500; }
.kpi-opt .status-bad { color: var(--red); font-weight: 500; }
.kpi-opt .ar { color: var(--ink-3); font-size: 11px; margin-left: auto; }
.kpi-opt.selected { background: var(--red-soft); }

/* ---- Tables ---- */
.tbl-wrap { overflow-x: auto; }
table.entry {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.entry th, table.entry td {
  border-bottom: 1px solid var(--line);
  padding: var(--row-pad-y) 8px;
  text-align: left;
  vertical-align: top;
  color: var(--ink-2);
}
table.entry th {
  background: var(--gray);
  font-weight: 600;
  font-size: 11.5px;
  color: var(--ink);
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--line-strong);
}
table.entry th .ar {
  display: block; font-weight: 400; color: var(--ink-2); font-size: 10.5px; direction: rtl;
}
table.entry td.num-col {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  width: 28px;
  text-align: center;
  font-size: 12px;
}
table.entry td.action-col { width: 40px; text-align: center; }
table.entry input, table.entry select, table.entry textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.04);
  padding: 4px 6px;
  font-family: inherit; font-size: 13px;
  border-radius: 3px;
  color: var(--ink);
  min-width: 0;
}
table.entry input:hover, table.entry select:hover, table.entry textarea:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.13);
}
table.entry input:focus, table.entry select:focus, table.entry textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--red);
  color: var(--ink);
  box-shadow: 0 0 0 2px var(--red-soft);
}
table.entry select option {
  background: #1a1a1a;
  color: #ffffff;
}
table.entry textarea { resize: none; field-sizing: content; min-height: 28px; line-height: 1.35; overflow: hidden; }
table.entry tr:hover td { background: rgba(0,0,0,0.01); }

.add-row {
  margin-top: 12px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
}
.add-row .count { font-size: 12px; color: var(--ink-3); }

/* ---- Split (two-column subsections) ---- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split .col-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.split .col-head .ar { color: var(--ink-3); font-weight: 400; font-size: 11px; }

/* ---- Photos ---- */
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.photo-card {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--bg);
}
.photo-drop {
  aspect-ratio: 4/3;
  background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(0,0,0,0.025) 8px, rgba(0,0,0,0.025) 9px);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-family: "JetBrains Mono", monospace; font-size: 11px;
  position: relative;
  overflow: hidden;
}
.photo-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-drop input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.photo-caption {
  margin-top: 8px; width: 100%;
  border: 1px solid var(--line);
  padding: 6px 8px; border-radius: 4px; font-size: 12.5px;
  font-family: inherit;
}
.photo-caption:focus { outline: none; border-color: var(--red); }

/* ---- Signatures ---- */
.sig-grid { display: grid; grid-template-columns: 160px 1fr 1fr 1.2fr 100px; gap: 10px; align-items: end; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sig-grid:last-child { border-bottom: none; }
.sig-role { font-weight: 500; font-size: 13px; }
.sig-role .ar { color: var(--ink-3); font-size: 11px; display: block; }
.sig-pad {
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
  height: 44px;
  position: relative;
  cursor: crosshair;
}
.sig-pad canvas { width: 100%; height: 100%; display: block; border-radius: 4px; }
.sig-pad .clear {
  position: absolute; top: 2px; right: 4px;
  background: transparent; border: none; color: var(--ink-3);
  font-size: 10px; cursor: pointer; padding: 2px 4px;
}
.sig-pad .clear:hover { color: var(--red); }

/* ---- Weather row ---- */
.weather-row { display: grid; grid-template-columns: 120px 1fr 80px 120px 1.3fr 90px 90px; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.weather-row.head { font-weight: 600; font-size: 11.5px; color: var(--ink-2); background: var(--gray); border-bottom: 1px solid var(--line-strong); padding: 8px; border-radius: 4px; margin-bottom: 4px; }
.weather-row.total { font-weight: 600; background: var(--gray-soft); padding: 10px 8px; border-radius: 4px; margin-top: 6px; border-bottom: none; }
.weather-day { font-weight: 500; font-size: 13px; }
.weather-day .ar { color: var(--ink-3); font-size: 11px; display: block; }

/* ---- Workforce / Equipment ---- */
.wf-row { display: grid; grid-template-columns: 1.4fr repeat(6, 1fr); gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); align-items: center; font-size: 13px; }
.wf-row.head { font-weight: 600; font-size: 11.5px; background: var(--gray); padding: 8px 6px; border-radius: 4px; color: var(--ink); border-bottom: 1px solid var(--line-strong); }
.wf-row.total { font-weight: 600; background: var(--gray-soft); padding: 10px 6px; border-radius: 4px; margin-top: 4px; border-bottom: none; }
.wf-row input { border: 1px solid rgba(255,255,255,0.07); background: rgba(255,255,255,0.04); padding: 5px; font-family: inherit; font-size: 13px; border-radius: 3px; width: 100%; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.wf-row input:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.13); }
.wf-row input:focus { outline: none; background: var(--surface); border-color: var(--red); color: var(--ink); box-shadow: 0 0 0 2px var(--red-soft); }
.wf-label .ar { color: var(--ink-3); font-size: 11px; display: block; }

.eq-row { display: grid; grid-template-columns: 1.4fr 60px 1fr 1fr 1fr 80px; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); align-items: center; font-size: 13px; }
.eq-row.head { font-weight: 600; font-size: 11.5px; background: var(--gray); padding: 8px 6px; border-radius: 4px; color: var(--ink); border-bottom: 1px solid var(--line-strong); }
.eq-row.total { font-weight: 600; background: var(--gray-soft); padding: 10px 6px; border-radius: 4px; margin-top: 4px; border-bottom: none; }
.eq-row input { border: 1px solid rgba(255,255,255,0.07); background: rgba(255,255,255,0.04); padding: 5px; font-family: inherit; font-size: 13px; border-radius: 3px; width: 100%; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.eq-row input:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.13); }
.eq-row input:focus { outline: none; background: var(--surface); border-color: var(--red); color: var(--ink); box-shadow: 0 0 0 2px var(--red-soft); }

/* ---- HSE split ---- */
.hse-split { display: grid; grid-template-columns: 1fr 1.2fr; gap: 16px; }
.hse-kpi { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 4px 8px; align-items: center; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.hse-kpi.head { font-weight: 600; font-size: 11.5px; color: var(--ink); background: var(--gray); padding: 8px; border-radius: 4px; border-bottom: 1px solid var(--line-strong); }
.hse-kpi input { border: 1px solid rgba(255,255,255,0.07); background: rgba(255,255,255,0.04); padding: 5px; font-family: inherit; font-size: 13px; text-align: right; border-radius: 3px; width: 100%; font-variant-numeric: tabular-nums; color: var(--ink); }
.hse-kpi input:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.13); }
.hse-kpi input:focus { outline: none; background: var(--surface); border-color: var(--red); color: var(--ink); box-shadow: 0 0 0 2px var(--red-soft); }

/* ---- Floating Tweaks panel ---- */
.tweaks-panel {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 14px;
  width: 260px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.12);
  z-index: 50;
  display: none;
}
.tweaks-panel.on { display: block; }
.tweaks-panel h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.tweaks-panel h3 button { padding: 2px 6px; font-size: 11px; }
.tweaks-row { margin-bottom: 10px; }
.tweaks-row label { display: block; font-size: 11.5px; color: var(--ink-2); margin-bottom: 4px; }
.tweaks-row .seg { display: flex; gap: 2px; border: 1px solid var(--line); border-radius: 4px; padding: 2px; }
.tweaks-row .seg button {
  flex: 1; border: none; padding: 5px; font-size: 12px; border-radius: 3px;
}
.tweaks-row .seg button.on { background: var(--red); color: white; }

body.density-compact { --pad: 12px; --row-pad-y: 6px; }
body.density-compact .field-grid { gap: 10px 14px; }
body.density-compact section.sec { margin-bottom: 28px; }

body.lang-en .ar, body.lang-en [data-ar-only] { display: none !important; }
body.lang-ar .en, body.lang-ar [data-en-only] { display: none !important; }
body.lang-ar { direction: rtl; }
body.lang-ar table.entry th, body.lang-ar table.entry td,
body.lang-ar .field { text-align: right; }

/* ---------- Responsive & Fixes ---------- */
@media (max-width: 960px) {
  .field-grid, .field-grid.two, .field-grid.three { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .split, .hse-split, .photo-grid { grid-template-columns: 1fr; }
  .weather-row { grid-template-columns: 1fr 1fr; gap: 6px; }
  .weather-row.head { display: none; }
  .wf-row { grid-template-columns: 1.3fr repeat(3, 1fr); }
  .eq-row { grid-template-columns: 1.3fr 1fr 1fr; }
  .eq-row.head, .wf-row.head { font-size: 10px; }
  .sig-grid { grid-template-columns: 1fr; gap: 6px; }
  table.entry { font-size: 12px; }
  .topbar-inner { padding: 8px 14px; }
  .doc { padding: 20px 14px 100px; max-width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .reports-page { padding: 16px 14px; }
}

@media (max-width: 600px) {
  .field-grid, .field-grid.two, .field-grid.three { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .tweaks-panel { right: 10px; left: 10px; width: auto; }
  .signoff-table { display: block; overflow-x: auto; }
}

/* Fix for Inputs contrast */
.weather-row input, .field input, .field textarea, table.entry td input, .signoff-table input {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.05);
}

/* Table scroll hint */
.tbl-wrap, .reports-table {
  position: relative;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.tbl-wrap::after, .reports-table::after {
  content: 'Swipe for more →';
  position: absolute;
  bottom: 4px; right: 8px;
  font-size: 9px;
  color: var(--ink-3);
  pointer-events: none;
  opacity: 0.5;
}
@media (min-width: 769px) { .tbl-wrap::after, .reports-table::after { display: none; } }


/* ---- MPR layout additions ---- */

/* Compact field grid variant */
.field-grid.compact { gap: 10px 14px; }
.field-grid.compact .field input { padding: 6px 10px; font-size: 13px; }
.field-grid.compact .field label { font-size: 11.5px; }

/* Wide textareas for narrative fields (highlights, concerns, recovery, look-ahead, conclusions) */
textarea.big {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-1);
  background: var(--surface);
  resize: none;
  field-sizing: content;
  min-height: 110px;
  box-sizing: border-box;
  transition: border-color 0.12s, box-shadow 0.12s;
  overflow: hidden;
}
textarea.big:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(139, 1, 1, 0.08);
}
textarea.big::placeholder { color: var(--ink-3); font-style: italic; }

/* Compact KPI grid (tight 3-column, smaller labels/inputs) */
.field-grid.kpi-compact { gap: 10px 14px; }
.field-grid.kpi-compact .field label { font-size: 11.5px; }
.field-grid.kpi-compact .field input {
  padding: 6px 10px;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Signatures single-row table */
.signoff-table { font-size: 13px; }
.signoff-table th {
  background: #E5E5E5;
  font-size: 12px;
  text-transform: none;
  color: var(--ink-2);
  letter-spacing: 0;
  font-weight: 500;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.signoff-table td {
  padding: 10px 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.signoff-table tr:last-child td { border-bottom: none; }
.signoff-table td.role-cell {
  background: var(--surface);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--ink-1);
  white-space: nowrap;
}
.signoff-table td.role-cell strong { font-weight: 600; }
.signoff-table td.role-cell .ar {
  color: var(--ink-3);
  font-size: 11.5px;
  margin-left: 4px;
}
.signoff-table input[type="text"],
.signoff-table input[type="date"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 7px 10px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-1);
  box-sizing: border-box;
}
.signoff-table input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(139, 1, 1, 0.1);
}

/* Signature pad cell — distinct boxed look */
.sig-pad-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  min-height: 36px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
}
.sig-pad-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: 'Segoe Script', 'Brush Script MT', cursive;
  font-size: 14px;
  color: var(--ink-1);
  padding: 0;
  min-width: 0;
}
.sig-pad-wrap input::placeholder {
  color: var(--ink-3);
  font-family: inherit;
  font-style: italic;
  font-size: 12px;
}
.sig-pad-clear {
  position: absolute;
  top: 4px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.sig-pad-clear:hover { color: var(--red); }

@media (max-width: 900px) {
  .field-grid.compact { grid-template-columns: 1fr 1fr; }
  .field-grid.kpi-compact { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .field-grid.compact { grid-template-columns: 1fr; }
  .field-grid.kpi-compact { grid-template-columns: 1fr; }
}


/* ---- Narrative textarea: explicit full width, taller ---- */
section.sec > textarea.big,
.sec > textarea.big {
  display: block;
  width: 100%;
  min-height: 110px;
  box-sizing: border-box;
}



/* ---- Incidents log: tighter row + severity-based row highlight ---- */
table.entry tr.sev-critical td,
table.entry tr.sev-lti td,
table.entry tr.sev-env td {
  background: rgba(220, 38, 38, 0.06);
}
table.entry tr.sev-critical td:first-child,
table.entry tr.sev-lti td:first-child,
table.entry tr.sev-env td:first-child {
  border-left: 3px solid #DC2626;
}
table.entry.tight td { padding: 4px 6px; }
table.entry.tight input, table.entry.tight select { padding: 4px 8px; font-size: 12.5px; }

/* ---- Photos: WSR-style large 2-col placeholders ---- */
.photo-wsr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 6px;
}
.photo-wsr-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.photo-wsr-drop {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1.5px dashed #D1D5DB;
  border-radius: 8px;
  background:
    repeating-linear-gradient(
      45deg,
      #FAFAF7,
      #FAFAF7 10px,
      #F5F5F0 10px,
      #F5F5F0 20px
    );
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  overflow: hidden;
}
.photo-wsr-drop:hover { border-color: var(--red); }
.photo-wsr-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.photo-wsr-drop .placeholder {
  font-family: 'JetBrains Mono', monospace;
  color: var(--ink-3);
  font-size: 14px;
  pointer-events: none;
}
.photo-wsr-drop img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.photo-wsr-caption {
  display: flex;
  gap: 8px;
  align-items: center;
}
.photo-wsr-caption input {
  flex: 1;
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--surface);
  color: var(--ink-2);
}
.photo-wsr-caption .remove-btn {
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-3);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.photo-wsr-caption .remove-btn:hover { color: #DC2626; border-color: #DC2626; }
.photo-wsr-num {
  position: absolute;
  top: 10px; left: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--ink-3);
  font-size: 11px;
  background: rgba(255,255,255,0.8);
  padding: 2px 6px;
  border-radius: 3px;
}

@media (max-width: 800px) {
  .photo-wsr-grid { grid-template-columns: 1fr; }
}


/* ---- Weather conditions: in-cell multi-select dropdown ---- */
.wc-cell { position: relative; width: 100%; }
.wc-trigger {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 4px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  color: var(--ink-1);
  transition: border-color 0.12s;
}
.wc-trigger:hover { border-color: var(--ink-3); }
.wc-trigger:focus { outline: none; border-color: var(--red); }
.wc-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.wc-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(139, 1, 1, 0.08);
  color: var(--red);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.wc-placeholder { color: var(--ink-3); font-style: italic; }
.wc-caret { color: var(--ink-3); font-size: 10px; flex-shrink: 0; }

.wc-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.16);
  padding: 10px;
  max-height: 480px;
  overflow-y: auto;
  width: 560px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.wc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: all 0.12s;
  min-height: 56px;
}
.wc-item:hover {
  border-color: var(--ink-3);
  background: var(--bg);
}
.wc-item.selected {
  border-color: var(--red);
  background: rgba(139, 1, 1, 0.06);
  box-shadow: 0 0 0 1px var(--red);
}
.wc-item input { display: none; }
.wc-item .wc-icon {
  font-size: 22px;
  line-height: 1;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
  color: var(--ink-1);
}
.wc-item .wc-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
  min-width: 0;
}
.wc-item .wc-text .en {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-1);
}
.wc-item .wc-text .ar {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 400;
}

@media (max-width: 700px) {
  .wc-menu { width: 320px; grid-template-columns: 1fr; }
}
