/* Coastal crew portal. Builds on the public site's css/styles.css tokens. */

body.portal { min-height: 100vh; display: flex; flex-direction: column; background: var(--color-bg); }
.portal-main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--color-text-muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 28px; }
code { background: var(--color-surface-3); padding: 1px 6px; border-radius: 4px; font-size: 0.88em; }
a:not(.btn):not(.dash-link) { color: var(--color-link); }
.portal-main a:not(.btn):hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); color: var(--white); line-height: 1.2; }

/* ---------- Header ---------- */
.portal-header { position: sticky; top: 0; z-index: 50; background: var(--color-header-bg); backdrop-filter: blur(10px); border-bottom: 1px solid var(--color-border); }
.portal-header-inner { max-width: 1240px; margin: 0 auto; padding: 0 24px; height: 68px; display: flex; align-items: center; gap: 20px; }
.portal-brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; color: var(--white); }
.portal-brand img { height: 30px; width: auto; }
.portal-brand span { font-weight: 700; font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--blue-accent); border-left: 1px solid var(--color-border); padding-left: 12px; }
.portal-nav { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.portal-nav > ul { display: flex; align-items: center; gap: 2px; }
.portal-nav a, .portal-dropdown > summary {
  display: block; padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem;
  color: var(--color-text); cursor: pointer; list-style: none; white-space: nowrap;
}
.portal-dropdown > summary::-webkit-details-marker { display: none; }
.portal-dropdown > summary::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-3px); opacity: 0.7; }
.portal-nav a:hover, .portal-dropdown > summary:hover, .portal-nav a[aria-current="page"], .portal-dropdown > summary[aria-current="page"] { color: var(--color-link); background: var(--blue-accent-light); text-decoration: none; }
.portal-dropdown { position: relative; }
.portal-dropdown > ul {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 220px; background: var(--color-surface-2);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
}
.portal-dropdown-right > ul { left: auto; right: 0; }
.portal-dropdown li a, .portal-dropdown li button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: var(--radius-sm); font-weight: 500; background: none; border: 0; color: var(--color-text); font-size: 0.9rem; }
.portal-dropdown li a:hover, .portal-dropdown li button:hover { background: var(--color-surface-4); color: var(--white); text-decoration: none; }
.portal-user-meta { padding: 10px 12px 12px; font-size: 0.82rem; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); margin-bottom: 6px; word-break: break-all; }
.portal-user-meta span { color: var(--blue-accent); font-weight: 600; }
.portal-user summary { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--color-primary); color: var(--white); display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; }
.portal-menu-btn { display: none; margin-left: auto; background: none; border: 0; color: var(--white); width: 44px; height: 44px; align-items: center; justify-content: center; }
.portal-menu-btn svg { width: 26px; height: 26px; }

@media (max-width: 960px) {
  .portal-menu-btn { display: inline-flex; }
  .portal-nav { display: none; position: fixed; inset: 68px 0 0 0; background: var(--color-surface); flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 16px 20px 40px; overflow-y: auto; }
  .portal-nav.is-open { display: flex; }
  .portal-nav > ul { flex-direction: column; align-items: stretch; }
  .portal-nav a, .portal-dropdown > summary { padding: 13px 14px; font-size: 1rem; }
  .portal-dropdown > ul { position: static; box-shadow: none; border: 0; background: transparent; padding: 0 0 0 14px; }
  .portal-user { border-top: 1px solid var(--color-border); padding-top: 12px; }
  .portal-user-name { display: inline; }
}

