/* Admin area: plain, calm screens on top of Tailwind utilities. Goal colours come from base/themes.css (.sdg-N).
   One typeface for everything, Thai and English alike: IBM Plex Sans Thai Looped — the looped (มีหัว) Thai letters,
   with Latin letters that match IBM Plex Sans, which backs it up. Setting the font variables here switches every font-sans / font-serif / font-script utility in the admin too. */
.admin {
    --font-sans: 'IBM Plex Sans Thai Looped', 'IBM Plex Sans', ui-sans-serif, system-ui, sans-serif;
    --font-serif: 'IBM Plex Sans Thai Looped', 'IBM Plex Sans', ui-sans-serif, system-ui, sans-serif;
    --font-script: 'IBM Plex Sans Thai Looped', 'IBM Plex Sans', ui-sans-serif, system-ui, sans-serif;
    font-family: var(--font-sans);
}

.admin-nav {
    display: flex;
    flex-direction: column;
    background: var(--color-navy);
}

@media (min-width: 1024px) {
    .admin-nav {
        position: sticky;
        top: 0;
        flex: none;
        width: 230px;
        height: 100vh;
    }
}

.admin-nav-link {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: rgb(255 255 255 / 0.7);
}

.admin-nav-link:hover,
.admin-nav-link.is-active {
    background: rgb(255 255 255 / 0.1);
    color: #fff;
}

.admin-title {
    font-family: var(--font-serif);
    font-size: 28px;
    font-weight: 700;
    text-transform: lowercase;
}

/* white page, raised white cards: a soft lift plus a hairline edge so every panel stands out */
.admin-card {
    padding: 28px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 0 0 1px rgb(49 54 70 / 0.07), 0 12px 32px -8px rgb(49 54 70 / 0.16), 0 4px 10px -4px rgb(49 54 70 / 0.08);
}

.admin-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.2s ease-out;
}

.admin-stat:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 0 1px rgb(49 54 70 / 0.08), 0 18px 40px -10px rgb(49 54 70 / 0.22);
}

/* saved / deleted message: a small toast in the top-right corner that slides in, then fades away by itself */
.admin-flash {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 18px 12px 14px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 0 0 1px rgb(47 184 172 / 0.25), 0 14px 32px -10px rgb(49 54 70 / 0.3);
    font-size: 14px;
    font-weight: 700;
    color: var(--color-teal-dark);
    animation: flash-toast 4.5s ease-out forwards;
    pointer-events: none;
}

@keyframes flash-toast {
    0% { opacity: 0; transform: translateY(-12px); }
    6%, 85% { opacity: 1; transform: none; }
    100% { opacity: 0; transform: translateY(-12px); visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    .admin-flash {
        animation: none;
    }
}

.admin-label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 700;
}

.admin-input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #d7dde4;
    border-radius: 10px;
    background: #fff;
    font-size: 15px;
    box-shadow: inset 0 1px 2px rgb(49 54 70 / 0.04);
}

.admin-input:focus {
    border-color: var(--color-teal-dark);
    outline: none;
    box-shadow: 0 0 0 4px rgb(84 221 209 / 0.2);
}

/* buttons stay light: a pale mint fill with teal text and edge (no dark fills, even on hover) */
.admin-btn {
    display: inline-block;
    padding: 11px 20px;
    border-radius: 10px;
    background: var(--color-mint-light);
    box-shadow: 0 0 0 1.5px rgb(47 184 172 / 0.45), 0 6px 14px -8px rgb(47 184 172 / 0.6);
    transition: background-color 0.2s ease-out, transform 0.2s ease-out, box-shadow 0.2s ease-out;
    font-size: 14px;
    font-weight: 700;
    text-transform: lowercase;
    color: #1f8f86;
}

.admin-btn:hover {
    background: #cdf1ec;
    transform: translateY(-1px);
    box-shadow: 0 0 0 1.5px rgb(47 184 172 / 0.6), 0 8px 18px -8px rgb(47 184 172 / 0.7);
}

.admin-btn.is-quiet {
    background: #fff;
    color: var(--color-navy);
    box-shadow: 0 0 0 1.5px #d7dde4, 0 4px 10px -6px rgb(49 54 70 / 0.25);
}

.admin-btn.is-quiet:hover {
    background: #f6f8fa;
}

/* small row buttons (edit / delete in tables) */
.admin-btn.is-small {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
}

.admin-btn.is-danger {
    background: #fff;
    color: #e5243b;
    box-shadow: 0 0 0 1.5px rgb(229 36 59 / 0.35), 0 4px 10px -6px rgb(229 36 59 / 0.35);
}

.admin-btn.is-danger:hover {
    background: #fdeced;
}

.admin-table {
    width: 100%;
    min-width: 760px;
    table-layout: fixed;
    font-size: 14px;
}

/* fixed column widths (set with <colgroup>), so columns sit in the same place on every table and every tab;
   the title column takes what is left */
.admin-table .col-kind { width: 140px; }
.admin-table .col-sdg { width: 200px; }
.admin-table .col-status { width: 200px; }
.admin-table .col-listed { width: 190px; }
.admin-table .col-actions { width: 170px; }
.admin-table .col-date { width: 130px; }
.admin-table .col-file { width: 120px; }
.admin-table .col-num { width: 90px; }
.admin-table .col-year { width: 110px; }

.admin-table td {
    overflow-wrap: anywhere;
}

.admin-table th {
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #eef1f4;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    text-transform: lowercase;
    color: rgb(49 54 70 / 0.5);
}

.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f5f7;
    vertical-align: middle;
}

/* what an item is (news, case studies, events) in a goal's combined list */
.kind-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: #eef1f4;
    font-size: 12px;
    font-weight: 700;
    color: rgb(49 54 70 / 0.7);
    white-space: nowrap;
}

.admin-chip {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 22px;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--goal, var(--color-navy));
    font-size: 11px;
    font-weight: 800;
    color: #fff;
}

