:root {
    --page-background: #f4f1ea;
    --content-background: #fffdf8;
    --heading-color: #243447;
    --text-color: #2f3337;
    --muted-text: #66615a;
    --accent-color: #7a2f35;
    --accent-hover: #60242a;
    --gold-accent: #a17b3f;
    --border-color: #d7d0c4;
    --danger-color: #9b2c2c;
    --danger-hover: #7a2020;
    --shadow-color: rgba(34, 38, 42, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        linear-gradient(
            rgba(244, 241, 234, 0.94),
            rgba(244, 241, 234, 0.94)
        ),
        repeating-linear-gradient(
            0deg,
            rgba(92, 76, 55, 0.025) 0,
            rgba(92, 76, 55, 0.025) 1px,
            transparent 1px,
            transparent 4px
        );
    color: var(--text-color);
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.6;
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/*==================================================
    HEADER
==================================================*/
.site-header {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 20px 26px;
    background: var(--heading-color);
    color: white;
    border-bottom: 4px solid var(--gold-accent);
    box-shadow: 0 4px 14px var(--shadow-color);
}

.site-logo {
    width: 95px;
    height: auto;
}

.header-right {
    flex: 1;
}

.site-title {
    margin: 0;
    font-size: 1.65rem;
    letter-spacing: 0.03em;
}

.site-subtitle {
    margin: 4px 0 0;
    color: #e5e1d9;
    font-size: 0.95rem;
}

.site-nav {
    margin-top: 14px;
}

.site-nav a {
    color: white;
    margin-right: 14px;
}

.site-nav a:hover {
    color: #f0dca8;
}

/*==================================================
    GENERAL LAYOUT
==================================================*/
.page-content {
    background: var(--content-background);
    padding: 28px;
    border: 1px solid var(--border-color);
    box-shadow: 0 5px 18px var(--shadow-color);
}

.site-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 28px auto;
}

/*==================================================
    HOME PAGE
==================================================*/
.home-hero {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    margin-bottom: 35px;
}

.home-intro {
    flex: 1;
    min-width: 0;
}

.book-cover {
    width: 260px;
    height: auto;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 18px
        rgba(0,0,0,.18);
}

.flash-message {
    margin: 0 0 18px 0;
    padding: 12px 15px;
    border: 1px solid;
    border-radius: 6px;
    font-weight: 600;
}

.flash-success {
    border-color: #74a982;
    background: #e4f3e8;
    color: #18582a;
}

.flash-info {
    border-color: #7d9dbd;
    background: #e8f1fa;
    color: #234d72;
}

.flash-warning {
    border-color: #c7a34e;
    background: #fff2cf;
    color: #654900;
}

.flash-error {
    border-color: #bd7777;
    background: #f9e3e3;
    color: #761d1d;
}

.admin-message {
    margin: 0 0 18px 0;
    padding: 12px 15px;
    border: 1px solid;
    border-radius: 6px;
    font-weight: 600;
}

.admin-message-success {
    border-color: #74a982;
    background: #e4f3e8;
    color: #18582a;
}

.admin-message-info {
    border-color: #7d9dbd;
    background: #e8f1fa;
    color: #234d72;
}

.admin-message-warning {
    border-color: #c7a34e;
    background: #fff2cf;
    color: #654900;
}

.admin-message-error {
    border-color: #bd7777;
    background: #f9e3e3;
    color: #761d1d;
}

.admin-users-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

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

.admin-users-table th,
.admin-users-table td {
    white-space: normal;
    overflow-wrap: break-word;
    vertical-align: top;
}

.manage-users-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}
.manage-users-header h2 {
    margin: 0 0 6px 0;
}
.manage-users-header p {
    margin: 0;
    color: #555;
}
.user-summary-grid {
    display: grid;
    grid-template-columns:
    repeat(auto-fit, minmax(130px, 1fr));
    gap: 6px;
    margin: 10px 0;
}
.user-summary-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 82px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    color: inherit;
    text-decoration: none;
}
.user-summary-card:hover {
    border-color: #777;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.12);
}
.user-summary-count {
    font-size: 1.7rem;
    font-weight: bold;
}
.user-summary-label {
    margin-top: 4px;
    font-size: 0.9rem;
}
.user-filter-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #f7f7f7;
}
.user-filter-panel label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-management-table th,
.user-management-table td {
    padding: 6px 8px;
}

