:root {
    --primary: #1e6fd9;
    --primary-hover: #1558ad;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --muted: #666;
    --border: #ddd;
    --danger: #c0392b;
    --success: #1e8e3e;
    /* Needs attention, which is not the same as wrong. Kept away from --danger so a flagged
       submission does not read as a rejected one. */
    --warn: #c77700;
    --warn-bg: #fdf3e2;
    --warn-text: #8a5300;
}

* {
    box-sizing: border-box;
}

body {
    font-family: system-ui, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

.shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

/* Stays on screen while the content scrolls.

   Without this the sidebar stretches to the height of the whole document - .shell is a flex row with
   align-items: stretch - and .sidebar-foot's margin-top:auto then pins the organisation name, the
   log-out button and the version to the bottom of the *document* rather than the window. On a short
   page they are visible and on a long one they are hundreds of pixels below the fold, which reads as
   the footer disappearing on some pages and not others.

   align-self overrides that stretch, the height makes it exactly one screen, and sticky holds it
   there. overflow-y is for a window too short to fit the nav and the footer at once. */
.sidebar {
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex: 0 0 240px;
    padding: 1.25rem 1rem;
    align-self: flex-start;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    color: var(--text);
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
    padding: 0 0.6rem 1rem;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar nav a {
    border-radius: 6px;
    color: var(--muted);
    font-size: 0.95rem;
    padding: 0.55rem 0.6rem;
    text-decoration: none;
}

.sidebar nav a:hover {
    background: var(--bg);
    color: var(--text);
}

.sidebar nav a.current {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-foot {
    margin-top: auto;
    padding: 0.6rem;
}

.sidebar-foot .org {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0 0 0.35rem;
}

/* Deliberately the quietest thing on the page - it is a reference, not information anyone needs
   while working. */
.sidebar-foot .version {
    color: var(--muted);
    font-size: 0.75rem;
    margin: 0.5rem 0 0;
    opacity: 0.7;
}

.content {
    flex: 1 1 auto;
    max-width: 900px;
    padding: 2rem 1.5rem;
}

@media (max-width: 700px) {
    .shell {
        flex-direction: column;
    }

    /* On a phone the sidebar is a bar across the top, not a column beside the content, so the
       sticky full-height treatment above has to be undone - left on, it would take the whole screen
       and push the page itself out of view. */
    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex: 0 0 auto;
        position: static;
        height: auto;
        overflow-y: visible;
        align-self: stretch;
    }

    .sidebar nav {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

.admin-table {
    border-collapse: collapse;
    width: 100%;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.4rem;
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.step-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.step-row {
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
    padding: 0.6rem 0.75rem;
}

.step-row.dragging {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    opacity: 0.85;
}

.step-row.retired {
    background: var(--bg);
}

.step-row.retired .step-fields input[type="text"] {
    color: var(--muted);
    text-decoration: line-through;
}

.step-position {
    color: var(--muted);
    flex: 0 0 1.75rem;
    font-size: 0.9rem;
}

.step-fields {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-width: 0;
}

.step-fields input[type="text"] {
    flex: 2 1 12rem;
    margin: 0;
}

.step-fields select {
    flex: 1 1 11rem;
    margin: 0;
}

.step-toggle {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex: 0 0 auto;
    font-size: 0.85rem;
    font-weight: normal;
    gap: 0.3rem;
    margin: 0;
}

.step-toggle input {
    width: auto;
}

.step-toggle.danger-toggle {
    color: var(--danger);
}

.step-row.doomed {
    border-color: var(--danger);
}

.step-row.doomed .step-fields input[type="text"] {
    color: var(--danger);
}

.form-actions {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.form-actions button,
.form-actions .button {
    margin-top: 0;
}

.step-discard {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.85rem;
    margin: 0;
    padding: 0.2rem 0.4rem;
}

/* touch-action is what lets a finger drag the row instead of scrolling the page. */
.drag-handle {
    background: none;
    border: none;
    color: var(--muted);
    cursor: grab;
    font-size: 1.2rem;
    line-height: 1;
    margin: 0;
    padding: 0.2rem 0.3rem;
    touch-action: none;
}

.drag-handle:hover {
    background: none;
    color: var(--text);
}

.drag-handle:focus-visible {
    box-shadow: 0 0 0 2px var(--primary);
    outline: none;
}

.step-row.dragging .drag-handle {
    cursor: grabbing;
}

button.secondary,
.button.secondary {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    margin-top: 0;
    padding: 0.5rem 1rem;
}

button.secondary:hover,
.button.secondary:hover {
    background: var(--bg);
}

.danger-zone {
    margin-top: 2rem;
}

.inline-form {
    display: inline-block;
    margin-right: 0.4rem;
}

.inline-form button {
    margin-top: 0;
}

button.danger {
    background: var(--danger);
}

.muted {
    color: var(--muted);
}

.notice {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    padding: 0.6rem 0.8rem;
}

tr.retired td {
    background: var(--bg);
}

.logout-form button {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 0;
    padding: 0;
}

.pco-login {
    display: block;
    background: var(--primary);
    color: #fff;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    padding: 0.65rem 1rem;
    border-radius: 6px;
    margin-top: 0.5rem;
}

.pco-login:hover {
    background: var(--primary-hover);
}

.card-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.card-switcher a {
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.9rem;
    padding: 0.3rem 0.8rem;
    text-decoration: none;
}

.card-switcher a.current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.login-divider {
    border-bottom: 1px solid var(--border);
    line-height: 0;
    margin: 1.5rem 0 1rem;
    text-align: center;
}

.login-divider span {
    background: var(--card-bg);
    color: var(--muted);
    font-size: 0.85rem;
    padding: 0 0.6rem;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    padding: 2rem;
}

.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
}

/* The landing page puts two panes side by side, which needs more room than a single form does. */
.content.wide {
    max-width: 1200px;
}

.card-picker {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.card-picker label {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}

.card-picker select,
.card-picker input[type="date"] {
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.45rem 0.6rem;
    width: auto;
}

.custom-dates {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.custom-dates[hidden] {
    display: none;
}

.card-browser {
    align-items: start;
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(240px, 20rem) 1fr;
}

/* Below this the two panes stop being side by side and the detail simply follows the list. */
@media (max-width: 820px) {
    .card-browser {
        grid-template-columns: 1fr;
    }
}

.entry-list-pane,
.entry-detail {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    padding: 1.25rem;
}

.entry-window {
    color: var(--muted);
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    margin: 0 0 0.75rem;
    text-transform: uppercase;
}

.entry-list {
    list-style: none;
    margin: 0;
    max-height: 60vh;
    overflow-y: auto;
    padding: 0;
}

/* A button, not a link: it opens a pane beside the list rather than navigating anywhere. */
.entry {
    align-items: baseline;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    font-size: 0.95rem;
    gap: 0.5rem;
    justify-content: space-between;
    margin: 0;
    padding: 0.5rem 0.6rem;
    text-align: left;
    width: 100%;
}

.entry:hover {
    background: var(--bg);
}

.entry.selected {
    background: var(--primary);
    color: #fff;
}

.entry.selected .entry-time {
    color: #fff;
}

.entry-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-time {
    color: var(--muted);
    flex: 0 0 auto;
    font-size: 0.8rem;
}

.entry-detail h2 {
    margin: 0 0 0.35rem;
}

.entry-detail h3 {
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    margin: 1.5rem 0 0.5rem;
    text-transform: uppercase;
    color: var(--muted);
}

.entry-meta {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.85rem;
    gap: 0.25rem 0.75rem;
    margin: 0 0 1rem;
}

.detail-fields {
    display: grid;
    gap: 0.2rem 1rem;
    grid-template-columns: 6rem 1fr;
    margin: 0;
}

.detail-fields dt {
    color: var(--muted);
    font-size: 0.85rem;
}

.detail-fields dd {
    margin: 0;
}

.next-step-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.next-step-links li {
    padding: 0.25rem 0;
}

.next-step-links a {
    color: var(--primary);
}

.prayer-request {
    background: var(--bg);
    border-radius: 6px;
    margin: 0;
    padding: 0.75rem;
    white-space: pre-wrap;
}

label {
    display: block;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    margin-top: 0.5rem;
}

.checkbox-group input {
    width: auto;
}

/* The two fields nobody chooses, said once above the boxes that are choices. */
.field-always {
    margin: 0 0 0.75rem;
}

/* Indented under the checkbox that reveals it, so it reads as belonging to that choice. */
.freeform-label {
    margin-top: 1rem;
    padding-left: 1.5rem;
    border-left: 2px solid var(--border);
}

.freeform-label p {
    margin-bottom: 0;
}

/* ---- Online cards admin --------------------------------------------------------------------- */
.online-card {
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
    margin-top: 1.25rem;
}

.online-card-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.online-card-head h2 {
    margin: 0;
    font-size: 1rem;
}

.badge {
    background: var(--success);
    color: #fff;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge.muted-badge {
    background: var(--border);
    color: var(--muted);
}

/* Monospace, because these are addresses and snippets people copy character for character. */
.copyable {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
}

.embed-snippet {
    min-height: 0;
    white-space: pre;
    overflow-x: auto;
}

/* The field and its Copy button. Top-aligned so the button sits by the first line of a snippet
   rather than floating halfway down six lines of it. */
.copy-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.copy-row .copyable {
    flex: 1 1 auto;
}

.copy-button {
    flex: 0 0 auto;
    /* Matches the height of the input beside it rather than the taller default button. */
    padding: 0.6rem 0.9rem;
    min-width: 5rem;
}

.online-card-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.inline-form input[type="number"] {
    width: 8rem;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
}

.inline-form button {
    margin-top: 0;
}

/* ---- Reviewing a queued submission ----------------------------------------------------------- */
.match-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-weight: normal;
    margin-top: 0.5rem;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.match-option input {
    width: auto;
    margin-top: 0.2rem;
}

.match-option:hover {
    background: var(--bg);
}

/* ---- The published card, as a visitor sees it ------------------------------------------------
   Standalone: no shell, no sidebar. It is also rendered inside an iframe on somebody else's page,
   so it has to look deliberate at any width and must not assume a page around it. */
body.public-card {
    background: var(--bg);
}

.public-card-shell {
    max-width: 640px;
    /* Top margin, not auto on all sides: inside a short iframe, vertical centring pushes the first
       field out of view. */
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.public-card-shell h1 {
    margin-top: 0;
    font-size: 1.35rem;
}

.public-thanks h1 {
    margin-bottom: 0.5rem;
}

/* The honeypot. Off-screen rather than display:none - some bots skip anything hidden that way,
   and this needs to look like an ordinary field to them while being unreachable to a person.
   aria-hidden and tabindex="-1" on the markup keep it away from screen readers and tabbing.

   Off-screen is also why a browser could autofill it, which is the whole reason a filled-in
   honeypot now flags a submission instead of discarding it. The defence against that is the field's
   name, not its position - see PublicSubmissionGuard.HONEYPOT_FIELD. */
.hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* A submission that tripped the honeypot. Amber rather than red throughout: this is "look at this
   before you approve it", not "this is spam" - some of them are real people whose browser filled in
   a field they never saw. */
.pill {
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    white-space: nowrap;
}

.pill-flag {
    background: var(--warn-bg);
    color: var(--warn-text);
}

.flagged-notice {
    border-left: 4px solid var(--warn);
}

.flagged-notice h2 {
    color: var(--warn-text);
}

/* Whatever was in the hidden field, shown as-is. It came from an anonymous caller, so it is printed
   through th:text and never interpreted - and wrapped, because a bot will happily post one
   unbroken 500-character string that would otherwise stretch the page sideways. */
.honeypot-value {
    background: var(--bg);
    border-radius: 6px;
    font-family: ui-monospace, monospace;
    font-size: 0.9rem;
    margin: 0 0 0.75rem;
    overflow-wrap: anywhere;
    padding: 0.75rem;
    white-space: pre-wrap;
}

/* Walking the review queue: back to the list on the left, where you are in the middle, the two
   steps on the right. */
.queue-pager {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.queue-pager .queue-position {
    color: var(--muted);
    font-size: 0.85rem;
}

.queue-pager-links {
    display: flex;
    gap: 1rem;
}

/* The end of the queue keeps its place rather than letting the other link jump sideways. */
.queue-pager-links .disabled {
    color: var(--border);
    cursor: default;
}

/* Set apart from the list: it acts on everything at once and cannot be undone one at a time. */
.bulk-approve h2 {
    font-size: 1rem;
}

.bulk-approve button {
    margin-top: 0.5rem;
}

/* What a bulk approval would do, one consequence per line. A sentence would bury the numbers,
   and the numbers are the whole point. */
.match-plan {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0;
}

.match-plan li {
    padding: 0.3rem 0;
    font-size: 0.95rem;
}

.match-plan strong {
    display: inline-block;
    min-width: 1.75rem;
}

/* Approve and re-check side by side; the destructive one is not the quiet one. */
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* One address, one line each, in the detail pane. */
.detail-fields .address span {
    display: block;
}

/* The address block on the entry form: four lines that are one thing. */
.address-fields {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 0.75rem;
}

.address-fields .full-width {
    grid-column: 1 / -1;
}

@media (max-width: 700px) {
    .address-fields {
        grid-template-columns: 1fr;
    }
}

button, .button {
    display: inline-block;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 1.5rem;
    text-decoration: none;
}

button:hover, .button:hover {
    background: var(--primary-hover);
}

.error {
    color: var(--danger);
    margin-top: 1rem;
}

.success {
    color: var(--success);
    background: #e6f4ea;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}
