* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, "Segoe UI", Tahoma, Arial, sans-serif; color: #1d2430; background: #f4f6f9; }
header { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.2rem; background: #12355b; color: #fff; }
header .brand { font-size: 1.05rem; }
header nav { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; }
header nav a { color: #cfe0f5; text-decoration: none; padding: .35rem .7rem; border-radius: 4px; }
header nav a.on, header nav a:hover { background: #1f4f80; color: #fff; }
header #who { font-size: .9rem; color: #cfe0f5; }
header #who button { margin-left: .6rem; }
header #who a { color: #fff; }
main { padding: 1.2rem; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 1.3rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
.card { background: #fff; border: 1px solid #dde3ea; border-radius: 6px; padding: 1rem; margin-bottom: 1rem; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.row > label { display: flex; flex-direction: column; font-size: .85rem; color: #4a5566; gap: .2rem; }
input, select, textarea { font: inherit; padding: .4rem .5rem; border: 1px solid #b9c3cf; border-radius: 4px; background: #fff; min-width: 9rem; }
textarea { width: 100%; min-height: 4rem; }
button { font: inherit; padding: .42rem .9rem; border-radius: 4px; border: 1px solid #1f4f80; background: #1f4f80; color: #fff; cursor: pointer; }
button.secondary { background: #fff; color: #1f4f80; }
button.danger { background: #a8322d; border-color: #a8322d; }
button:disabled { opacity: .5; cursor: default; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: .45rem .55rem; border-bottom: 1px solid #e6eaef; vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: #5b6676; background: #f8fafc; }
tr.click { cursor: pointer; }
tr.click:hover { background: #f1f6fc; }
.muted { color: #6b7685; }
.badge { display: inline-block; padding: .05rem .45rem; border-radius: 10px; font-size: .78rem; background: #e7ecf2; }
.badge.scheduled { background: #e6f0fb; color: #1f4f80; }
.badge.images_received { background: #e3f5e8; color: #1d6b35; }
.badge.reported { background: #ece6fb; color: #4b2a91; }
.badge.cancelled { background: #f4e4e3; color: #8a2a25; }
.badge.warn { background: #fff1d6; color: #7a5200; }
.error { color: #a8322d; margin: .5rem 0; }
.login { max-width: 360px; margin: 10vh auto; }
.login input { width: 100%; }
.login label { display: block; margin-bottom: .8rem; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.preview { max-width: 100%; max-height: 420px; background: #000; display: block; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
dl.kv dt { color: #5b6676; }
dl.kv dd { margin: 0; }
#toast { position: fixed; bottom: 1rem; right: 1rem; background: #1d2430; color: #fff; padding: .6rem 1rem; border-radius: 5px; max-width: 420px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
label input[type=checkbox] { min-width: 0; }
header .badge { background: #2b6aa8; color: #fff; margin-left: .5rem; }

/* ---------------------------------------------------------------- reporting */
a.button { display: inline-block; font: inherit; padding: .42rem .9rem; border-radius: 4px; border: 1px solid #1f4f80;
  background: #fff; color: #1f4f80; text-decoration: none; }
a.button:hover { background: #f1f6fc; }
.badge.draft { background: #fff1d6; color: #7a5200; }
.badge.signed { background: #e3f5e8; color: #1d6b35; }
.badge.amended { background: #ece6fb; color: #4b2a91; }
.badge.prio-stat { background: #c62828; color: #fff; font-weight: 600; }
.badge.prio-urgent { background: #f6c343; color: #4a3500; font-weight: 600; }
.badge.prio-routine { background: transparent; color: #6b7685; padding-inline: 0; }
.badge.hms-queued { background: #e6f0fb; color: #1f4f80; }
.badge.hms-delivered { background: #e3f5e8; color: #1d6b35; }
.badge.hms-failed { background: #f4e4e3; color: #8a2a25; }
h2.first { margin-top: 0; }
h3 { font-size: .95rem; margin: 1rem 0 .3rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

.report-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.report-title h1 { margin-bottom: .6rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
dl.kv-wide { grid-template-columns: max-content 1fr max-content 1fr; }
@media (max-width: 800px) { dl.kv-wide { grid-template-columns: max-content 1fr; } }

.report-editor .tools { margin-bottom: .8rem; align-items: center; }
.segs { display: inline-flex; }
.segs .seg { background: #fff; color: #1f4f80; border-radius: 0; }
.segs .seg:first-child { border-start-start-radius: 4px; border-end-start-radius: 4px; }
.segs .seg:last-child { border-start-end-radius: 4px; border-end-end-radius: 4px; border-inline-start-width: 0; }
.segs .seg[aria-pressed=true] { background: #1f4f80; color: #fff; }
.segs .seg[lang=ar], [lang=ar] { font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Noto Sans Arabic", Arial, sans-serif; }

label.section { display: block; margin-block-end: .9rem; }
label.section .sec-title { display: block; font-weight: 600; color: #33404f; margin-block-end: .25rem; }
.editor textarea, .template-sections textarea { min-height: 8rem; resize: vertical; line-height: 1.55; text-align: start; unicode-bidi: plaintext; }
.editor textarea.sec-findings, .editor textarea.sec-addendum { min-height: 14rem; }
.editor[dir=rtl] textarea, .template-sections textarea[dir=rtl] { font-size: 15px; }
.editor[dir=rtl] .sec-title { text-align: start; }
.editor.dirty { border-inline-start: 3px solid #f6c343; padding-inline-start: .7rem; }
.report-editor .buttons { align-items: center; }
.report-editor .saved { margin: 0; margin-inline-start: auto; }
.report-editor.busy button { opacity: .6; pointer-events: none; }
button.sign { background: #1d6b35; border-color: #1d6b35; }
button.danger-text { color: #a8322d; border-color: #a8322d; }

section.signed { border-block-start: 1px solid #e6eaef; padding-block: .4rem; }
section.signed:first-of-type { border-block-start: 0; }
section.signed.addendum { background: #faf8ff; border-inline-start: 3px solid #b9a6e8; padding-inline: .8rem; margin-block-start: .6rem; }
section.signed h3 { color: #33404f; }
section.signed .text { white-space: pre-wrap; text-align: start; unicode-bidi: plaintext; }
section.signed .sig { font-size: .85rem; color: #4a5566; margin: .8rem 0 .2rem; }
[dir=rtl] .sig { text-align: end; }

details.history summary { cursor: pointer; font-weight: 600; }
details.history table { margin-top: .8rem; }

.template-sections { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 1rem; margin-top: .8rem; }
@media (max-width: 800px) { .template-sections { grid-template-columns: 1fr; } }
.lines { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem 1rem; margin: .8rem 0; }
.lines > label { display: flex; flex-direction: column; font-size: .85rem; color: #4a5566; gap: .2rem; }
.lines.one { grid-template-columns: 1fr; }
img.logo { max-height: 90px; max-width: 320px; display: block; margin-bottom: .8rem; border: 1px solid #e6eaef; background: #fff; padding: .3rem; }

@media print {
  header, .noprint, .report-editor, details.history, .actions, #toast { display: none !important; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
}

/* ---------------------------------------------------------------- sign dialog, notices */
dialog.sign-dialog { border: 1px solid #b9c3cf; border-radius: 6px; padding: 1.2rem; max-width: 440px; width: 92vw; }
dialog.sign-dialog::backdrop { background: rgba(18, 53, 91, .35); }
dialog.sign-dialog label { display: flex; flex-direction: column; gap: .25rem; margin: .8rem 0; font-size: .9rem; }
dialog.sign-dialog input { width: 100%; }
.notice { background: #fff1d6; color: #7a5200; padding: .5rem .7rem; border-radius: 4px; }
.setting dl.help { margin: .6rem 0; font-size: .92rem; }
.setting dl.help dt { font-weight: 600; }
.setting-head { justify-content: space-between; align-items: center; }
input.num { width: 7rem; min-width: 0; }