.user-filter-panel input,
.user-filter-panel select,
.status-form input,
.status-form select,
.inline-form select {
    min-height: 30px;
    padding: 5px 7px 20px 5px;
    border: 1px solid #aaa;
    border-radius: 4px;
    background: white;
}

.activity-cell {
    width: 130px;
    min-width: 130px;
}

.activity-block {
    display: grid;
    gap: 5px;
}

.activity-item {
    display: grid;
    gap: 1px;
}

.activity-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #666;
}

.activity-value {
    font-size: 0.85rem;
    white-space: nowrap;
}

.form-label {
    font-size: 0.78rem;
    white-space: nowrap;
}
.secondary-text,
.muted-text,
.status-reason {
    color: #666;
    font-size: 0.85rem;
}
.status-reason {
    margin-top: 5px;
    max-width: 220px;
}

.status-reason-entry {
    margin-top: 6px;
}
.status-reason-entry input {
    width: 100%;
    min-height: 34px;
    padding: 5px 7px;
    box-sizing: border-box;
    border: 1px solid #aaa;
    border-radius: 4px;
}

.status-reason-entry[hidden] {
    display: none;
}
.verification-line {
    margin-top: 6px;
}
.badge {
    display: inline-block;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 0.77rem;
    font-weight: bold;
    line-height: 1.25;
}
.verified {
    background: #dff3e5;
    color: #155c2d;
}
.unverified {
    background: #f6e3c5;
    color: #72500c;
}
.status-pending {
    background: #fff1c9;
    color: #6b4b00;
}
.status-active {
    background: #dff3e5;
    color: #155c2d;
}
.status-suspended {
    background: #fde4bd;
    color: #754800;
}
.status-banned {
    background: #f6d5d5;
    color: #7b1616;
}
.status-archived {
    background: #e2e2e2;
    color: #444;
}
.current-user-marker {
    display: inline-block;
    margin-left: 5px;
    padding: 2px 6px;
    border-radius: 5px;
    background: #333;
    color: white;
    font-size: 0.7rem;
}
.role-assignment-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.role-assignment-form {
    display: flex;
    align-items: center;
    gap: 5px;
}
.role-assignment-form select,
.account-status-inline select {
    height: 30px;
    padding: 2px 26px 2px 8px;
    font-size: 0.90rem;
    line-height: 1.2;
    box-sizing: border-box;
}
.role-assignment-form button,
.account-status-inline button {
    height: 30px;
    padding: 0 12px;
}
.roles-cell {
    width: 190px;
    min-width: 190px;
}
.role-control-list {
    display: flex;
    flex-wrap: wrap;
    gap: 3 px 5px;
    margin-bottom: 6px;
}
.role-remove-form {
    display: inline-flex;
    align-items: center;
}
.inline-form {
    display: flex;
    gap: 5px;
    align-items: center;
}
.status-form {
    display: grid;
    gap: 7px;
}
.status-form label {
    display: grid;
    gap: 3px;
}
.small-button,
.filter-button {
    height: 30px;
    padding: 6px 12px;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
}
.small-button {
    background: #333;
    color: white;
}
.filter-button {
    background: #333;
    color: white;
}
.clear-filter-link {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
}
.details-link,
.reason-link {
    display: inline-block;
    margin-top: 5px;
    margin-right: 10px;
    font-size: 0.78rem;
}
.empty-state {
    padding: 30px !important;
    text-align: center !important;
    color: #666;
}
.page-footer-navigation {
    margin-top: 20px;
}

