:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0C1248;
  --accent: #F9583A;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #e11d48;
  --bg: #f1f5f9;
}

* { box-sizing: border-box; }
body.ops-page {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.ops-shell { max-width: 1100px; margin: 0 auto; padding: 18px 16px 48px; }
.ops-header {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  align-items: flex-start; margin-bottom: 14px;
}

.ops-header h1 { margin: 0 0 4px; font-size: 1.25rem; color: var(--brand); }
.ops-header p { margin: 0; color: var(--muted); font-size: .88rem; max-width: 52rem; line-height: 1.45; }
.ops-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ops-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 9px 12px; font-weight: 700; font-size: .85rem; cursor: pointer; color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center;
}
.ops-btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.ops-btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.ops-btn:disabled { opacity: .55; cursor: not-allowed; }

#opsMsg { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; font-size: .86rem; display: none; }
#opsMsg.ok { display: block; background: #dcfce7; color: #166534; }
#opsMsg.err { display: block; background: #fee2e2; color: #991b1b; }
#opsMsg.info { display: block; background: #e0e7ff; color: #312e81; }
#opsWho, #opsRole {color:#fff;}
.ops-busy-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: none; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(1px);
}
.ops-busy-overlay.is-open { display: flex; }
.ops-busy-card {
  background: #fff; border-radius: 12px; padding: 22px 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  min-width: 220px; max-width: min(360px, 90vw); text-align: center;
}
.ops-busy-spinner {
  width: 28px; height: 28px;
  border: 3px solid #e2e8f0; border-top-color: var(--accent, #2563eb);
  border-radius: 50%; animation: ops-busy-spin 0.7s linear infinite;
}
.ops-busy-text { font-size: 0.9rem; color: #0f172a; font-weight: 600; line-height: 1.35; }
.ops-busy-sub { font-size: 0.78rem; color: #64748b; }
@keyframes ops-busy-spin { to { transform: rotate(360deg); } }

.ops-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.ops-card h2 {
  margin: 0 0 10px; font-size: .95rem; color: var(--brand);
  border-bottom: 2px solid var(--accent); padding-bottom: 6px;
}
.ops-card textarea { width:100%;}
.ops-hint { font-size: .8rem; color: var(--muted); margin: -4px 0 12px; line-height: 1.4; }

.ops-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
}
.ops-card input:not([type="checkbox"]),
.ops-card select {
    min-width: 150px;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    background: #fff;
    text-transform: none;
    letter-spacing: normal;
}
.sc-add-sub input:not([type="checkbox"]){min-width:50%;}
#fHospital {width: 80%; }
@media (max-width: 720px) { .ops-grid { grid-template-columns: 1fr; } }
.ops-grid label, .ops-field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: .75rem; color: var(--muted); font-weight: 600;
}
/* Column flex would otherwise put the required marker on its own row, unsettling the grid */
.ops-grid label > .req, .ops-field > .req { display: contents; }
.ops-grid input, .ops-grid select, .ops-grid textarea,
.ops-table input, .ops-table select {
  padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px;
  font: inherit; color: var(--ink); font-weight: 500;
}
.ops-grid textarea { min-height: 64px; resize: vertical; }
.ops-grid .full { grid-column: 1 / -1; }

.ops-table-wrap { overflow-x: auto; }
.ops-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.ops-table th, .ops-table td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; vertical-align: top; }
.ops-table th { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; }
.ops-table input, .ops-table select { width: 100%; min-width: 72px; }
.ops-row-actions { white-space: nowrap; }
.ops-check { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--ink); margin: 0 0 10px; }
.ops-check input { width: 16px; height: 16px; }

.ops-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px;
}
.ops-kpi { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.ops-kpi label { display: block; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.ops-kpi strong { font-size: 1rem; }
.rag { display: inline-block; padding: .12rem .45rem; border-radius: 999px; font-size: .7rem; font-weight: 800; }
.rag-Green { background: #dcfce7; color: #166534; }
.rag-Amber { background: #fef3c7; color: #92400e; }
.rag-Red { background: #fee2e2; color: #991b1b; }

.ops-list table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.ops-list th, .ops-list td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.ops-list tr.row-click { cursor: pointer; }
.ops-list tr.row-click:hover { background: #f8fafc; }

.view-only .ops-editor { display: none; }
.view-only .ops-viewer { display: block; }
.view-only #btnSave,
.view-only #btnSign,
.view-only #btnLabourFromAttendance { display: none !important; }
.ops-viewer { display: none; }
.ops-viewer dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; margin: 0; font-size: .9rem; }
.ops-viewer dt { color: var(--muted); font-weight: 700; }
.ops-viewer dd { margin: 0; }
.ops-viewer ul { margin: 0; padding-left: 1.1rem; }
.ops-viewer li { margin: 3px 0; }
.ops-viewer .ops-nil,
.ops-nil { margin: 0; color: var(--muted); font-size: .88rem; }

.ops-toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px;
}
.ops-toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: .75rem; color: var(--muted); font-weight: 600; }
.ops-toolbar input, .ops-toolbar select { padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }

/* Manager's signature panel — shared by every ops form (see ops-signature.js) */
.sc-sig { display:flex; flex-wrap:wrap; gap:16px; align-items:center; }
.sc-sig-img { max-height:70px; max-width:240px; background:#fff; border:1px solid #e2e8f0; border-radius:6px; padding:5px; }
.sc-sig-meta { font-size:.82rem; color:#64748b; line-height:1.55; }
.sc-sig-meta strong { display:block; color:#0f172a; font-size:.92rem; }
.sc-sig-actions { margin-left:auto; display:flex; gap:8px; align-items:center; }
.sc-sig-none { border:1px dashed #fdba74; background:#fff7ed; border-radius:8px; padding:14px 16px; width:100%; }
.sc-sig-none strong { display:block; color:#9a3412; margin-bottom:4px; }
.sc-sig-none p { margin:0 0 10px; font-size:.83rem; color:#7c2d12; line-height:1.55; }
/* The panel must stay usable on a signed form, which is otherwise greyed out */
.signed-lock #signatureCard a.ops-btn { pointer-events:auto; opacity:1; }
@media (max-width: 720px) { .sc-sig-actions { margin-left:0; width:100%; } }