.portal-footer { text-align: center; padding: 22px 24px; font-size: 0.8rem; color: var(--grey-500); border-top: 1px solid var(--color-border); }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.page-head .eyebrow { margin-bottom: 6px; }
.page-intro { color: var(--color-text-muted); margin-top: 8px; max-width: 720px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.page-actions form { display: inline; }

/* ---------- Buttons ---------- */
.btn-small { padding: 7px 12px; font-size: 0.82rem; }
.btn-danger { background: transparent; color: #ff8a8a; border: 1px solid rgba(255, 120, 120, 0.45); }
.btn-danger:hover { background: #b42318; border-color: #b42318; color: var(--white); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
form.inline { display: inline; }

/* ---------- Alerts, pills, badges ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 18px; border: 1px solid; font-size: 0.95rem; }
.alert-success { background: rgba(34, 160, 90, 0.12); border-color: rgba(34, 160, 90, 0.45); color: #8ee0b2; }
.alert-error { background: rgba(220, 60, 60, 0.12); border-color: rgba(220, 60, 60, 0.5); color: #ffb0b0; }
.alert-info { background: rgba(37, 170, 225, 0.1); border-color: rgba(37, 170, 225, 0.4); color: #a9def5; }
.alert-warn { background: rgba(240, 170, 40, 0.1); border-color: rgba(240, 170, 40, 0.45); color: #f8d38a; }
.alert a { color: inherit; text-decoration: underline; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; background: var(--color-surface-4); color: var(--color-text); white-space: nowrap; }
.pill-ok { background: rgba(34, 160, 90, 0.18); color: #8ee0b2; }
.pill-warn { background: rgba(240, 170, 40, 0.16); color: #f8d38a; }
a.pill:hover { text-decoration: none; filter: brightness(1.2); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 4px; font-size: 0.76rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.badge-draft { background: var(--color-surface-4); color: var(--color-text); }
.badge-submitted { background: rgba(37, 170, 225, 0.18); color: #8fd6f5; }
.badge-approved { background: rgba(34, 160, 90, 0.2); color: #8ee0b2; }
.badge-returned { background: rgba(240, 170, 40, 0.18); color: #f8d38a; }

/* ---------- Panels & layout ---------- */
.panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 20px; }
.panel h2 { font-size: 1.2rem; margin-bottom: 14px; }
.panel.narrow { max-width: 760px; }
.grid-2 { display: grid; gap: 20px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.stack > * + * { margin-top: 16px; }
.portal-empty { text-align: center; padding: 56px 24px; background: var(--color-surface); border: 1px dashed var(--color-border); border-radius: var(--radius-lg); }
.portal-empty h2 { font-size: 1.25rem; margin-bottom: 8px; }
.portal-empty p { color: var(--color-text-muted); margin-bottom: 18px; }

/* ---------- Forms ---------- */
.field label, .field legend { display: block; font-size: 0.86rem; font-weight: 600; color: var(--color-text); margin-bottom: 6px; }
.field input:not([type=checkbox]):not([type=file]), .field select, .field textarea,
.toolbar input, .toolbar select, .step-cell input, .step-cell textarea, .step-cell select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface-2); color: var(--color-text); font-size: 0.95rem;
}
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .toolbar select:focus,
.step-cell input:focus, .step-cell textarea:focus, .step-cell select:focus { outline: 2px solid var(--blue-accent); outline-offset: 0; border-color: transparent; }
.field input[type=file] { font-size: 0.9rem; max-width: 100%; }
.field small { display: block; margin-top: 5px; color: var(--color-text-muted); font-size: 0.8rem; }
.field input:disabled { opacity: 0.6; }
.field fieldset { border: 0; padding: 0; margin: 0; }
.field .req { color: #ff9b9b; }
.is-invalid { border-color: #ff6b6b !important; box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.25); }
.field-grid { display: grid; grid-template-columns: 1fr; gap: 16px 20px; }
@media (min-width: 700px) {
  .field-grid { grid-template-columns: 1fr 1fr; }
  .field-grid > .field:not(.half) { grid-column: 1 / -1; }
}
.field.full { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; cursor: pointer; line-height: 1.45; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; accent-color: var(--blue-accent); }
.check-grid { display: grid; gap: 10px 20px; }
@media (min-width: 700px) { .check-grid.cols-2 { grid-template-columns: 1fr 1fr; } .check-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.check-view { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; color: var(--color-text-muted); }
.check-view.on { color: var(--color-text); }
.check-view .box { width: 18px; height: 18px; border: 1px solid var(--grey-500); border-radius: 3px; flex-shrink: 0; margin-top: 2px; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.check-view.on .box { background: var(--blue-accent); border-color: var(--blue-accent); color: #04121c; }
.view-value { padding: 2px 0; white-space: normal; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.form-actions form { display: inline; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; min-width: 160px; }

.seg { display: inline-flex; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 3px; }
.seg a { padding: 7px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.88rem; color: var(--color-text) !important; }
.seg a[aria-current="page"] { background: var(--color-primary); color: var(--white) !important; }
.seg a:hover { text-decoration: none !important; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); margin-bottom: 18px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); padding: 12px 16px; border-bottom: 1px solid var(--color-border); background: var(--color-surface-2); }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr.is-inactive td { opacity: 0.55; }
.data-table td.right > * + * { margin-left: 6px; }
.sig-img { height: 48px; width: auto; background: #fff; border-radius: 4px; padding: 2px; }

/* ---------- Auth pages ---------- */
.portal-bare .portal-main { display: grid; place-items: center; padding-top: 48px; }
.auth-card { width: 100%; max-width: 440px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 36px 32px; box-shadow: var(--shadow-lg); }
.auth-card-wide { max-width: 560px; }
.auth-card h1 { font-size: 1.7rem; margin: 4px 0 16px; }
.auth-logo { height: 40px; width: auto; margin-bottom: 26px; }
.auth-links { margin-top: 18px; text-align: center; font-size: 0.92rem; }
.auth-small { margin-top: 18px; font-size: 0.82rem; color: var(--color-text-muted); text-align: center; }

/* ---------- Dashboard ---------- */
.dash-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .dash-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .dash-grid { grid-template-columns: repeat(3, 1fr); } }
.dash-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 22px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.dash-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--blue-accent), var(--blue-800)); }
.dash-card h2 { font-size: 1.02rem; color: var(--color-heading); margin-bottom: 14px; }
.dash-body { flex: 1; }
.dash-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 18px; }
.dash-link { margin-left: auto; color: var(--color-link); font-weight: 600; font-size: 0.9rem; }
.dash-link:hover { text-decoration: underline; }
.big-num { font-size: 2.6rem; font-weight: 800; color: var(--white); line-height: 1; margin-bottom: 6px; }
.mini-list li { padding: 8px 0; border-bottom: 1px solid var(--color-border); font-size: 0.92rem; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list span { color: var(--color-text-muted); }

/* ---------- Roster ---------- */
.roster-day { margin-bottom: 22px; }
.roster-day h2 { font-size: 1rem; color: var(--color-text-muted); margin-bottom: 10px; font-weight: 600; }
.roster-day h2 span { color: var(--white); font-weight: 800; margin-right: 4px; }
.roster-day h2 em { font-style: normal; background: var(--blue-accent); color: #04121c; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; margin-left: 8px; vertical-align: middle; }
.roster-day ul { display: grid; gap: 10px; }
.shift { display: flex; gap: 18px; background: var(--color-surface); border: 1px solid var(--color-border); border-left: 3px solid var(--blue-accent); border-radius: var(--radius-md); padding: 14px 18px; }
.shift-time { font-weight: 800; color: var(--white); min-width: 74px; }
.shift-time span { display: block; font-weight: 500; font-size: 0.82rem; color: var(--color-text-muted); }
.shift-main strong { color: var(--white); }
.shift-crew { color: var(--color-heading); font-weight: 600; }
.shift-remark { margin-top: 6px; font-size: 0.86rem; color: var(--color-text-muted); }

/* ---------- Documents ---------- */
.doc-group { margin-bottom: 28px; }
.doc-group > h2 { font-size: 1.05rem; color: var(--color-heading); margin-bottom: 10px; }
.doc-list { display: grid; gap: 10px; }
.doc-item { display: flex; gap: 16px; align-items: flex-start; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 16px 18px; }
.doc-main { flex: 1; min-width: 0; }
.doc-title { font-weight: 700; font-size: 1.02rem; color: var(--white) !important; }
.doc-meta { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 2px; }
.doc-desc { font-size: 0.9rem; margin-top: 6px; color: var(--color-text-muted); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.file-icon { flex-shrink: 0; width: 44px; height: 52px; border-radius: 6px; display: grid; place-items: center; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em; background: var(--color-surface-4); color: var(--white); }
.file-pdf { background: #b42318; } .file-doc { background: #1d5bd8; } .file-xls { background: #137a3e; } .file-ppt { background: #c4510f; } .file-img, .file-mp4 { background: #6941c6; }
@media (max-width: 640px) { .doc-item { flex-wrap: wrap; } .doc-actions { width: 100%; justify-content: flex-start; } }
.upload-panel > summary { cursor: pointer; list-style: none; }
.upload-panel > summary::before { content: "+ "; color: var(--blue-accent); font-weight: 800; }
.upload-panel[open] > summary { margin-bottom: 18px; }
.row-menu { position: relative; display: inline-block; text-align: left; }
.row-menu > summary { list-style: none; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu-body { position: absolute; right: 0; top: calc(100% + 6px); width: 320px; z-index: 30; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-lg); display: grid; gap: 18px; }
.row-menu-body form + form { border-top: 1px solid var(--color-border); padding-top: 16px; }
.row-menu-actions { display: flex; gap: 8px; border-top: 1px solid var(--color-border); padding-top: 14px; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row input { flex: 1; padding: 8px 10px; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 4px; color: var(--color-text); font-family: monospace; font-size: 0.82rem; }

/* ---------- Access levels ---------- */
.role-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 14px; }
.role-head .field { min-width: 200px; }
.role-head .grow { flex: 1; }
.perm-grid { display: grid; gap: 18px; margin-bottom: 16px; }
@media (min-width: 800px) { .perm-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .perm-grid { grid-template-columns: repeat(4, 1fr); } }
.perm-grid fieldset { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 12px 14px 14px; display: grid; gap: 9px; }
.perm-grid legend { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-heading); padding: 0 6px; }
.check-list li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.check-list li > span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; font-size: 0.85rem; }
.check-list .ok > span { background: rgba(34, 160, 90, 0.25); color: #8ee0b2; }
.check-list .bad > span { background: rgba(240, 170, 40, 0.22); color: #f8d38a; }
.detail-list { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin-bottom: 20px; font-size: 0.94rem; }
.detail-list dt { color: var(--color-text-muted); }

/* ---------- SWMS / JSA ---------- */
.choice-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.choice-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.choice-card h3 { font-size: 1.15rem; }
.choice-card p { flex: 1; font-size: 0.9rem; }
.choice-card .btn { align-self: flex-start; }
.choice-blank { border-style: dashed; }
.form-status { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; font-size: 0.86rem; color: var(--color-text-muted); margin: -8px 0 20px; }
.form-section h2 { display: flex; align-items: center; gap: 12px; }
.sec-num { width: 28px; height: 28px; border-radius: 50%; background: var(--color-primary); color: var(--white); display: grid; place-items: center; font-size: 0.85rem; flex-shrink: 0; }
.form-section > .muted.small { margin: -6px 0 16px; }

.steps-head { display: none; }
.steps-body { list-style: none; display: grid; gap: 12px; margin-bottom: 12px; }
.step-row { position: relative; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px 14px 14px 46px; display: grid; gap: 10px; }
.step-row .steps-num { position: absolute; left: 12px; top: 14px; width: 24px; height: 24px; border-radius: 50%; background: var(--color-surface-4); display: grid; place-items: center; font-size: 0.78rem; font-weight: 700; }
.step-label { display: block; font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 4px; }
.step-cell textarea { resize: vertical; min-height: 64px; font-size: 0.9rem; line-height: 1.45; }
.steps-tools { display: flex; gap: 6px; justify-content: flex-end; }
.steps-tools button { width: 32px; height: 32px; border-radius: 4px; border: 1px solid var(--color-border); background: var(--color-surface-3); color: var(--color-text); font-size: 0.9rem; }
.steps-tools button:hover { background: var(--color-surface-4); }
.steps-tools button[data-step-remove]:hover { background: #b42318; color: #fff; }
@media (min-width: 1000px) {
  .steps-head { display: flex; gap: 10px; padding: 0 10px 8px 46px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
  .steps-head > span:not(.steps-num) { flex: var(--w) 1 0; }
  .steps-head .steps-num { display: none; }
  .steps-head .steps-tools { flex: 0 0 106px; }
  .step-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 10px 10px 46px; }
  .step-cell { flex: var(--w) 1 0; min-width: 0; }
  .step-label { display: none; }
  .step-row .steps-tools { flex: 0 0 106px; padding-top: 4px; }
  .step-row .steps-num { top: 18px; }
}
.risk-select[data-risk="L"], .risk-L { background: rgba(34, 160, 90, 0.28) !important; color: #b8f0cf; }
.risk-select[data-risk="M"], .risk-M { background: rgba(240, 200, 40, 0.26) !important; color: #fbe7a1; }
.risk-select[data-risk="H"], .risk-H { background: rgba(240, 120, 30, 0.32) !important; color: #ffd0a8; }
.risk-select[data-risk="E"], .risk-E { background: rgba(220, 40, 40, 0.38) !important; color: #ffc4c4; }
span.risk { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 0.8rem; font-weight: 700; }
.risk-help { margin-top: 10px; font-size: 0.9rem; }
.risk-help summary { cursor: pointer; color: var(--color-link); font-weight: 600; }
.risk-matrix { border-collapse: collapse; margin: 12px 0; font-size: 0.82rem; width: 100%; max-width: 720px; }
.risk-matrix th, .risk-matrix td { border: 1px solid var(--color-border); padding: 6px 8px; text-align: center; }
.risk-matrix th { background: var(--color-surface-3); font-weight: 600; }
.risk-matrix small { font-weight: 400; color: var(--color-text-muted); }

.sticky-actions { position: sticky; bottom: 0; z-index: 20; background: rgba(10, 10, 13, 0.92); backdrop-filter: blur(8px); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 12px 16px; margin-bottom: 20px; }
.form-footer-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.form-footer-actions form { display: inline; }
.form-footer-actions .btn-danger { margin-left: auto; }

.sign-box { margin-top: 22px; border-top: 1px solid var(--color-border); padding-top: 20px; display: grid; gap: 16px; max-width: 560px; }
.sign-box h3 { font-size: 1.1rem; }
.sig-pad { position: relative; }
.sig-pad canvas { width: 100%; height: 180px; background: #fff; border-radius: var(--radius-md); touch-action: none; cursor: crosshair; display: block; }
.sig-pad button { position: absolute; top: 8px; right: 8px; background: #fff; color: #0b1f3a; border-color: #ccd; }

/* ---------- Print ---------- */
.print-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.print-head { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body.portal { background: #fff !important; color: #111 !important; font-size: 10.5pt; }
  .portal-header, .portal-footer, .no-print, .print-bar, .sign-box, .risk-help summary { display: none !important; }
  .portal-main { padding: 0; max-width: none; }
  * { color: #111 !important; box-shadow: none !important; }
  h1, h2, h3, .doc-title { color: #000 !important; }
  .print-head { display: flex; gap: 16px; align-items: center; border-bottom: 2px solid #0b54a6; padding-bottom: 10px; margin-bottom: 14px; }
  .print-head img { height: 42px; width: auto; }
  .print-head h1 { font-size: 16pt; }
  .panel, .step-row, .table-wrap { background: #fff !important; border: 1px solid #bbb !important; border-radius: 4px; break-inside: avoid; padding: 10px 12px; margin-bottom: 10px; }
  .form-section { break-inside: auto; }
  .sec-num { background: #0b54a6 !important; color: #fff !important; }
  .check-view.on .box { background: #0b54a6 !important; color: #fff !important; }
  .steps-head { display: flex !important; gap: 8px; padding: 0 8px 4px 34px; font-size: 7.5pt; font-weight: 700; text-transform: uppercase; }
  .steps-head > span:not(.steps-num) { flex: var(--w) 1 0; }
  .steps-head .steps-num { display: none; }
  .step-row { display: flex !important; gap: 8px; padding: 6px 6px 6px 34px !important; font-size: 9pt; }
  .step-cell { flex: var(--w) 1 0; min-width: 0; }
  .step-label { display: none; }
  .step-row .steps-num { left: 6px; top: 6px; background: #ddd !important; }
  .risk-L { background: #c9f0d6 !important; } .risk-M { background: #fbeaa6 !important; } .risk-H { background: #ffd2ad !important; } .risk-E { background: #ffbcbc !important; }
  .field-grid { grid-template-columns: 1fr 1fr !important; gap: 6px 14px; }
  .check-grid.cols-2, .check-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr !important; gap: 3px 10px; font-size: 8.5pt; }
  .badge { border: 1px solid #999; }
  span.risk { font-size: 7pt; padding: 1px 4px; }
  .step-cell { overflow-wrap: anywhere; }
  a { text-decoration: none !important; }
}

/* Public stylesheet gives every <section> 72px padding; portal sections manage their own */
.portal-main section { padding-block: 0; }
.portal-main section.panel, .portal-main section.dash-card { padding: 24px; }
.portal-main section.dash-card { padding: 22px; }
.field-grid > .steps { grid-column: 1 / -1; }
.step-cell select.risk-select { padding: 10px 4px 10px 8px; font-size: 0.85rem; }
.perm-grid fieldset { align-content: start; }


/* ---------- Calendar (Rentman) ---------- */
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav h2 { font-size: 1.3rem; min-width: 170px; text-align: center; }
.cal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cal-legend { margin-bottom: 12px; display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; }
.cal-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.cal-key-shift { background: var(--blue-accent); }
.cal-key-avail { background: rgba(240, 170, 40, 0.8); }
.cal { border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); overflow: visible; }
.cal-head, .cal-body { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: 10px 8px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); background: var(--color-surface-2); border-bottom: 1px solid var(--color-border); text-align: center; }
.cal-head div:first-child { border-top-left-radius: var(--radius-lg); }
.cal-head div:last-child { border-top-right-radius: var(--radius-lg); }
.cal-day { min-height: 112px; padding: 6px; border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.is-other { background: rgba(0, 0, 0, 0.18); }
.cal-day.is-other .cal-date { opacity: 0.45; }
.cal-date { font-weight: 700; font-size: 0.85rem; color: var(--color-text); padding: 2px 4px; }
.cal-dow, .cal-mon { display: none; }
.cal-day.is-today .cal-date { color: #04121c; background: var(--blue-accent); border-radius: 999px; align-self: flex-start; padding: 2px 9px; }
.cal-ev { position: relative; --ev: var(--blue-accent); }
.cal-ev > summary { list-style: none; cursor: pointer; display: block; padding: 4px 7px; border-radius: 5px; background: color-mix(in srgb, var(--ev) 22%, transparent); border-left: 3px solid var(--ev); font-size: 0.78rem; line-height: 1.3; overflow: hidden; }
.cal-ev > summary::-webkit-details-marker { display: none; }
.cal-ev > summary:hover { background: color-mix(in srgb, var(--ev) 34%, transparent); }
.cal-ev.is-cont > summary { opacity: 0.7; border-left-style: dashed; }
.cal-ev-avail { --ev: rgb(240, 170, 40); }
.cal-ev-title { display: block; font-weight: 700; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev-sub { display: block; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-pop { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 280px; max-width: 80vw; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 14px 16px; font-size: 0.86rem; }
.cal-day:nth-child(7n) .cal-pop, .cal-day:nth-child(7n-1) .cal-pop { left: auto; right: 0; }
.cal-pop strong { color: var(--white); display: block; margin-bottom: 8px; }
.cal-pop dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; }
.cal-pop dt { color: var(--color-text-muted); }
.cal-pop dd { margin: 0; color: var(--color-text); word-break: break-word; }
.cal-links { margin-top: 10px; display: flex; gap: 14px; }
.copy-row { display: flex; gap: 8px; margin-top: 12px; }
.copy-row input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface-2); color: var(--color-text); font-size: 0.85rem; }
.shift-venue { margin-top: 4px; font-size: 0.86rem; color: var(--color-text); }
@media (max-width: 760px) {
  .cal-head { display: none; }
  .cal-body { display: block; }
  .cal-day { min-height: 0; border-right: 0; padding: 10px 12px; }
  .cal-day.is-empty, .cal-day.is-other.is-empty { display: none; }
  .cal-dow, .cal-mon { display: inline; }
  .cal-pop { position: static; width: auto; max-width: none; margin-top: 6px; box-shadow: none; }
  .cal-nav h2 { min-width: 0; font-size: 1.1rem; }
}

/* ---------- To-do list ---------- */
.todo-add { display: flex; gap: 8px; flex-wrap: wrap; }
.todo-add input[type=text] { flex: 1 1 320px; }
.todo-add input, .todo-edit input, .desk-opts select { padding: 10px 12px; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text); font: inherit; color-scheme: dark; }
.todo-list { list-style: none; margin-top: 14px; }
.todo-list li { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--color-border); }
.todo-list li:first-child { border-top: 0; }
.todo-list form { display: contents; }
.todo-edit { display: flex !important; gap: 8px; flex: 1; flex-wrap: wrap; }
.todo-edit input[type=text] { flex: 1 1 260px; }
.todo-tick { width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--color-text-muted); background: transparent; cursor: pointer; }
.todo-tick:hover { border-color: #3cc98a; background: rgba(60, 201, 138, 0.15); }
.is-done .todo-tick { background: #3cc98a; border-color: #3cc98a; }
.is-done .todo-title { text-decoration: line-through; color: var(--color-text-muted); }
.todo-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.todo-due { font-size: 0.82rem; color: var(--color-text-muted); white-space: nowrap; }
.todo-due-today, .todo-due-soon { color: #f0aa28; }
.todo-due-late { color: #ef5a5a; font-weight: 700; }
.todo-act { background: none; border: 0; padding: 0; font: inherit; font-size: 0.82rem; color: var(--color-text-muted) !important; cursor: pointer; }
.todo-act:hover { color: var(--color-link) !important; text-decoration: underline; }
.todo-done { margin-top: 16px; }
.todo-done summary { cursor: pointer; color: var(--color-text-muted); font-size: 0.9rem; margin-bottom: 4px; }
.todo-done > form { margin-top: 10px; }
.desk-opts { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin: 14px 0 6px; }
.desk-opts label { display: grid; gap: 4px; font-size: 0.82rem; font-weight: 600; color: var(--color-text-muted); }
.desk-steps { margin: 8px 0 0 22px; display: grid; gap: 6px; list-style: decimal; }
.desk-steps li { padding-left: 4px; }
@media (max-width: 600px) { .todo-act { display: none; } }

/* ---------- Licences ---------- */
.pill-bad { background: rgba(220, 60, 60, 0.18); color: #ffb0b0; }
.pill-btn { border: 0; cursor: pointer; font: inherit; font-size: 0.76rem; font-weight: 700; }
.inline-form { display: inline; }
.inline-check { display: inline-flex; gap: 4px; align-items: center; font-weight: 400; }
.lic-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); margin-bottom: 20px; }
.lic-card { background: var(--color-surface); border: 1px solid var(--color-border); border-left: 4px solid #3cc98a; border-radius: var(--radius-lg); padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 10px; }
.lic-card.lic-soon { border-left-color: #f0aa28; }
.lic-card.lic-expired { border-left-color: #ef5a5a; }
.lic-card.lic-none { border-left-color: var(--color-surface-4); }
.lic-card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.lic-card h2 { font-size: 1.02rem; }
.lic-card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 0.9rem; margin: 0; }
.lic-card dt { color: var(--color-text-muted); }
.lic-card dd { margin: 0; overflow-wrap: anywhere; }
.lic-card footer { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--color-border); }
.lic-verified { margin: 0; }