/* ==========================================================
   DOCUMENT IMAGE BLOCK
   ========================================================== */
.document-image {
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
}
.document-image-content {
    display: block;
    width: 100%;
    height: auto;
}


/* ----------------------------------------------------------
   Alignment
   ---------------------------------------------------------- */
.document-image--left {
    margin-right: auto;
    margin-left: 0;
}
.document-image--center {
    margin-right: auto;
    margin-left: auto;
}
.document-image--right {
    margin-right: 0;
    margin-left: auto;
}


/* ----------------------------------------------------------
   Semantic sizes
   ---------------------------------------------------------- */
.document-image--small {
    width: min(100%, 180px);
}
.document-image--medium {
    width: min(100%, 280px);
}
.document-image--large {
    width: min(100%, 480px);
}
.document-image--full {
    width: 100%;
}

/* ----------------------------------------------------------
   Caption
   ---------------------------------------------------------- */
.document-image-caption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: center;
}
/* ----------------------------------------------------------
   Book-cover presentation
   ---------------------------------------------------------- */
.document-image--style-book-cover
.document-image-content {
    border-radius: 4px;
    box-shadow: 0 0.4rem 1rem rgb(0 0 0 / 18%);
}


@media (max-width: 800px) {
    .manage-users-header {
        flex-direction: column;
    }
    .user-filter-panel {
        align-items: stretch;
    }
    .user-filter-panel label {
            width: 100%;
    }
}

h1,
h2,
h3,
h4 {
    color: var(--heading-color);
    line-height: 1.25;
}

h2 {
    margin-top: 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gold-accent);
}

.portal-card {
    margin-bottom: 18px;
    padding: 18px;
    background: white;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--gold-accent);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.portal-card h3 {
    margin-top: 0;
}

.portal-card-muted {
    background: #f8f6f1;
}

.portal-status {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    background: #ece7dc;
    color: var(--heading-color);
    font-size: 0.88rem;
    font-weight: bold;
}

.button,
button,
input[type="submit"] {
    display: inline-block;
    padding: 9px 15px;
    border: 1px solid var(--accent-color);
    border-radius: 5px;
    background: var(--accent-color);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: bold;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
    transition:
        background 0.15s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
    background: var(--accent-hover);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.16);
}

.button-secondary {
    background: white;
    color: var(--accent-color);
}

.button-secondary:hover {
    background: #f3ece7;
    color: var(--accent-hover);
}

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

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

.button-small {
    padding: 6px 10px;
    font-size: 0.86rem;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    align-items: center;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: white;
}

th,
td {
    padding: 10px;
    border: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
}

th {
    background: #eee9df;
    color: var(--heading-color);
}

tr:nth-child(even) td {
    background: #faf8f4;
}

textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select {
    width: min(100%, 760px);
    padding: 9px 10px;
    border: 1px solid #bcb5aa;
    border-radius: 4px;
    background: white;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
}
/* ==========================================================
   ADMINISTRATIVE TASK PANEL
   ========================================================== */

.admin-task-panel {
    margin: 0 0 1.75rem 0;
    padding: 1.25rem;
    border: 1px solid #d8d8d8;
    border-left-width: 6px;
    border-radius: 8px;
    background: #ffffff;
}

.admin-task-summary {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

.admin-task-status-icon {
    flex: 0 0 auto;
    font-size: 1.6rem;
    line-height: 1;
}

.admin-task-summary-text {
    flex: 1 1 auto;
}

.admin-task-summary-text h2 {
    margin: 0 0 0.35rem 0;
    font-size: 1.2rem;
}

.admin-task-summary-text p {
    margin: 0;
}

.admin-task-list {
    display: grid;
    gap: 0.65rem;
    margin-top: 1rem;
}

.admin-task-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;

    padding: 0.8rem 1rem;

    border: 1px solid #d8d8d8;
    border-radius: 6px;

    color: inherit;
    text-decoration: none;
    background: #ffffff;
}
.admin-task-row:hover,
.admin-task-row:focus {
    background: #f4f4f4;
    text-decoration: none;
}
.admin-task-row-label {
    font-weight: 600;
}
.admin-task-count {
    display: inline-flex;
    justify-content: center;
    align-items: center;

    min-width: 2rem;
    height: 2rem;
    padding: 0 0.55rem;

    border-radius: 999px;
    font-weight: 700;
    background: #eeeeee;
}