.admin-chip.is-filter {
    opacity: 0.5;
}

.admin-chip.is-filter.is-active,
.admin-chip.is-filter:hover {
    opacity: 1;
}

/* goal picker: a checkbox per goal, filled with the goal colour once ticked */
.sdg-pick input {
    position: absolute;
    opacity: 0;
}

.sdg-pick span {
    display: inline-block;
    padding: 5px 10px;
    border: 1.5px solid var(--goal);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: var(--goal);
    cursor: pointer;
}

.sdg-pick input:checked + span {
    background: var(--goal);
    color: #fff;
}

.sdg-pick input:focus-visible + span {
    outline: 2px solid var(--color-navy);
    outline-offset: 2px;
}

/* Sign-in page: the home page's sky and lawn behind a paper card */
.admin-login {
    background: linear-gradient(180deg, #4fa9e3 0%, #7cc4ee 55%, #a9dcf7 100%);
}

.admin-login-card {
    z-index: 1;
    overflow: hidden;
    border-radius: 6px;
    background: #fff;
    box-shadow: 10px 12px 0 rgb(30 70 110 / 0.18), 0 0 0 1px rgb(30 70 110 / 0.06);
}

.admin-login-stripes {
    display: flex;
    height: 6px;
}

.admin-login-stripes span {
    flex: 1;
    background: var(--goal);
}

/* clouds drift and cast paper shadows like on the public site */
.admin-login .float-gently {
    animation: login-float 7s ease-in-out infinite;
}

.admin-login .float-gently--slow {
    animation-duration: 9s;
    animation-delay: -3s;
}

.admin-login .paper-lift-sky {
    filter: drop-shadow(4px 5px 0 rgb(30 80 120 / 0.12));
}

@keyframes login-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@media (prefers-reduced-motion: reduce) {
    .admin-login .float-gently { animation: none; }
}

/* SDG goals manager: goal blocks like the home page grid, and a goal-coloured header on each goal's page */
.goal-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 210px;
    padding: 16px;
    border-radius: 12px;
    background: var(--goal);
    color: #fff;
    box-shadow: 5px 5px 0 color-mix(in srgb, var(--goal) 45%, #1b1f2a);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.goal-block:hover {
    transform: translateY(-4px);
    box-shadow: 7px 9px 0 color-mix(in srgb, var(--goal) 45%, #1b1f2a);
}

.goal-block-model {
    display: grid;
    flex: 1;
    place-items: center;
}

.goal-block-model svg {
    width: 64px;
    height: 64px;
    filter: drop-shadow(3px 4px 0 rgb(0 0 0 / 0.18));
}

.goal-block-meta {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: rgb(255 255 255 / 0.8);
}

.goal-card {
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 0 0 1px rgb(49 54 70 / 0.07), 0 12px 32px -8px rgb(49 54 70 / 0.16), 0 4px 10px -4px rgb(49 54 70 / 0.08);
}

.goal-head {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 22px;
}

.goal-head-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--goal);
}

.goal-head-icon svg {
    width: 38px;
    height: 38px;
}

.goal-head-chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--goal) 14%, #fff);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--goal) 80%, #1b1f2a);
}

/* a goal page sheet: heading, category buttons and list stacked inside .goal-card, split by hairlines */
.goal-card > .goal-tabs-big {
    border-top: 1px solid #eef1f4;
    border-radius: 0;
    background: #f8fafc;
    box-shadow: none;
    padding: 8px 10px;
}

:is(.goal-card, .goal-scope) .admin-table th {
    background: #fff;
}

/* a goal's category buttons: all · news · case studies · events */
.goal-tabs-big {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 0 0 1px rgb(49 54 70 / 0.07), 0 12px 32px -8px rgb(49 54 70 / 0.16), 0 4px 10px -4px rgb(49 54 70 / 0.08);
}

.goal-tab-big {
    display: inline-flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 130px;
    padding: 12px 16px;
    border-radius: 9px;
    font-weight: 700;
    text-transform: lowercase;
    color: rgb(49 54 70 / 0.6);
}

.goal-tab-big:hover {
    background: #f4f6f9;
    color: var(--color-navy);
}

.goal-tab-big.is-active {
    background: color-mix(in srgb, var(--goal) 13%, #fff);
    color: color-mix(in srgb, var(--goal) 80%, #1b1f2a);
    box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--goal) 45%, #fff);
}

.goal-tab-count {
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgb(49 54 70 / 0.08);
    font-size: 12px;
    text-align: center;
}

.goal-tab-big.is-active .goal-tab-count {
    background: color-mix(in srgb, var(--goal) 22%, #fff);
}

/* attachments field in news / case study / event forms */

.attach-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 0 0 1px rgb(49 54 70 / 0.08), 0 4px 12px -6px rgb(49 54 70 / 0.18);
}

.attach-kind {
    flex: none;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef1f4;
    font-size: 11px;
    font-weight: 700;
}

.link-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) 36px;
    gap: 8px;
    align-items: center;
}

.link-remove {
    height: 36px;
    border-radius: 8px;
    font-size: 20px;
    line-height: 1;
    color: rgb(49 54 70 / 0.45);
}

.link-remove:hover {
    background: #fdecee;
    color: #E5243B;
}

/* cover picture box: empty state with a prompt, or the picture with a "change" tag */
.cover-drop {
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    aspect-ratio: 16 / 7;
    border: 1px solid #e3e8ee;
    border-radius: 16px;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color 0.2s ease-out, background-color 0.2s ease-out;
}

.cover-drop:hover {
    border-color: var(--color-teal-dark);
    background: var(--color-mint-light);
}

.cover-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: rgb(49 54 70 / 0.5);
}

.cover-drop:hover .cover-empty {
    color: var(--color-teal-dark);
}

.cover-drop.has-image {
    border: 2px solid #e3e8ee;
    box-shadow: 0 4px 14px rgb(49 54 70 / 0.08);
}

