:root {
    --ink: #1d2733;
    --ink-soft: #55606d;
    --line: #dfe3e8;
    --paper: #f5f6f8;
    --card: #ffffff;
    /* Evexia Home brand */
    --brand-blue: #2f6ba6;
    --brand-red: #9f2a44;
    --accent: var(--brand-blue);
    --accent-soft: #e6eef7;
    --accent-dark: #24527f;
    --danger: #b42318;
    --highlight: #fff7d6;
}

html { font-size: 15px; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

.btn-primary { background-color: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active { background-color: var(--accent-dark) !important; border-color: var(--accent-dark) !important; }
.btn-outline-primary { color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover, .btn-outline-primary:active { color: #fff !important; background-color: var(--accent) !important; border-color: var(--accent) !important; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(47, 107, 166, .18); }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(47, 107, 166, .18); }

/* ---- header ---- */
.app-header { background: #fff; border-bottom: 1px solid var(--line); padding: .8rem 0; box-shadow: 0 1px 0 rgba(29,39,51,.03); }
.app-header::before { content: ""; display: block; height: 4px; margin-top: -.8rem; margin-bottom: .8rem;
    background: linear-gradient(90deg, var(--brand-blue) 0 68%, var(--brand-red) 68% 100%); }
.brand { text-decoration: none; display: flex; align-items: center; gap: .9rem; }
.brand-logo { height: 36px; width: auto; display: block; }
.brand-divider { width: 1px; height: 28px; background: var(--line); }
.brand-app { color: var(--ink-soft); font-weight: 600; font-size: 1rem; letter-spacing: .01em; white-space: nowrap; }
.app-nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
.app-nav a { color: var(--ink-soft); text-decoration: none; padding: .4rem .75rem; border-radius: 6px; font-weight: 500; }
.app-nav a:hover { color: var(--ink); background: var(--paper); }
.app-nav a.active { color: var(--brand-blue); background: var(--accent-soft); }
@media (max-width: 575.98px) {
    .brand-logo { height: 26px; }
    .brand-divider, .brand-app { display: none; }
    .app-nav { margin-left: 0; }
}

h1, .h1 { font-size: 1.6rem; font-weight: 650; }
/* Intro and instruction text share one width, so they end at the same point on every page. */
.page-intro { color: var(--ink-soft); max-width: 58rem; }

/* ---- schedule grid (home) ---- */
.group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 1.6rem 0 .6rem; font-weight: 600; }
.period-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.period-tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.period-tile:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-1px); }
.period-tile .name { font-weight: 650; font-size: 1.05rem; }
.period-tile .counts { font-size: .82rem; color: var(--ink-soft); margin-top: .15rem; }
.period-tile.empty { border-style: dashed; background: transparent; }

/* ---- period editor ---- */
.period-bar {
    position: sticky; top: 0; z-index: 20;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
    background: var(--paper); padding: .6rem 0; margin-bottom: .6rem; border-bottom: 1px solid var(--line);
}
.period-title { margin: 0; font-size: 1.5rem; }
.crumb { color: var(--ink-soft); text-decoration: none; }
.crumb:hover { color: var(--accent); }
.crumb-sep { color: #a0a8b1; }
.hint { color: var(--ink-soft); font-size: .9rem; max-width: 58rem; }

.ref { font-family: Consolas, "Cascadia Mono", monospace; font-size: .8rem; background: var(--accent-soft); color: var(--accent); padding: .05rem .4rem; border-radius: 4px; font-weight: 600; }

.question-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem 1.1rem; margin-bottom: 1rem; scroll-margin-top: 80px; }
.question-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.q-number { width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 600; font-size: .85rem; display: inline-flex; align-items: center; justify-content: center; }
.field-label { font-size: .78rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .25rem; display: block; }
.question-text { font-size: 1.05rem; font-weight: 500; }
.field-help { font-size: .78rem; color: #8a939d; margin-top: .25rem; }
.time-input { max-width: 11rem; font-variant-numeric: tabular-nums; }
.time-input.needs-time { border-color: #e0a800; box-shadow: 0 0 0 .2rem rgba(224, 168, 0, .25); }

.discussion { margin-top: .8rem; padding: .6rem .75rem .7rem; border-radius: 8px; background: #fbf8ef; border: 1px dashed #e2d6ad; scroll-margin-top: 80px; }
.discussion-open { background: #fff6d9; border-style: solid; border-color: #e7c96a; }
.discussion-resolved { background: #f3f8f4; border-style: solid; border-color: #b9dcc4; }
.discussion-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.notes-tag { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: .78rem; color: #8a6d00; }
.discussion-status { font-size: .78rem; font-weight: 600; padding: .05rem .45rem; border-radius: 999px; }
.status-open { background: #ffe9a6; color: #6b5300; }
.status-resolved { background: #d9efe0; color: #1f6b3d; }
.comment-list { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .4rem; }
.comment { background: #fff; border: 1px solid #ece4c8; border-radius: 8px; padding: .45rem .65rem; }
.discussion-resolved .comment { border-color: #d5e8db; }
.comment-meta { display: flex; align-items: baseline; gap: .5rem; font-size: .78rem; color: var(--ink-soft); }
.comment-author { font-weight: 600; color: var(--ink); }
.comment-delete { margin-left: auto; border: none; background: none; padding: 0; font-size: .75rem; color: #98a1ab; }
.comment-delete:hover { color: var(--danger); text-decoration: underline; }
.comment-text { white-space: pre-wrap; font-size: .92rem; margin-top: .1rem; }
.comment-new { display: flex; gap: .5rem; align-items: flex-start; }
.mention-wrap { flex: 1; min-width: 0; }
.mention { color: var(--brand-blue); font-weight: 600; background: var(--accent-soft); border-radius: 4px; padding: 0 .2rem; }
.mention-menu { position: absolute; z-index: 1050; list-style: none; margin: 0; padding: .25rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(29,39,51,.14); max-width: 420px; }
.mention-menu li { display: flex; flex-direction: column; padding: .35rem .6rem; border-radius: 6px; cursor: pointer; }
.mention-menu li.active, .mention-menu li:hover { background: var(--accent-soft); }
.mention-name { font-weight: 600; font-size: .9rem; color: var(--ink); }
.mention-email { font-size: .76rem; color: var(--ink-soft); }
.comment-input { background: #fff; font-size: .92rem; resize: vertical; min-height: 2.4rem; }

/* Internal (internal users only) and external (shared with all users) posts */
.visibility { font-size: .7rem; font-weight: 600; padding: 0 .4rem; border-radius: 999px; letter-spacing: .02em; }
.visibility-internal { background: #eef0f3; color: #55606d; }
.visibility-external { background: #dff3f1; color: #13706a; }
.comment-external { border-left: 3px solid #2a9d93; }
.author-type { font-size: .7rem; font-weight: 600; color: #13706a; border: 1px solid #a9dbd6; border-radius: 999px; padding: 0 .4rem; align-self: flex-start; }
.share-row { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .75rem; margin-top: .35rem; font-size: .8rem; }
.share-toggle { display: inline-flex; align-items: center; gap: .4rem; margin: 0; font-weight: 600; color: var(--ink); cursor: pointer; }
.share-toggle .form-check-input { float: none; margin: 0; width: 1rem; height: 1rem; flex: none; }
.share-note { color: var(--ink-soft); }
/* Room for the longer of the two notes, so the tick box doesn't jump sideways when it's ticked. */
.share-row .share-note[id] { min-width: 18.5em; }
.share-row.is-external .share-note { color: #13706a; font-weight: 600; }
.overview-comment-meta .visibility { margin-left: .35rem; }
.notes-badge { display: inline-block; margin-top: .4rem; margin-left: .2rem; font-size: .75rem; color: #6b5300; background: #fff1b8; border: 1px solid #ecd27a; border-radius: 4px; padding: 0 .35rem; }
.overview-notes { margin-top: .4rem; font-weight: 400; font-size: .82rem; color: #6b5300; background: #fff6d9; border-left: 3px solid #e7c96a; padding: .25rem .5rem; }
.overview-comment { white-space: pre-wrap; margin-top: .15rem; color: var(--ink); }
.overview-comment-meta { color: #6b5300; font-weight: 600; }
.answers { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
/* The last column (move/remove buttons) has a fixed width so the headings above line up with the boxes below –
   with "auto" the empty heading cell was narrower than the buttons, which shifted every heading to the right. */
.answer-labels, .answer-row {
    display: grid;
    grid-template-columns: minmax(140px, 1.2fr) minmax(0, 3fr) minmax(0, 3fr) 6.75rem;
    gap: .75rem;
}
.answer-labels span { font-size: .78rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.answer-row { padding: .65rem 0; border-bottom: 1px dashed var(--line); align-items: start; scroll-margin-top: 80px; border-radius: 6px; }
.answer-row:last-of-type { border-bottom: none; }
.answer-text { font-weight: 600; }
/* Trigger and response boxes: 3 lines to start with (text + padding + border), growing as more is typed. */
.free-text { min-height: calc(3 * 1.45em + .75rem + 2px); resize: vertical; line-height: 1.45; font-size: .95rem; }
.answer-actions { display: flex; gap: .15rem; justify-content: flex-end; }

.btn-icon { width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--line); background: #fff; color: var(--ink-soft); border-radius: 6px; line-height: 1; font-size: 1rem; }
.btn-icon:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-icon:disabled { opacity: .35; }
.btn-icon-danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
/* Up/down arrows: easier to spot than the plain icon buttons. */
/* Up/down arrows: plain box, but a thick dark arrow (drawn, so it looks the same whatever fonts the PC has). */
.btn-icon.btn-move { color: var(--ink); display: inline-flex; align-items: center; justify-content: center; }
.move-arrow { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.meta { font-size: .78rem; color: #8a939d; }

.add-question {
    display: block; width: 100%; padding: 1rem; margin: .5rem 0 1.5rem;
    border: 2px dashed #b9c1ca; border-radius: 12px; background: transparent;
    color: var(--accent); font-weight: 600; font-size: 1rem;
}
.add-question:hover { border-color: var(--accent); background: var(--accent-soft); }

.copy-panel { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .9rem 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.empty-state { background: var(--card); border: 1px dashed #b9c1ca; border-radius: 12px; padding: 1.4rem; margin-bottom: 1rem; text-align: center; }

.just-changed { animation: flash-bg 2.2s ease-out; }
@keyframes flash-bg { 0% { background: var(--highlight); } 100% { background: transparent; } }
.question-card.just-changed { animation: flash-card 2.2s ease-out; }
@keyframes flash-card { 0% { box-shadow: 0 0 0 3px #f3d36b; } 100% { box-shadow: 0 0 0 0 transparent; } }

.flash { transition: opacity .6s; }
.flash.fade-out { opacity: 0; }

/* ---- pathways ---- */
.pathway-c0 { --pw: var(--brand-blue); --pw-soft: #e6eef7; }
.pathway-c1 { --pw: var(--brand-red); --pw-soft: #f7e9ec; }
.pathway-c2 { --pw: #b4560b; --pw-soft: #fbefe4; }
.pathway-c3 { --pw: #2f5fb3; --pw-soft: #e7eefa; }
.pathway-dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--pw, var(--accent)); display: inline-block; flex: none; align-self: center; }

.pathway-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .75rem; margin: 1.2rem 0 1.4rem; }
.pathway-tab {
    display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: center;
    padding: .85rem 1rem; border-radius: 12px; text-decoration: none; color: var(--ink);
    background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--pw);
}
.pathway-tab:hover { color: var(--ink); border-color: var(--pw); }
.pathway-tab.active { background: var(--pw-soft); border-color: var(--pw); box-shadow: inset 0 0 0 1px var(--pw); }
.pathway-tab-name { font-weight: 650; font-size: 1.05rem; }
.pathway-tab-count { grid-column: 2; font-size: .82rem; color: var(--ink-soft); }

.pathway-heading { font-size: 1.25rem; font-weight: 650; color: var(--pw); display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .5rem; gap: .5rem; margin: 0 0 .2rem; }
.pathway-heading span:not(.pathway-dot) { color: var(--ink-soft); font-weight: 400; font-size: .95rem; }
.pathway-panel .period-tile:hover { border-color: var(--pw); }
.pathway-panel .period-tile:not(.empty) { border-top: 3px solid var(--pw); }

.pathway-crumb { display: inline-flex; align-items: center; gap: .4rem; color: var(--pw); font-weight: 600; }
.pathway-crumb:hover { color: var(--pw); text-decoration: underline; }
#period-form .question-card { border-left: 4px solid var(--pw); }
#period-form .q-number { background: var(--pw); }
#period-form .ref { background: var(--pw-soft); color: var(--pw); }

.filter-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: .8rem 0 1.4rem; }
.filter-tabs a { padding: .35rem .8rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink-soft); background: var(--card); font-size: .9rem; }
.filter-tabs a:hover { color: var(--ink); border-color: #b9c1ca; }
.filter-tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.overview-pathway-block { margin-bottom: 2.5rem; }
.overview-pathway-block .pathway-heading { padding-bottom: .5rem; border-bottom: 2px solid var(--pw); margin-bottom: 1rem; }

/* ---- overview / history ---- */
.overview-period { margin-bottom: 2rem; }
.overview-period h3 { font-size: 1.05rem; font-weight: 650; display: flex; align-items: baseline; gap: .6rem; }
.overview-table { background: var(--card); font-size: .9rem; }
.overview-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); background: #fafbfc; }
.overview-table td { vertical-align: top; white-space: pre-wrap; }
.overview-table td.q-cell { font-weight: 500; }
.missing { color: #a0a8b1; font-style: italic; }

@media (max-width: 991.98px) {
    .answer-row { grid-template-columns: 1fr; }
    .answer-actions { justify-content: flex-end; }
}

/* ---- procedures ---- */
.procedure-bar { display: flex; align-items: flex-end; gap: 1.2rem; flex-wrap: wrap; margin-bottom: .8rem; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); font-weight: 600; }
.procedure-title { margin: 0; display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.procedure-title .procedure-name { font-weight: 500; color: var(--ink-soft); font-size: 1.15rem; }
.procedure-code { display: inline-block; font-weight: 700; letter-spacing: .03em; color: #fff; background: var(--ink); border-radius: 6px; padding: .05rem .5rem; font-size: .85em; }
.procedure-title .procedure-code { font-size: 1.25rem; padding: .1rem .6rem; }
.procedure-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.procedure-switch a { padding: .35rem .85rem; text-decoration: none; color: var(--ink-soft); font-weight: 600; border-right: 1px solid var(--line); }
.procedure-switch a:last-child { border-right: none; }
.procedure-switch a:hover { color: var(--ink); background: var(--paper); }
.procedure-switch a.active { background: var(--ink); color: #fff; }
.procedure-crumb { font-weight: 700; color: var(--ink); text-decoration: none; }
.procedure-crumb:hover { color: var(--accent); }
.overview-filters { margin: .8rem 0 1.2rem; }
.overview-procedure { font-size: 1.1rem; color: var(--ink-soft); margin-bottom: 1rem; }
.code-input { text-transform: uppercase; font-weight: 600; letter-spacing: .03em; }
.code-input::placeholder { text-transform: none; font-weight: 400; letter-spacing: 0; }
.procedure-table td.text-end { white-space: nowrap; }
.rename-row td { background: var(--paper); }
.admin-card-wide { grid-column: 1 / -1; }
.download-group { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .6rem; }
.download-group .procedure-code { min-width: 3.4rem; text-align: center; }

/* ---- user menu ---- */
.user-menu { margin-left: .25rem; }
.user-button { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--line); border-radius: 999px; padding: .2rem .7rem .2rem .25rem; background: #fff; color: var(--ink); font-size: .92rem; }
.user-button:hover, .user-button:focus { border-color: #b9c1ca; background: var(--paper); }
.avatar { width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--brand-blue); color: #fff; font-weight: 700; font-size: .85rem; display: inline-flex; align-items: center; justify-content: center; }
.user-menu .dropdown-header { white-space: normal; line-height: 1.35; color: var(--ink-soft); }
.user-menu .dropdown-item:active { background: var(--accent); }
@media (max-width: 575.98px) { .user-name { display: none; } .user-button { padding-right: .5rem; } }

/* ---- sign-in pages ---- */
.auth-body { min-height: 100vh; background:
    radial-gradient(1200px 500px at 10% -10%, #e6eef7 0, transparent 60%),
    radial-gradient(900px 400px at 110% 110%, #f7e9ec 0, transparent 60%), var(--paper); }
.auth-body::before { content: ""; display: block; height: 4px; background: linear-gradient(90deg, var(--brand-blue) 0 68%, var(--brand-red) 68% 100%); }
.auth-wrap { min-height: calc(100vh - 4px); display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 2.2rem 2rem 1.8rem; box-shadow: 0 10px 30px rgba(29,39,51,.06); }
.auth-logo { height: 30px; width: auto; display: block; margin: 0 auto 1.6rem; }
.auth-title { font-size: 1.45rem; text-align: center; margin-bottom: .25rem; }
.auth-sub { text-align: center; color: var(--ink-soft); margin-bottom: 1.4rem; font-size: .95rem; }
.auth-foot { text-align: center; color: var(--ink-soft); font-size: .85rem; margin: 1.2rem 0 0; }
.auth-card .form-label { font-weight: 600; font-size: .9rem; }

/* ---- admin ---- */
.crumbs { font-size: .9rem; color: var(--ink-soft); margin-bottom: .4rem; }
.crumbs a { text-decoration: none; }
.narrow-page { max-width: 640px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem 1.3rem; }
.panel-title { font-size: 1.05rem; font-weight: 650; margin-bottom: .3rem; }
.panel-warn { border-color: #f0c36d; background: #fffaf0; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-top: 1.2rem; align-items: start; }
.admin-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem 1.3rem; color: var(--ink); text-decoration: none; border-top: 4px solid var(--brand-blue); }
a.admin-card:hover { border-color: var(--brand-blue); color: var(--ink); }
.admin-card-static { border-top-color: var(--brand-red); }
.admin-card-title { font-size: 1.15rem; font-weight: 650; margin-bottom: .35rem; }
.admin-card-body { color: var(--ink-soft); font-size: .92rem; }
.admin-card-cta { margin-top: .8rem; color: var(--brand-blue); font-weight: 600; font-size: .9rem; }
.download-list { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.user-table td, .user-table th { white-space: nowrap; }
.user-table tr.inactive td { color: #98a1ab; }
.you { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; background: var(--paper); border: 1px solid var(--line); color: var(--ink-soft); border-radius: 4px; padding: 0 .3rem; margin-left: .3rem; vertical-align: middle; }
.role { font-size: .78rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; }
.role-admin { background: #f7e9ec; color: var(--brand-red); }
.role-editor { background: var(--accent-soft); color: var(--brand-blue); }
.user-type { font-size: .8rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; white-space: nowrap; }
.user-type-internal { background: #eef0f3; color: #3d4752; }
.user-type-external { background: #dff3f1; color: #13706a; }
.status { font-size: .8rem; font-weight: 600; }
.status::before { content: ""; display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; margin-right: .35rem; background: currentColor; vertical-align: middle; }
.status-on { color: #1f7a4d; }
.status-off { color: #98a1ab; }
.status-locked { color: #b54708; }
.status-pending { color: #8a6d00; }

@media print {
    .app-header, .no-print { display: none !important; }
    body { background: #fff; }
    .overview-period { break-inside: avoid-page; }
}