/* ----------------------------------------------------------
   GREEN — no tasks pending
   ---------------------------------------------------------- */
.admin-task-status-clear {
    border-left-color: #2f7d32;
}
.admin-task-status-clear .admin-task-status-icon {
    color: #2f7d32;
}
/* ----------------------------------------------------------
   YELLOW — normal-priority tasks pending
   ---------------------------------------------------------- */

.admin-task-status-normal {
    border-left-color: #c79400;
}
.admin-task-status-normal .admin-task-status-icon {
    color: #c79400;
}
.admin-task-status-normal .admin-task-count {
    background: #fff3c4;
}

/* ----------------------------------------------------------
   RED — urgent tasks pending
   ---------------------------------------------------------- */
.admin-task-status-urgent {
    border-left-color: #b3261e;
}
.admin-task-status-urgent .admin-task-status-icon {
    color: #b3261e;
}
.admin-task-status-urgent .admin-task-count {
    color: #ffffff;
    background: #b3261e;
}

textarea:focus,
input:focus,
select:focus {
    outline: 2px solid rgba(122, 47, 53, 0.20);
    border-color: var(--accent-color);
}

.notice {
    margin: 15px 0;
    padding: 12px 14px;
    border-left: 4px solid var(--gold-accent);
    background: #f7f2e7;
}

.notice-warning {
    border-left-color: #b77820;
    background: #fff5df;
}

.notice-danger {
    border-left-color: var(--danger-color);
    background: #faeaea;
}

.site-footer {
    padding: 18px 24px;

    color: var(--muted-text);
    background: #ebe6dc;

    border-top: 1px solid var(--border-color);

    text-align: center;
    font-size: 0.84rem;
    line-height: 1.45;
}

.site-footer p {
    margin: 5px auto;
    max-width: 920px;
}

.development-notice {
    padding: 11px 18px;

    background: #f3e4bb;
    color: #40351f;

    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid #c8aa65;

    font-size: 0.92rem;
    line-height: 1.45;
    text-align: center;
}

.development-notice strong {
    color: var(--accent-color);
}

.project-status-card {
    border-left-color: var(--accent-color);
    background: #faf5e9;
}

.project-progress {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 7px;
    margin: 18px 0;
}

.progress-stage {
    padding: 9px 7px;

    background: #e3ded4;
    color: var(--muted-text);

    border: 1px solid var(--border-color);
    border-radius: 4px;

    text-align: center;
    font-size: 0.82rem;
}

.progress-stage.complete {
    background: #dce7da;
    color: #355136;
}

.progress-stage.active {
    background: #f3e4bb;
    color: #5c4317;
    border-color: var(--gold-accent);
    font-weight: bold;
}
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin: 0.1rem 0.2rem 0.1rem 0;
    padding: 0.18rem 0.4rem;
    border-radius: 999px;
    background: #e8edf5;
    font-size: 0.72rem;
    font-weight: 400;     /* was 600; */
}

.role-remove-button {
    border: none;
    background: transparent;
    color: #666;
    width: 16px;
    height: 16px;
    padding: 0;
    margin: 0;
    font-size: 0.72rem;
    line-height: 1;
    cursor: pointer;
}

.role-remove-button:hover,
.role-remove-button:focus {
    color: #a00000;
}

/* ==========================================================
   Program Information Pages
   ========================================================== */

.programs-page,
.program-detail-page {
    max-width: 960px;
    margin: 0 auto;
}