.cover-drop.has-image .cover-empty {
    display: none;
}

.cover-change {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: none;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgb(49 54 70 / 0.75);
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.cover-drop.has-image .cover-change {
    display: block;
}

/* Publishing box: an on/off switch beside the publish date */
.publish-box {
    display: grid;
    gap: 20px;
    align-items: center;
    padding: 20px 22px;
    border-radius: 14px;
    background: #f8fafc;
    box-shadow: 0 0 0 1px rgb(49 54 70 / 0.07);
}

@media (min-width: 768px) {
    .publish-box {
        grid-template-columns: 1fr minmax(240px, 320px);
    }
}

/* a box holding only a switch (no date beside it) is as wide as its text, not the whole form */
.publish-box:not(:has(.publish-date)) {
    grid-template-columns: auto;
    width: fit-content;
    max-width: 100%;
    padding-right: 28px;
}

.publish-switch {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
}

.switch-track {
    position: relative;
    flex: none;
    width: 48px;
    height: 28px;
    border-radius: 999px;
    background: #cfd6de;
    transition: background-color 0.2s ease-out;
}

.switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 4px rgb(49 54 70 / 0.25);
    transition: transform 0.2s ease-out;
}

.publish-switch input:checked + .switch-track {
    background: var(--color-teal-dark);
}

.publish-switch input:checked + .switch-track .switch-thumb {
    transform: translateX(20px);
}

.publish-switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 4px rgb(84 221 209 / 0.3);
}

/* counts under each goal cabinet on the sdg goals screen: one short line, pinned to the bottom of the cell so every
   row lines up whatever the length of the goal's name */
.goal-cabinet-counts {
    margin-top: auto;
    padding: 3px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--goal) 12%, #fff);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    color: color-mix(in srgb, var(--goal) 75%, #1b1f2a);
}

.goal-caption + .goal-cabinet-counts {
    translate: 0 8px;
}

/* inside a goal's page every button, switch and focus ring takes that goal's colour (the sheet and the form under it
   carry .sdg-N, so --goal is set); delete keeps its red so it still reads as a warning */
:is(.goal-card, .goal-scope) .admin-btn {
    background: color-mix(in srgb, var(--goal) 12%, #fff);
    box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--goal) 45%, #fff), 0 6px 14px -8px color-mix(in srgb, var(--goal) 60%, transparent);
    color: color-mix(in srgb, var(--goal) 80%, #1b1f2a);
}

:is(.goal-card, .goal-scope) .admin-btn:hover {
    background: color-mix(in srgb, var(--goal) 20%, #fff);
    box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--goal) 60%, #fff), 0 8px 18px -8px color-mix(in srgb, var(--goal) 70%, transparent);
}

:is(.goal-card, .goal-scope) .admin-btn.is-quiet {
    background: #fff;
    box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--goal) 30%, #fff), 0 4px 10px -6px rgb(49 54 70 / 0.2);
}

:is(.goal-card, .goal-scope) .admin-btn.is-quiet:hover {
    background: color-mix(in srgb, var(--goal) 7%, #fff);
}

:is(.goal-card, .goal-scope) .admin-btn.is-danger {
    background: #fff;
    box-shadow: 0 0 0 1.5px rgb(229 36 59 / 0.35), 0 4px 10px -6px rgb(229 36 59 / 0.35);
    color: #e5243b;
}

:is(.goal-card, .goal-scope) .admin-btn.is-danger:hover {
    background: #fdeced;
}

:is(.goal-card, .goal-scope) .admin-input:focus {
    border-color: var(--goal);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--goal) 18%, transparent);
}

:is(.goal-card, .goal-scope) .publish-switch input:checked + .switch-track {
    background: var(--goal);
}

/* "รูปอื่นๆ" (gallery) field: one pale box holding the pictures (four-by-three thumbnails) and an add tile;
   empty, the add tile fills the box as one big "click or drop" prompt */
.gallery-box {
    min-height: 150px;
    padding: 12px;
    border: 1px solid #e3e8ee;
    border-radius: 16px;
    background: #f8fafc;
    transition: border-color 0.2s ease-out, background-color 0.2s ease-out;
}

.gallery-box.is-dragging {
    border-color: var(--color-teal);
    background: var(--color-mint-light);
}

