/* Tajmee'e HSE portal — shared styles (matches Tadweer brand) */
@font-face {
    font-family: 'Degular';
    src: url('/Degular-Black.otf') format('opentype');
    font-weight: 900;
    font-style: normal;
}

:root {
    /* Tajmee'e palette (from the Tajmee'e brand artwork) */
    --tj-deep: #0e2c2c;         /* forest teal, main dark */
    --tj-deeper: #081b1c;       /* darkest teal, app bar */
    --tj-green: #26c27f;        /* Tajmee'e green */
    --tj-green-hover: #1fb072;
    --tj-green-ink: #062016;    /* text on green */
    --tj-green-soft: #e3f6ec;
    --tadweer-dark: #0f2a2b;
    --tadweer-green: #26d07c;
    --tadweer-blue: #0072e0;
    --tadweer-white: #ffffff;
    --tadweer-orange: #ff9518;
    --tadweer-purple: #901484;
    --tadweer-yellow: #ffb81c;
    --tadweer-grey: #8b8b8a;

    /* Location type colours */
    --type-office: #0072e0;
    --type-workshop: #26d07c;
    --type-camp: #ffb81c;
    --type-wcp: #901484;

    --ink: #152628;
    --muted: #5a6b68;
    --line: #dfe7e4;
    --field: #c8d5d0;
    --soft: #f6f9f8;
    --app-bg: #edf2f0;
    --surface: #ffffff;
    --head: #f3f7f5;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16,24,32,.05), 0 1px 3px rgba(16,24,32,.04);
    --brand-gradient: linear-gradient(90deg, #0a7fe3, #18a6b8 45%, #2ccf86);
    --band-h: 210px;
    --waves: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='44' viewBox='0 0 220 44'%3E%3Cpath d='M0 22c27.5 0 27.5-14 55-14s27.5 14 55 14 27.5-14 55-14 27.5 14 55 14' fill='none' stroke='%23ffffff' stroke-opacity='.045' stroke-width='1.2'/%3E%3C/svg%3E");
    --body-font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    --display-font: 'Degular', "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    font-family: var(--body-font);
    font-size: 14px;
    line-height: 1.45;
    color: var(--ink);
    background-color: var(--app-bg);
    background-image: var(--waves), linear-gradient(180deg, var(--tj-deep) 0, #12403e var(--band-h), var(--app-bg) var(--band-h));
    background-size: 220px 44px, 100% 100%;
    background-repeat: repeat, no-repeat;
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
h1 { font-family: var(--display-font); letter-spacing: .3px; }
h2, h3, h4 { font-weight: 650; letter-spacing: 0; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px 40px; }
.content { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.content + .content { margin-top: 16px; }

/* App bar */
.appbar { background: var(--tj-deeper); position: sticky; top: 0; z-index: 30; }
.appbar::after { content: ""; display: block; height: 3px; background: var(--brand-gradient); }
.appbar-in { max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.appbar-brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: white; min-width: 0; }
.appbar-brand img { height: 34px; display: block; }
.appbar-name { padding-left: 14px; border-left: 1px solid rgba(255,255,255,.2); font-size: 15px; font-weight: 600; white-space: nowrap; color: #dff3ea; }
.appbar-user { display: flex; align-items: center; gap: 14px; min-width: 0; }
.appbar-user .who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; min-width: 0; }
.appbar-user .who b { color: white; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.appbar-user .who small { color: #8fb5a8; font-size: 12px; white-space: nowrap; }
.appbar-out { background: transparent; color: white; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.appbar-out:hover { background: var(--tj-green); border-color: var(--tj-green); color: var(--tj-green-ink); }
.appbar-out:focus-visible, .appbar-brand:focus-visible { outline: 3px solid var(--tadweer-green); outline-offset: 2px; }

/* Page heading */
.page-head { padding: 20px 0 22px; }
.page-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.back-btn { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.28); color: white; border-radius: 8px; padding: 6px 12px 6px 8px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.back-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.back-btn:hover { background: var(--tj-green); border-color: var(--tj-green); color: var(--tj-green-ink); }
.back-btn:focus-visible { outline: 3px solid var(--tj-green); outline-offset: 2px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: #9cbdb2; }
.crumbs a { color: #9cbdb2; text-decoration: none; }
.crumbs a:hover { color: white; text-decoration: underline; }
.crumbs .sep { color: #5d8579; }
.crumbs [aria-current] { color: white; font-weight: 600; }
.title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.title-row h1 { margin: 0; font-size: 30px; line-height: 1.15; color: white; }
.page-sub { margin: 4px 0 0; color: #a9cbbf; font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
a.btn { text-decoration: none; display: inline-block; text-align: center; }
.btn { border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; font-family: var(--body-font); font-size: 14px; font-weight: 600; line-height: 1.3; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tile:focus-visible, .type-option input:focus-visible + span { outline: 3px solid var(--tj-green); outline-offset: 2px; }
.btn-primary { background: var(--tj-green); color: var(--tj-green-ink); }
.btn-primary:hover { background: var(--tj-green-hover); }
.btn-blue { background: var(--tadweer-blue); color: white; }
.btn-blue:hover { background: #005fc0; }
.btn-ghost { background: rgba(255,255,255,0.12); color: white; border: 1px solid rgba(255,255,255,0.45); }
.btn-ghost:hover { background: var(--tj-green); color: var(--tj-green-ink); }
.btn-light { background: var(--surface); color: var(--ink); border-color: var(--field); }
.btn-light:hover { border-color: var(--tj-green-hover); color: #0f7a4c; }
.btn-danger { background: var(--surface); color: #b42318; border-color: #f1b3ad; }
.btn-danger:hover { background: #fef3f2; }
.btn-edit { background: var(--surface); color: var(--tadweer-blue); border-color: #b9d6f5; }
.btn-edit:hover { background: #eff6fe; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }

/* Forms */
.form-group { margin-bottom: 15px; }
.form-group label, .label { font-size: 13px; font-weight: 600; color: #3d4956; display: block; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
    width: 100%; padding: 9px 12px; font-size: 15px; border: 1px solid var(--field); border-radius: 8px; background: white; color: var(--ink); font-family: inherit;
}
input:hover, select:hover, textarea:hover { border-color: #aab6c3; }
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.panel { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }

/* Location type picker (coloured options) */
.type-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.type-option { position: relative; }
.type-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.type-option span { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid var(--field); border-radius: 8px; background: white; font-weight: 600; font-size: 14px; }
.type-option span::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.type-option input:checked + span { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); background: color-mix(in srgb, var(--c) 9%, white); }

.type-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.type-tag { display: flex; margin-top: 2px; align-items: center; font-size: 11px; font-weight: 600; color: var(--muted); }

/* Tiles (portal + management menus) */
.tiles { display: flex; flex-direction: column; gap: 12px; }
.tile { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 16px 20px; border: 1px solid var(--line); border-left: 4px solid var(--accent, var(--tadweer-blue)); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; text-decoration: none; color: var(--tadweer-dark); text-align: left; font: inherit; }
.tile:hover { border-color: var(--accent, var(--tadweer-blue)); }
.tile-title { font-size: 16px; font-weight: 650; display: block; }
.tile-desc { font-size: 13px; color: var(--muted); display: block; margin-top: 3px; }
.tile-arrow { color: var(--accent, var(--tadweer-blue)); font-size: 18px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--head); color: #4a5665; text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; word-wrap: break-word; }
tbody tr:hover td { background: #f8fbfa; }
tr.group td { background: #e8f0ec; color: var(--tadweer-dark); font-weight: 650; text-align: left; font-size: 13px; padding: 8px 12px; }
tr.focus-row td { background: #eef9f3; }
tr.focus-row td:first-child { box-shadow: inset 4px 0 0 var(--tj-green); }
td.loc-cell { border-left: 5px solid var(--c, transparent); }
a.loc-link { color: var(--tadweer-dark); font-weight: 600; text-decoration: none; }
a.loc-link:hover { color: var(--tadweer-blue); text-decoration: underline; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Status pills */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill-open { background: #ffedd5; color: #9a3412; }
.pill-over { background: #fee2e2; color: #991b1b; }
.pill-closed { background: #d1fae5; color: #065f46; }
.pill-mine { background: #dcfce7; color: #166534; }
.pill-other { background: #e2e8f0; color: #334155; }

/* Map */
.map-bar { background: var(--head); color: var(--ink); padding: 9px 14px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.map { width: 100%; height: 380px; border: 1px solid var(--line); border-top: none; border-radius: 0 0 var(--radius) var(--radius); background: #e8ecf0; margin-bottom: 18px; z-index: 1; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-weight: 500; font-size: 12px; color: var(--muted); }

/* Input with a button beside it */
.input-with-btn { display: flex; gap: 8px; align-items: center; }
.input-with-btn input { flex: 1; }

/* Map pop-ups */
.pop { font-family: var(--body-font); font-size: 13px; line-height: 1.5; color: var(--ink); min-width: 170px; }
.pop b { font-size: 14px; }
.map.gm-on { border-top: 1px solid var(--line); }

/* Toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar > input, .toolbar > select { flex: 1; min-width: 160px; }

/* Lists (management) */
.list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-height: 520px; overflow-y: auto; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 13px; border-bottom: 1px solid var(--line); font-size: 14px; }
.list-item:last-child { border-bottom: none; }
.list-item .meta { font-size: 12px; color: var(--muted); }

/* Modal (report questionnaire) */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,32,0.6); display: none; align-items: center; justify-content: center; padding: 15px; z-index: 1000; }
.modal-backdrop.open { display: flex; }
.modal { background: white; width: 100%; max-width: 560px; border-radius: 12px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.3); max-height: calc(100vh - 30px); display: flex; flex-direction: column; }
.modal-head { background: var(--brand-gradient) bottom / 100% 4px no-repeat, var(--waves) top left / 220px 44px repeat, var(--tj-deep); color: white; padding: 16px 20px 20px; }
.modal-head h3 { margin: 0; font-size: 1.15rem; font-weight: 650; }
.modal-head .sub { font-size: 13px; color: #94a3b8; margin-top: 4px; }
.progress { height: 5px; background: #e2e8f0; }
.progress > div { height: 100%; background: var(--brand-gradient); transition: width .2s; }
.modal-body { padding: 22px 20px; overflow-y: auto; }
.modal-body h4 { margin: 0 0 14px; font-size: 1.1rem; color: var(--tadweer-dark); }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--soft); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-grid.three { grid-template-columns: repeat(3, 1fr); }
.choice { border: 1px solid var(--field); border-radius: 10px; padding: 18px 14px; background: white; cursor: pointer; text-align: left; font: inherit; }
.choice b { display: block; font-size: 16px; font-weight: 650; color: var(--tadweer-dark); margin-bottom: 2px; }
.choice small { color: var(--muted); font-size: 13px; }
.choice.selected { border-color: var(--tj-green-hover); box-shadow: inset 0 0 0 1px var(--tj-green-hover); background: var(--tj-green-soft); }
.review dt { font-size: 12px; font-weight: bold; color: var(--muted); margin-top: 12px; }
.review dd { margin: 3px 0 0; font-size: 15px; white-space: pre-wrap; }

/* Risk letter badge */
.risk-badge { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; background: var(--r); color: white; font-weight: 700; font-size: 14px; flex-shrink: 0; }

/* Custom select (risk picker) */
.picker { position: relative; }
.picker-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; min-height: 48px; font: inherit; font-size: 16px; text-align: left; border: 1px solid var(--field); border-radius: 8px; background: white; cursor: pointer; color: var(--ink); }
.picker-btn .placeholder { color: var(--muted); }
.picker-btn::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-3px); flex-shrink: 0; }
.picker-list { position: static; margin-top: 6px; background: white; border: 1px solid var(--field); border-radius: 8px; box-shadow: 0 12px 30px rgba(16,24,32,0.18); z-index: 5; padding: 4px; margin: 0; list-style: none; }
.picker-list li { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1.35; }
.picker-list li:hover, .picker-list li.active { background: #f1f5f9; }
.picker-list li[aria-selected="true"] { background: #eff6ff; }

/* Notice */
.notice { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 0 0 14px; }

/* Email backup panel */
.email-panel { position: fixed; right: 16px; bottom: 16px; z-index: 1500; width: min(400px, calc(100% - 32px)); background: white; border: 1px solid var(--field); border-top: 4px solid var(--tj-green); border-radius: 12px; box-shadow: 0 16px 40px rgba(16,24,32,0.25); padding: 16px 18px; display: none; font-size: 14px; }
.email-panel.open { display: block; }
.email-panel b { display: block; font-size: 15px; color: var(--tadweer-dark); padding-right: 28px; }
.email-panel p { margin: 8px 0 0; color: var(--ink); line-height: 1.45; }
.email-panel .email-panel-q { font-weight: 600; margin-top: 12px; }
.email-panel-warn { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e !important; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.email-panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.email-panel .file-name { font-weight: 600; word-break: break-all; }
.email-panel .email-panel-to { font-size: 13px; color: var(--muted); }
.email-panel-close { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border: none; background: #f1f5f9; border-radius: 50%; font-size: 18px; cursor: pointer; line-height: 1; }

/* Email buttons */
.btn-email { background: var(--tj-deep); color: white; }
.btn-email:hover { background: var(--tj-deeper); }
.btn-reminder { background: #fef3c7; color: #92400e; border: 1px solid #f59e0b; }
.btn-urgent { background: #dc2626; color: white; }

/* WCP View toggle on maps (same as Tadweer) */
.wcp-toggle { background: white; color: var(--tadweer-dark); border-color: var(--field); }
.wcp-toggle[aria-pressed="true"] { background: var(--tadweer-purple); color: white; }
.map-bar .bar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Menu sections */
.nav-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; align-items: start; }
.nav-section { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.nav-section > h3 { margin: 0; padding: 14px 16px 12px; color: var(--tadweer-dark); font-size: 16px; border-bottom: 1px solid var(--line); }
.nav-group { padding: 6px 8px 10px; }
.nav-group + .nav-group { border-top: 1px solid var(--line); }
.nav-group-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 8px 4px; }
.nav-group-title small { font-weight: 600; color: var(--muted); }
.nav-link { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 10px; text-decoration: none; color: var(--tadweer-dark); }
.nav-link:hover { background: var(--soft); }
.nav-link:hover .arrow { transform: translateX(3px); }
.nav-link:focus-visible { outline: 3px solid var(--tadweer-blue); outline-offset: 1px; }
.nav-link .txt { min-width: 0; }
.nav-link b { display: block; font-size: 14px; font-weight: 650; }
.nav-link span.d { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.nav-link .arrow { color: #a3afbd; transition: transform .15s, color .15s; }
.nav-link:hover .arrow { color: #13915a; }
.ic { width: 36px; height: 36px; padding: 8px; border-radius: 9px; background: var(--tj-green-soft); fill: none; stroke: #13915a; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-section[data-sec="report"] .ic { background: #e6f1fd; stroke: var(--tadweer-blue); }
.nav-section[data-sec="documents"] .ic { background: #f1f5f9; stroke: #475569; }

/* Demo mode banner */
.demo-banner { display: flex; justify-content: center; align-items: center; gap: 8px 18px; flex-wrap: wrap; background: #fff4d6; color: #6b4a00; border-bottom: 1px solid #f3d27a; padding: 8px 24px; font-size: 13px; }
.demo-banner .demo-actions { display: flex; gap: 8px; align-items: center; }
.demo-banner a { color: var(--tadweer-dark); font-weight: 600; }
.demo-banner a { color: #6b4a00; }
.demo-view { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.demo-view select { width: auto; padding: 3px 8px; font-size: 13px; border-color: #c79a2a; }
.demo-banner button { border: 1px solid #c79a2a; background: white; color: #6b4a00; border-radius: 6px; padding: 4px 10px; font: inherit; font-weight: 600; cursor: pointer; }

/* Date and month navigator */
.stepper { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; }
.stepper .arrow, .stepper > button:not(.today-btn) { width: 38px; height: 38px; flex-shrink: 0; border-radius: 8px; border: 1px solid var(--field); background: white; color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; }
.stepper .arrow:hover:not(:disabled), .stepper > button:not(.today-btn):hover:not(:disabled) { border-color: var(--tadweer-blue); color: var(--tadweer-blue); }
.stepper button:disabled { opacity: .35; cursor: not-allowed; }
.stepper .step-label, .stepper > b { flex: 1; text-align: center; color: var(--tadweer-dark); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--tj-deeper); color: white; padding: 12px 18px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 2000; border-left: 4px solid var(--tadweer-green); max-width: calc(100% - 30px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-left-color: #f87171; }

.loading { color: var(--muted); padding: 30px; text-align: center; }
.hidden { display: none !important; }

@media (max-width: 700px) {
    .container { padding: 0 10px 28px; }
    .appbar-in { padding: 0 12px; height: 54px; }
    .appbar-brand img { height: 26px; }
    .appbar-name { display: none; }
    .appbar-user .who small { display: none; }
    .appbar-user .who b { max-width: 130px; font-size: 13px; }
    .page-head { padding: 12px 2px 14px; }
    .title-row h1 { font-size: 22px; }
    .content { padding: 14px; }
    td, th { padding: 8px; font-size: 12px; }
    .choice-grid, .choice-grid.three { grid-template-columns: 1fr; }
    .map { height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