.programs-header {
    margin-bottom: 24px;
}

.programs-header h2,
.program-detail-header h2 {
    margin-bottom: 8px;
}

.programs-header p,
.program-introduction {
    color: #555;
    line-height: 1.55;
}

.program-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.program-card {
    display: flex;
    flex-direction: column;
    padding: 22px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: white;
}

.program-card h3 {
    margin-top: 0;
}

.program-card p {
    line-height: 1.5;
}

.program-card .program-button {
    margin-top: auto;
}

.program-button {
    display: inline-block;
    width: fit-content;
    padding: 9px 15px;
    border: 1px solid #555;
    border-radius: 5px;
    background: #333;
    color: white;
    font-weight: 600;
    text-decoration: none;
}

.program-button:hover,
.program-button:focus {
    background: #555;
    color: white;
}

.program-back-link {
    margin-bottom: 18px;
}

.program-section {
    margin: 26px 0;
}

.program-section h3 {
    margin-bottom: 8px;
}

.program-section p,
.program-section li {
    line-height: 1.55;
}

.program-section li {
    margin-bottom: 6px;
}

.program-application-panel {
    margin-top: 30px;
    padding: 20px;
    border: 1px solid #bbb;
    border-radius: 8px;
    background: #f5f5f5;
}

.program-application-panel h3 {
    margin-top: 0;
}

/* ==========================================================
   Program Application Forms
   ========================================================== */

.program-application-form {
    max-width: 820px;
    margin: 0 auto;
}

.application-form-header {
    margin-bottom: 24px;
}

.application-form-header h2 {
    margin-bottom: 10px;
}

.program-application-form .form-field {
    margin-bottom: 22px;
}

.program-application-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

.program-application-form textarea,
.program-application-form input[type="text"] {
    box-sizing: border-box;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #999;
    border-radius: 5px;
    font: inherit;
    line-height: 1.45;
}

.program-application-form textarea {
    resize: vertical;
}

.program-application-form textarea:focus,
.program-application-form input[type="text"]:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.field-help {
    margin: 0 0 7px;
    color: #555;
    font-size: 0.92rem;
    line-height: 1.4;
}

.required-marker {
    font-weight: 700;
}

.form-error,
.form-error-summary {
    color: #8b0000;
}

.form-error {
    margin: 6px 0 0;
    font-size: 0.92rem;
    font-weight: 600;
}

.form-error-summary {
    margin-bottom: 20px;
    padding: 12px;
    border: 1px solid #8b0000;
    border-radius: 5px;
    background: #fff5f5;
}

.application-form-actions {
    margin-top: 26px;
}

@media (max-width: 760px) {
    .program-card-grid {
        grid-template-columns: 1fr;
    }
}

.actions-cell {
    width: 210px;
    min-width: 210px;
    padding: 6px 8px !important;
}

.account-status-form {
    display: block;
    width: 100%;
    min-width: 0;
}

.account-status-form > label {
    display: none;
}

.account-status-inline {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;
}

.account-status-inline input {
    flex: 1 1 100px;
    width: 100px;
    min-width: 0;
}

.account-status-form > a {
    display: inline-block;
    margin-top: 5px;
    font-size: 0.8rem;
}

/*==================================================
    RESPONSIVE LAYOUT
==================================================*/

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

@media (max-width: 760px) {
    .site-shell {
        width: min(100% - 18px, 1120px);
        margin: 10px auto;
    }

    .home-hero {
        flex-direction: column;
        align-items: center;
    }

    .home-intro {
        width: 100%;
    }

    .page-content {
        padding: 18px;
    }

    .button-row {
        align-items: stretch;
    }

    .button-row .button,
    .button-row button {
        width: 100%;
        text-align: center;
    }

    table {
        font-size: 0.9rem;
    }

    .enlarged-book-cover {
        max-width: 82vw;
        max-height: 70vh;
    }

    .cover-dialog-content {
        padding: 16px;
    }

}