:is(.goal-card, .goal-scope) .gallery-box.is-dragging {
    border-color: var(--goal);
    background: color-mix(in srgb, var(--goal) 8%, #fff);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}

.gallery-slot {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 0 0 1px rgb(49 54 70 / 0.08), 0 4px 10px -6px rgb(49 54 70 / 0.3);
}

.gallery-slot img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    aspect-ratio: 4 / 3;
    border: 1px solid #e3e8ee;
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    font-weight: 700;
    color: rgb(49 54 70 / 0.5);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease-out, background-color 0.2s ease-out, color 0.2s ease-out;
}

.gallery-add:hover {
    border-color: var(--color-teal);
    background: var(--color-mint-light);
    color: var(--color-teal-dark);
}

:is(.goal-card, .goal-scope) .gallery-add:hover {
    border-color: var(--goal);
    background: color-mix(in srgb, var(--goal) 8%, #fff);
    color: color-mix(in srgb, var(--goal) 80%, #1b1f2a);
}

.gallery-add .h-7 {
    width: 22px;
    height: 22px;
}

.gallery-add-full {
    display: none;
}

/* empty: the add tile is the whole box */
.gallery-box.is-empty .gallery-grid {
    display: block;
    height: 100%;
}

.gallery-box.is-empty .gallery-add {
    gap: 4px;
    width: 100%;
    height: 100%;
    min-height: 124px;
    aspect-ratio: auto;
    border: 0;
    background: none;
    font-size: 14px;
}

.gallery-box.is-empty .gallery-add .h-7 {
    width: 32px;
    height: 32px;
}

.gallery-box.is-empty .gallery-add-short {
    display: none;
}

.gallery-box.is-empty .gallery-add-full {
    display: block;
    font-weight: 400;
}

.gallery-x {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: rgb(255 255 255 / 0.92);
    font-size: 16px;
    font-weight: 700;
    line-height: 26px;
    color: #e5243b;
    box-shadow: 0 2px 6px rgb(49 54 70 / 0.25);
}

.gallery-remove {
    position: absolute;
    right: 6px;
    bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgb(255 255 255 / 0.92);
    font-size: 12px;
    font-weight: 700;
    color: #e5243b;
    cursor: pointer;
}

.gallery-slot.is-saved:has(input:checked) img {
    opacity: 0.3;
}

/* add / edit forms in numbered steps (x-admin.form-step): a heading strip with the step number, then the fields */
.form-step {
    overflow: hidden;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 0 0 1px rgb(49 54 70 / 0.08), 0 6px 16px -10px rgb(49 54 70 / 0.2);
}

.form-step-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid #eef1f4;
    background: #f8fafc;
    color: var(--color-navy);
}

.form-step-num {
    display: grid;
    flex: none;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: var(--color-mint-light);
    box-shadow: 0 0 0 1.5px rgb(47 184 172 / 0.45);
    font-weight: 800;
    color: #1f8f86;
}

:is(.goal-card, .goal-scope) .form-step-num {
    background: color-mix(in srgb, var(--goal) 13%, #fff);
    box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--goal) 45%, #fff);
    color: color-mix(in srgb, var(--goal) 80%, #1b1f2a);
}

.form-step-body {
    padding: 20px;
}

/* the pictures step: cover and gallery side by side on wide screens; the cover box and the gallery box stand at
   least the same height, the gallery's thumbnails four a row inside it */
@media (min-width: 1024px) {
    .form-step-photos {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
        align-items: start;
    }

    .form-step-photos > * + * {
        margin-top: 0 !important;
    }

    .form-step-photos [data-cover-field] {
        display: flex;
        flex-direction: column;
    }

    .form-step-photos .cover-drop {
        aspect-ratio: auto;
        height: 260px;
    }

    .form-step-photos .gallery-box {
        min-height: 260px;
    }

    .form-step-photos .gallery-box.is-empty .gallery-add {
        min-height: 234px;
    }

    .form-step-photos .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.form-step-photos .cover-drop {
    max-width: none;
}

.form-step-photos .cover-drop + span,
.form-step-photos [data-cover-field] > span.mx-auto {
    max-width: none;
}

/* dashboard: stat cards with a tinted icon per kind */
.admin-stat {
    --tone: var(--color-teal-dark);
    position: relative;
    padding: 20px 22px;
}

.dash-stat--reports { --tone: #0a97d9; }
.dash-stat--case-studies { --tone: #4c9f38; }
.dash-stat--news { --tone: #e5243b; }
.dash-stat--events { --tone: #fd9d24; }
.dash-stat--documents { --tone: #8f1838; }
.dash-stat--messages { --tone: #19486a; }

.dash-stat-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--tone, var(--color-teal-dark)) 13%, #fff);
    color: var(--tone, var(--color-teal-dark));
}

.admin-stat .dash-stat-more {
    position: absolute;
    top: 22px;
    right: 20px;
    font-size: 12px;
    font-weight: 700;
    color: var(--tone);
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

.admin-stat:hover .dash-stat-more {
    opacity: 1;
}

/* file pickers (attachments, a report's PDF): a low box like the picture boxes, instead of the browser's own
   "เลือกไฟล์ ไม่ได้เลือกไฟล์ใด" bar; click it or drop files on it, the picked files are listed underneath */
.file-drop {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: 1px solid #e3e8ee;
    border-radius: 14px;
    background: #f8fafc;
    color: rgb(49 54 70 / 0.55);
    cursor: pointer;
    transition: border-color 0.2s ease-out, background-color 0.2s ease-out, color 0.2s ease-out;
}

.file-drop:hover,
.file-drop.is-dragging {
    border-color: var(--color-teal);
    background: var(--color-mint-light);
    color: var(--color-teal-dark);
}

:is(.goal-card, .goal-scope) .file-drop:hover,
:is(.goal-card, .goal-scope) .file-drop.is-dragging {
    border-color: var(--goal);
    background: color-mix(in srgb, var(--goal) 8%, #fff);
    color: color-mix(in srgb, var(--goal) 80%, #1b1f2a);
}

/* the title row of a news / case study form: the title alone, or the title with the category beside it */
.form-row-title {
    display: grid;
    gap: 20px;
}

@media (min-width: 768px) {
    .form-row-title:has(> :nth-child(2)) {
        grid-template-columns: minmax(0, 1fr) 280px;
    }
}

.attach-list {
    display: grid;
    gap: 6px;
}

/* file-type badges in colour, so a list of attachments reads at a glance */
.attach-kind[data-type="pdf"] { background: #fde3e6; color: #c5192d; }
.attach-kind[data-type="doc"],
.attach-kind[data-type="docx"] { background: #dfeefb; color: #0a6fb8; }
.attach-kind[data-type="xls"],
.attach-kind[data-type="xlsx"],
.attach-kind[data-type="csv"] { background: #e2f3dc; color: #3f8a2c; }
.attach-kind[data-type="ppt"],
.attach-kind[data-type="pptx"] { background: #feead8; color: #c95d10; }
.attach-kind[data-type="jpg"],
.attach-kind[data-type="jpeg"],
.attach-kind[data-type="png"] { background: #efe4f7; color: #7a3fa8; }
.attach-kind[data-type="ลิงก์"] { background: var(--color-mint-light); color: #1f8f86; }

.attach-remove {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 700;
    color: #e5243b;
    cursor: pointer;
}

.link-add {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid #e3e8ee;
    background: #f8fafc;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    color: rgb(49 54 70 / 0.55);
    transition: border-color 0.2s ease-out, background-color 0.2s ease-out, color 0.2s ease-out;
}

.link-add:hover {
    border-color: var(--color-teal);
    background: var(--color-mint-light);
    color: var(--color-teal-dark);
}

:is(.goal-card, .goal-scope) .link-add:hover {
    border-color: var(--goal);
    background: color-mix(in srgb, var(--goal) 8%, #fff);
    color: color-mix(in srgb, var(--goal) 80%, #1b1f2a);
}

/* ------------------------------------------------------------------------------------------------------------------
   No boxes behind the content: cards, the goal sheet, form steps, publishing boxes and list rows lose their frame,
   background and shadow; parts are told apart by hairlines and space instead. Inputs and the pick/drop boxes
   keep their outline — they are things to click, not frames.
   ------------------------------------------------------------------------------------------------------------------ */
.admin-card,
.goal-card,
.form-step {
    border-radius: 0;
    background: none;
    box-shadow: none;
}

.goal-card,
.form-step {
    overflow: visible;
}

.admin-card {
    padding: 0;
}

/* dashboard numbers: a coloured rule on top instead of a card */
.admin-card.admin-stat {
    padding: 16px 2px 4px;
    border-top: 3px solid color-mix(in srgb, var(--tone) 40%, #fff);
}

.admin-card.admin-stat:hover {
    box-shadow: none;
    border-top-color: var(--tone);
}

/* messages: one after another, split by a line */
article.admin-card {
    padding: 18px 0;
    border-bottom: 1px solid #eef1f4;
}

/* the goal sheet: heading, category buttons and list without a sheet behind them */
.goal-card .goal-head {
    padding: 0 0 18px;
}

.goal-card > .goal-tabs-big {
    border: 0;
    border-radius: 12px;
}

.goal-card > .border-t,
.goal-card > div > .admin-table,
.goal-card .admin-table {
    border-top: 0;
}

/* form steps: the number and title over a hairline, the fields underneath */
.form-step-head {
    padding: 0 0 12px;
    border-bottom: 1px solid #eef1f4;
    background: none;
}

.form-step-body {
    padding: 20px 0 0;
}

form.space-y-6 > .form-step + .form-step {
    margin-top: 40px;
}

/* the publishing / "show in the list" switches sit straight on the page */
.publish-box {
    padding: 0;
    background: none;
    box-shadow: none;
}

/* attached files and links: rows split by lines, no little cards */
.attach-row {
    padding: 10px 2px;
    border-bottom: 1px solid #eef1f4;
    border-radius: 0;
    background: none;
    box-shadow: none;
}

/* attached files as little A4 sheets: the picture, the PDF's first page or a ruled page, the type badge in a corner,
   a folded corner on top; the name and size underneath. A click opens the file in a new tab. */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 18px;
}

.doc-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.doc-paper {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 210 / 297;
    border: 1px solid #e3e8ee;
    border-radius: 4px 14px 4px 4px;
    background: #fff;
    box-shadow: 0 6px 14px -8px rgb(49 54 70 / 0.35);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.doc-paper:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 22px -10px rgb(49 54 70 / 0.45);
}

/* the folded corner */
.doc-paper::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 18px;
    height: 18px;
    background: linear-gradient(225deg, #fff 50%, #dfe5ec 50%);
    box-shadow: -1px 1px 2px rgb(49 54 70 / 0.12);
}

.doc-paper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* the PDF's first page, scaled down; clicks go to the link, not the viewer */
.doc-paper iframe {
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: none;
}

.doc-lines {
    position: absolute;
    inset: 22% 16% 30%;
    background: repeating-linear-gradient(180deg, #e6ebf0 0 3px, transparent 3px 11px);
}

.doc-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
}

.doc-name {
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.doc-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 12px;
    color: rgb(49 54 70 / 0.5);
}

.doc-x {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 700;
    line-height: 24px;
    color: #e5243b;
}

.doc-x:hover {
    background: #fdeced;
}

.doc-tile.is-saved:has(.attach-remove input:checked) .doc-paper {
    opacity: 0.35;
}

/* opening pictures: the cover's "ดูรูปเต็ม" button (only once there is a picture) and the shared viewer */
.cover-zoom {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    display: none;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgb(255 255 255 / 0.92);
    font-size: 13px;
    font-weight: 700;
    color: var(--color-navy);
    box-shadow: 0 2px 8px rgb(49 54 70 / 0.25);
}

.cover-drop.has-image .cover-zoom {
    display: block;
}

.gallery-slot > a {
    position: absolute;
    inset: 0;
    cursor: zoom-in;
}

.lightbox {
    /* Tailwind resets every margin to 0; a dialog needs auto margins to sit in the middle of the screen */
    margin: auto;
    max-width: min(1100px, 92vw);
    max-height: 92vh;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: #1b1f2a;
    box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.6);
}

.lightbox::backdrop {
    background: rgb(20 23 32 / 0.75);
}

.lightbox img {
    display: block;
    max-width: min(1100px, 92vw);
    max-height: calc(92vh - 52px);
    margin: 0 auto;
    object-fit: contain;
}

.lightbox-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.lightbox-bar a:hover {
    text-decoration: underline;
}

.lightbox-bar button {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    font-size: 20px;
    line-height: 32px;
    color: #fff;
}

.lightbox-bar button:hover {
    background: rgb(255 255 255 / 0.12);
}

/* ---------- phones ---------- */

/* the side menu becomes a slim bar on top: logo and sign-out on one line, the menu one swipeable row under them */
@media (max-width: 1023px) {
    .admin-nav {
        position: sticky;
        top: 0;
        z-index: 30;
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .admin-nav-brand {
        padding: 12px 16px !important;
    }

    .admin-nav-user {
        grid-row: 1;
        grid-column: 2;
        margin: 0 !important;
        padding: 0 16px !important;
        text-align: right;
    }

    .admin-nav-user p {
        display: none;
    }

    .admin-nav-menu {
        grid-column: 1 / -1;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding: 0 12px 10px !important;
        scrollbar-width: none;
    }

    .admin-nav-menu::-webkit-scrollbar {
        display: none;
    }

    .admin-nav-link {
        flex: none;
    }
}

/* tables turn into a list: each row a block, its cells stacked, the buttons underneath */
@media (max-width: 767px) {
    .admin-table {
        display: block;
        min-width: 0;
    }

    .admin-table colgroup,
    .admin-table thead {
        display: none;
    }

    .admin-table tbody,
    .admin-table tr,
    .admin-table td {
        display: block;
        width: auto;
    }

    .admin-table tr {
        padding: 14px 0;
        border-bottom: 1px solid #eef1f4;
    }

    .admin-table td {
        padding: 3px 0;
        border: 0;
    }

    .admin-table td:first-child {
        font-size: 15px;
    }

    .admin-table td:last-child > .flex {
        justify-content: flex-start;
        margin-top: 8px;
    }
}

/* a row's status as a button: green dot = published, grey = draft; a click switches it */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    transition: background-color 0.2s ease-out, box-shadow 0.2s ease-out;
}

.status-pill.is-on {
    background: #e4f5ea;
    color: #237a3f;
}

.status-pill.is-off {
    background: #eef1f4;
    color: rgb(49 54 70 / 0.6);
}

.status-pill:hover {
    box-shadow: 0 0 0 1.5px currentColor;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
}

.status-pill.is-off .status-dot {
    background: none;
    box-shadow: inset 0 0 0 1.5px currentColor;
}

/* the "แสดงบนหน้าเว็บ" switch in a table row (the forms' switch, smaller) */
.row-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 2px 0;
    color: var(--color-navy);
}

.row-switch .switch-track {
    width: 38px;
    height: 22px;
}

.row-switch .switch-thumb {
    width: 16px;
    height: 16px;
}

.row-switch.is-on .switch-track {
    background: var(--color-teal-dark);
}

.row-switch.is-on .switch-thumb {
    transform: translateX(16px);
}

:is(.goal-card, .goal-scope) .row-switch.is-on .switch-track,
.goal-table-scope .row-switch.is-on .switch-track {
    background: var(--goal);
}

.row-switch:hover .switch-track {
    box-shadow: 0 0 0 3px rgb(84 221 209 / 0.3);
}

/* page links under a table: light rounded buttons, the current page in teal (goal pages: the goal's colour) */
.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}

.pager-info {
    font-size: 13px;
    color: rgb(49 54 70 / 0.55);
}

.pager-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pager-link,
.pager-gap {
    display: grid;
    place-items: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
}

.pager-link {
    background: #fff;
    color: var(--color-navy);
    box-shadow: 0 0 0 1px #e3e8ee;
    transition: background-color 0.2s ease-out, box-shadow 0.2s ease-out;
}

a.pager-link:hover {
    background: var(--color-mint-light);
    box-shadow: 0 0 0 1.5px rgb(47 184 172 / 0.45);
}

.pager-link.is-current {
    background: var(--color-mint-light);
    color: #1f8f86;
    box-shadow: 0 0 0 1.5px rgb(47 184 172 / 0.6);
}

.pager-link.is-disabled {
    color: rgb(49 54 70 / 0.25);
    box-shadow: 0 0 0 1px #eef1f4;
}

.pager-gap {
    color: rgb(49 54 70 / 0.4);
}

/* year filter on a goal's list: small pills; the chosen year in the goal's colour */
.admin-year-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 14px 0 4px;
}

.admin-year {
    padding: 4px 12px;
    border-radius: 999px;
    background: #fff;
    font-size: 13px;
    font-weight: 700;
    color: rgb(49 54 70 / 0.7);
    box-shadow: 0 0 0 1px #e3e8ee;
}

.admin-year:hover {
    box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--goal, var(--color-teal)) 50%, #fff);
}

.admin-year.is-active {
    background: color-mix(in srgb, var(--goal, var(--color-teal)) 14%, #fff);
    color: color-mix(in srgb, var(--goal, var(--color-teal-dark)) 80%, #1b1f2a);
    box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--goal, var(--color-teal)) 50%, #fff);
}

/* table tools (components/admin/table-tools): search + filters on the left, counts and bulk delete on the right */
.table-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
}

.table-tools-filters {
    display: flex;
    flex: 1 1 520px;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.table-search {
    position: relative;
    flex: 1 1 220px;
    max-width: 340px;
}

.table-search svg {
    position: absolute;
    top: 50%;
    left: 12px;
    width: 16px;
    height: 16px;
    color: rgb(49 54 70 / 0.4);
    transform: translateY(-50%);
}

.table-search .admin-input {
    padding-left: 36px;
}

.table-tools .admin-input {
    padding-top: 8px;
    padding-bottom: 8px;
    font-size: 14px;
}

.table-filter {
    width: auto;
    min-width: 150px;
}

.table-clear {
    font-size: 13px;
    font-weight: 700;
    color: #e5243b;
}

.table-bulk {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.table-count {
    font-size: 13px;
    color: rgb(49 54 70 / 0.6);
}

.table-count b {
    color: var(--color-navy);
}

.admin-btn.is-danger.is-solid {
    background: #e5243b;
    color: #fff;
    box-shadow: none;
}

.admin-btn.is-danger.is-solid:hover {
    background: #c51a2f;
}

.admin-btn:disabled {
    opacity: .4;
    pointer-events: none;
}

/* the tick column */
.admin-table .col-check { width: 44px; }

.admin-table .row-check {
    width: 17px;
    height: 17px;
    accent-color: var(--color-teal-dark);
    cursor: pointer;
}

.admin-table tr:has(.row-check:checked) td {
    background: #f0faf8;
}

/* the tick boxes only show while deleting several rows ("ลบหลายรายการ" → body.is-selecting) */
.admin-table .check-cell { display: none; }
body.is-selecting .admin-table .check-cell { display: table-cell; }
.admin-table col.col-check { display: none; }
body.is-selecting .admin-table col.col-check { display: table-column; width: 44px; }

.table-bulk-tools {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.table-bulk-tools[hidden] { display: none; }

/* a filtering column heading: label + funnel, a chip for the chosen value, and a small menu underneath */
.th-filter {
    position: relative;
    display: inline-block;
}

.th-filter summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 8px;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
}

.th-filter summary::-webkit-details-marker { display: none; }

.th-filter summary:hover,
.th-filter[open] summary {
    background: var(--color-mint-light);
    color: var(--color-teal-dark);
}

.th-filter svg {
    width: 13px;
    height: 13px;
    opacity: .45;
}

.th-filter.is-active svg {
    opacity: 1;
    color: var(--color-teal-dark);
}

.th-filter-chip {
    padding: 1px 8px;
    border-radius: 9999px;
    background: var(--color-teal);
    font-size: 11px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: #fff;
}

.th-filter-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: -8px;
    z-index: 30;
    display: grid;
    min-width: 200px;
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 30px rgb(49 54 70 / 0.18), 0 0 0 1px rgb(49 54 70 / 0.06);
}

.th-filter-menu a {
    padding: 7px 10px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
    color: var(--color-navy);
}

.th-filter-menu a:hover,
.th-filter-menu a.is-current {
    background: var(--color-mint-light);
    color: var(--color-teal-dark);
}

/* the table lets the heading menus spill below it */
.admin-card.overflow-x-auto:has(.th-filter[open]) { overflow: visible; }

/* a dropdown in the side menu (case studies › all case studies, videos) */
.admin-nav-group summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
}

.admin-nav-group summary::-webkit-details-marker { display: none; }

.admin-nav-group summary::after {
    content: '▾';
    font-size: 11px;
    opacity: .6;
    transition: transform .2s ease;
}

.admin-nav-group[open] summary::after { transform: rotate(180deg); }

.admin-nav-sub {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 4px 0 4px 14px;
    padding-left: 10px;
    border-left: 1px solid rgb(255 255 255 / .15);
}

.admin-nav-link.is-sub {
    display: block;
    padding: 6px 12px;
    font-size: 13px;
}

.admin-nav-link.is-sub.is-current {
    background: rgb(47 184 172 / .25);
    color: #fff;
}

/* narrow screens: the menu runs across the top, so the dropdown opens as a small panel */
@media (max-width: 1023px) {
    .admin-nav-group { position: relative; flex: none; }
    .admin-nav-sub {
        position: absolute;
        top: 100%;
        left: 0;
        z-index: 40;
        min-width: 170px;
        margin: 4px 0 0;
        padding: 6px;
        border: 0;
        border-radius: 10px;
        background: var(--color-navy);
        box-shadow: 0 10px 24px rgb(0 0 0 / .25);
    }
    .admin-nav-group:not([open]) .admin-nav-sub { display: none; }
}

/* ---------------------------------------------------------------------------------------------------------------
   Live card preview on the news / case study form (components/admin/card-preview, admin.js): the card as the site
   draws it — the site's own fonts and story-card.css — beside the form on wide screens, above it on narrow ones.
   --------------------------------------------------------------------------------------------------------------- */
@media (min-width: 1280px) {
    .post-editor {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 330px;
        align-items: start;
        gap: 40px;
    }

    .post-editor > form { grid-column: 1; grid-row: 1; }

    .card-preview {
        grid-column: 2;
        grid-row: 1;
        position: sticky;
        top: 24px;
    }
}

.card-preview {
    margin-bottom: 32px;
    padding: 18px 18px 16px;
    border-radius: 14px;
    background: #fbf6ee;
    box-shadow: 0 0 0 1px rgb(49 54 70 / 0.08);
}

@media (min-width: 1280px) {
    .card-preview { margin-bottom: 0; }
}

.card-preview-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 10px;
}

.card-preview-head {
    margin-bottom: 14px;
}

.card-preview-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 16px;
    padding: 3px;
    border-radius: 9999px;
    background: rgb(49 54 70 / 0.07);
}

.card-preview-tabs button {
    flex: 1;
    padding: 5px 8px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    color: rgb(49 54 70 / 0.6);
}

.card-preview-tabs button.is-on {
    background: #fff;
    color: var(--color-navy);
    box-shadow: 0 1px 3px rgb(49 54 70 / 0.15);
}

/* the site's typefaces inside the preview (the admin itself uses IBM Plex Sans Thai Looped) */
.card-preview-stage {
    --font-sans: 'Raleway', ui-sans-serif, system-ui, sans-serif;
    --font-serif: 'Merriweather', Georgia, serif;
    --font-script: 'Caveat', cursive;
    position: relative;
    font-family: var(--font-sans);
    line-height: 1.86em;
}

/* both looks are always laid out (so admin.js can measure what gets cut); the one not chosen is kept out of sight */
.card-preview-look {
    max-width: 290px;
    margin: 0 auto;
}

.card-preview-look:not(.is-on) {
    position: absolute;
    top: 0;
    left: 0;
    visibility: hidden;
    pointer-events: none;
}

.card-preview .story-card:hover {
    transform: none;
}

/* the home page's large first card: drawn at its real width (about 590px) and shown at half size */
.card-preview-look.is-large {
    max-width: none;
    width: 590px;
    zoom: 0.5;
}

.card-preview-look.is-large .story-art {
    aspect-ratio: 16 / 9;
}

.card-preview-look.is-large .story-card > span:last-child {
    padding: 18px 22px 20px;
}

.card-preview-look.is-large .story-title {
    font-size: 19px;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    min-height: calc(2 * 1.6em);
}

.card-preview-look.is-large .story-summary {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.7;
    color: color-mix(in srgb, var(--color-navy) 65%, #fff);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.card-preview-look.is-large .story-date {
    font-size: 13px;
}

/* notes under the card: a tick when all is well, amber for what will be cut, grey for tips */
.card-preview-notes {
    display: grid;
    gap: 6px;
    margin-top: 16px;
    font-size: 13px;
    line-height: 1.5;
}

.card-preview-notes li {
    display: flex;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    background: #fff;
}

.card-preview-notes li::before {
    flex: none;
    font-weight: 700;
}

.card-preview-notes .is-ok { color: #2f7d4a; }
.card-preview-notes .is-ok::before { content: '✓'; }
.card-preview-notes .is-warn { color: #9a5b00; background: #fff4dc; }
.card-preview-notes .is-warn::before { content: '!'; }
.card-preview-notes .is-tip { color: rgb(49 54 70 / 0.65); }
.card-preview-notes .is-tip::before { content: 'i'; font-style: italic; }

/* each kind of card at the width the site gives it */
.card-preview-look.is-doc { max-width: 200px; }
.card-preview-look.is-report { max-width: 250px; padding-top: 10px; }

.card-preview :is(.event-card, .doc-sheet, .report-book):hover,
.card-preview .event-card:hover {
    transform: none;
}

/* ---------- /admin/stats: visitors and what they open (admin/stats, components/admin/stats-rows) ---------- */
.stats-periods {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 0 0 1px rgb(49 54 70 / 0.08);
}

.stats-periods a {
    padding: 6px 12px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    color: rgb(49 54 70 / 0.6);
}

.stats-periods a:hover { color: var(--color-navy); }

.stats-periods a.is-active {
    background: var(--color-navy);
    color: #fff;
}

/* the five totals always in one row; on a phone the row scrolls sideways */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 899px) {
    .stats-summary {
        grid-template-columns: repeat(5, minmax(150px, 1fr));
        overflow-x: auto;
        padding-bottom: 6px;
    }
}

.stats-total {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
}

.stats-panel {
    padding: 20px 22px;
}

.stats-panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px 16px;
    margin-bottom: 14px;
}

.stats-panel-head h2 {
    font-family: var(--font-serif);
    font-size: 17px;
    font-weight: 900;
    color: var(--color-navy);
}

.stats-two {
    display: grid;
    gap: 24px;
}

@media (min-width: 1100px) {
    .stats-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* the bar charts: SVG bars on a 100 × 40 drawing, stretched to the panel */
.stats-chart {
    display: block;
    width: 100%;
    height: 180px;
    border-bottom: 1px solid #e6eaee;
}

.stats-chart rect { transition: opacity .15s ease; }
.stats-chart g:hover rect { opacity: .75; }
.stats-chart .is-views { fill: #b9e6df; }
.stats-chart .is-visitors { fill: var(--color-teal); }
.stats-chart.is-hours rect { fill: #fd9d24; }

.stats-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgb(49 54 70 / 0.6);
}

.stats-legend i {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.stats-legend i.is-views { background: #b9e6df; }
.stats-legend i.is-visitors { margin-left: 8px; background: var(--color-teal); }

.stats-axis,
.stats-hours-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: rgb(49 54 70 / 0.5);
}

.stats-hours-axis span {
    flex: 1;
    text-align: center;
}

/* a share bar under a name */
.stats-bar {
    display: block;
    width: 100%;
    height: 6px;
    margin-top: 5px;
    border-radius: 3px;
    background: #eef1f4;
}

.stats-bar rect { fill: var(--goal, var(--color-teal)); }

/* the 17 goals */
.stats-goals {
    display: grid;
    gap: 8px 28px;
}

@media (min-width: 900px) {
    .stats-goals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.stats-goals li {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    grid-template-areas: "n name num" "n bar bar";
    align-items: center;
    column-gap: 10px;
}

.stats-goal-n {
    grid-area: n;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--goal);
    font-size: 12px;
    font-weight: 800;
    color: #fff;
}

.stats-goal-name {
    grid-area: name;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--color-navy);
}

.stats-goals .stats-bar { grid-area: bar; margin-top: 2px; }

.stats-goal-num {
    grid-area: num;
    font-size: 12px;
    font-weight: 700;
    color: rgb(49 54 70 / 0.6);
}

/* ranked lists */
.stats-rows li {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    padding: 9px 0;
    border-top: 1px dashed #e6eaee;
}

.stats-rows li:first-child { border-top: 0; padding-top: 0; }

.stats-rows-rank {
    font-family: var(--font-serif);
    font-size: 14px;
    font-weight: 900;
    color: rgb(49 54 70 / 0.35);
}

.stats-rows-name {
    display: block;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--color-navy);
}

.stats-rows-name a:hover { color: var(--color-teal-dark); text-decoration: underline; }

.stats-rows-last {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: rgb(49 54 70 / 0.45);
}

.stats-rows-num {
    font-size: 14px;
    font-weight: 800;
    text-align: right;
    white-space: nowrap;
    color: var(--color-navy);
}

.stats-rows-num small {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: rgb(49 54 70 / 0.5);
}

/* the latest visits */
.stats-recent {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.stats-recent th {
    padding: 0 10px 8px 0;
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    color: rgb(49 54 70 / 0.5);
}

.stats-recent td {
    padding: 8px 10px 8px 0;
    border-top: 1px dashed #e6eaee;
    color: var(--color-navy);
    vertical-align: top;
}

.stats-recent a:hover { color: var(--color-teal-dark); text-decoration: underline; }

/* the dashboard's visitor strip: four totals in one row */
.stats-summary.is-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 899px) {
    .stats-summary.is-four { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
}

/* ---------- /admin/manuals: the two manuals to open or download (admin/manuals) ---------- */
.manual-list {
    display: grid;
    gap: 20px;
}

@media (min-width: 1100px) {
    .manual-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.manual-card {
    display: flex;
    gap: 18px;
    padding: 24px 26px;
}

.manual-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: #e3f6f3;
    color: #1f9e8f;
}

.manual-card.is-admin .manual-icon {
    background: #fdf1de;
    color: #c77d12;
}

.manual-for {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    color: #1f9e8f;
}

.manual-card.is-admin .manual-for { color: #c77d12; }
