:root {
    /* ── Design tokens, matched to centreforcorrosionstudies/assets/css/style.css ── */
    --navy: #F5F7F9;          /* page background */
    --navy-mid: #EEF2F6;      /* light tint / alt surface */
    --navy-card: #FFFFFF;     /* card / panel surface */
    --navy-deep: #0B2545;     /* dark surface: preview hero, help/preview buttons */
    --steel: #2C4A63;
    --rust: #C2410C;          /* primary accent */
    --rust-light: #A83B12;
    --amber: #C2410C;         /* alias */
    --amber-bright: #D9530F;  /* hover accent */
    --ink: #1A2233;           /* default text */
    --grey-light: #46586E;    /* secondary text */
    --grey-mid: #64788C;      /* muted/caption text */
    --grey-dark: #C7D2DC;     /* borders on light surfaces */
    --rule: rgba(110, 142, 168, 0.16);
    --rule-amber: rgba(194, 65, 12, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--navy);
    color: var(--ink);
    padding: 16px;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    margin-bottom: 20px;
}

header h1 {
    font-size: 24px;
    color: var(--ink);
}

header .subtitle {
    color: var(--grey-light);
    font-size: 14px;
}

/* ─── Toolbar ────────────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    background: var(--navy-card);
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 12px;
}

.toolbar label {
    font-weight: 600;
    font-size: 14px;
}

.toolbar select {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid var(--grey-dark);
    border-radius: 6px;
    background: var(--navy-card);
    font-size: 14px;
}

.toolbar button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
}

.toolbar button:hover {
    opacity: 0.8;
}

.btn-save {
    background: var(--rust);
    color: white;
}

.btn-save:hover {
    background: var(--amber-bright);
}

/* ─── Status ────────────────────────────────────────────────────────── */
.status {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
    background: var(--navy-mid);
    color: var(--grey-light);
}

.status.error {
    background: #fed7d7;
    color: #9b2c2c;
}

.status.success {
    background: #c6f6d5;
    color: #276749;
}

.status.info {
    background: #bee3f8;
    color: #2a4365;
}

/* ─── Main Layout ────────────────────────────────────────────────────── */
.main {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 16px;
}

@media (max-width: 768px) {
    .main {
        grid-template-columns: 1fr;
    }
}

/* ─── List Panel ────────────────────────────────────────────────────── */
.list-panel {
    background: var(--navy-card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 16px;
    max-height: 600px;
    overflow: auto;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.list-header h3 {
    font-size: 16px;
    color: var(--ink);
}

.btn-add {
    background: var(--rust);
    color: white;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}

.btn-add:hover {
    background: var(--amber-bright);
}

#entryList {
    list-style: none;
    padding: 0;
}

#entryList li {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
    border: 1px solid transparent;
}

#entryList li:hover {
    background: var(--navy-mid);
    border-color: var(--grey-dark);
}

#entryList li.active {
    background: rgba(194, 65, 12, 0.08);
    border-color: var(--rust);
    font-weight: 600;
}

/* ─── Fields Panel ───────────────────────────────────────────────────── */
.fields-panel {
    background: var(--navy-card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 16px;
    max-height: 600px;
    overflow: auto;
}

.placeholder {
    color: var(--grey-mid);
    text-align: center;
    padding: 40px 0;
}

.field-group {
    margin-bottom: 14px;
}

.field-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--grey-light);
    margin-bottom: 4px;
}

.field-group input,
.field-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--grey-dark);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--navy-mid);
}

.field-group input:focus,
.field-group textarea:focus {
    outline: none;
    border-color: var(--rust);
    box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.1);
}

.field-group textarea {
    resize: vertical;
    min-height: 80px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.field-group.buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--grey-dark);
}

.field-group.buttons button {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.btn-update {
    background: var(--rust);
    color: white;
}

.btn-update:hover {
    background: var(--amber-bright);
}

.btn-delete {
    background: #e53e3e;
    color: white;
}

.btn-delete:hover {
    background: #c53030;
}

/* ─── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--navy-mid);
}
::-webkit-scrollbar-thumb {
    background: var(--grey-dark);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--grey-mid);
}

/* ─── Help Button ───────────────────────────────────────────────────── */
.btn-help {
    background: var(--steel);
    color: white;
}

.btn-help:hover {
    background: var(--navy-deep);
}

/* ─── Modal ─────────────────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: var(--navy-card);
    margin: 5% auto;
    padding: 30px;
    border: 1px solid var(--grey-dark);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.modal-close {
    color: var(--grey-mid);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--ink);
    text-decoration: none;
}

.modal-content h2 {
    color: var(--ink);
    border-bottom: 2px solid var(--rust);
    padding-bottom: 10px;
    margin-top: 0;
}

.modal-content h3 {
    color: var(--steel);
    margin-top: 20px;
    font-size: 18px;
}

.modal-content hr {
    border: 0;
    border-top: 1px solid var(--grey-dark);
    margin: 20px 0;
}

.modal-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.modal-content table th {
    background: var(--navy-mid);
    text-align: left;
    padding: 8px 12px;
    border: 1px solid var(--grey-dark);
}

.modal-content table td {
    padding: 8px 12px;
    border: 1px solid var(--grey-dark);
}

.modal-content ul, .modal-content ol {
    padding-left: 20px;
}

.modal-content code {
    background: var(--navy-mid);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.modal-content p {
    line-height: 1.6;
}

/* ─── Field Hints ──────────────────────────────────────────────────── */
.field-hint {
    font-size: 11px;
    color: var(--grey-mid);
    margin-top: 4px;
    line-height: 1.4;
}

.field-group input[readonly],
.field-group textarea[readonly] {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--navy-mid) !important;
}

/* ─── Entry Type Header ─────────────────────────────────────────────── */
.entry-type-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
    margin-bottom: 16px;
}

/* ─── Mobile Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .modal-content {
        margin: 10% auto;
        padding: 20px;
        width: 95%;
        max-height: 90vh;
    }

    .modal-content table {
        font-size: 12px;
    }

    .modal-content table th,
    .modal-content table td {
        padding: 4px 8px;
    }
}

/* ─── CMS Upgrades ──────────────────────────────────────────────────── */

/* Fields panel taller to fit rich editors */
.fields-panel {
    max-height: 88vh;
}

/* Required field star */
.required-star {
    color: #e53e3e;
    margin-left: 2px;
}

/* Validation error */
.field-error {
    font-size: 12px;
    color: #c53030;
    font-weight: 600;
    margin-top: 5px;
    padding: 4px 8px;
    background: #fff5f5;
    border-left: 3px solid #e53e3e;
    border-radius: 0 4px 4px 0;
}

/* Date input row */
.date-input-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}
.date-input-wrap input[type="text"] {
    flex: 1;
}
.field-group .date-pick-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    background: var(--rust);
    color: white;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    user-select: none;
}
.date-pick-btn:hover {
    background: var(--amber-bright);
}

/* PDF select button */
.btn-pdf {
    margin-top: 6px;
    background: var(--navy-mid);
    color: var(--grey-light);
    border: 1px solid var(--grey-dark);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.btn-pdf:hover {
    background: var(--grey-dark);
}

/* Preview button in type header */
.btn-preview {
    margin-left: auto;
    background: var(--steel);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn-preview:hover {
    background: var(--navy-deep);
}

/* Word count */
.word-count {
    font-size: 11px;
    color: var(--grey-mid);
    text-align: right;
    margin-top: 4px;
}

/* ─── Quill editor overrides ──────────────────────────────────────── */
.quill-editor {
    border-radius: 0 0 6px 6px;
}
.quill-full .ql-container.ql-snow {
    min-height: 300px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--navy-mid);
    border-color: var(--grey-dark);
    border-radius: 0 0 6px 6px;
}
.quill-minimal .ql-container.ql-snow {
    min-height: 90px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--navy-mid);
    border-color: var(--grey-dark);
    border-radius: 0 0 6px 6px;
}
.ql-toolbar.ql-snow {
    border-color: var(--grey-dark);
    border-radius: 6px 6px 0 0;
    background: var(--navy-card);
}
.quill-editor:focus-within .ql-toolbar.ql-snow,
.quill-editor:focus-within .ql-container.ql-snow {
    border-color: var(--rust);
    box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.1);
}
.ql-snow .ql-stroke { stroke: var(--grey-mid); }
.ql-snow .ql-fill   { fill:   var(--grey-mid); }
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--rust); }
.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill   { fill:   var(--rust); }
.ql-snow .ql-picker-label { color: var(--grey-light); }
.ql-snow .ql-picker-label:hover,
.ql-snow .ql-picker-item:hover,
.ql-snow .ql-picker-item.ql-selected { color: var(--rust) !important; }
.ql-editor { line-height: 1.7; }
.ql-editor.ql-blank::before { color: var(--grey-mid); font-style: normal; }
.ql-toolbar .ql-undo::before  { content: "↩"; font-size: 15px; color: var(--grey-mid); }
.ql-toolbar .ql-redo::before  { content: "↪"; font-size: 15px; color: var(--grey-mid); }
.ql-toolbar .ql-undo:hover::before,
.ql-toolbar .ql-redo:hover::before { color: var(--rust); }
.ql-toolbar .ql-table::before { content: "⊞ Table"; font-size: 11px; font-weight: 600; color: var(--grey-mid); }
.ql-toolbar .ql-table:hover::before,
.ql-toolbar .ql-table.ql-active::before { color: var(--rust); }
.ql-editor table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.ql-editor th { padding: 8px 10px; border: 1px solid var(--grey-dark); background: var(--navy-mid); font-weight: 600; text-align: left; }
.ql-editor td { padding: 7px 10px; border: 1px solid var(--grey-dark); vertical-align: top; }

/* ─── Login page ──────────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: var(--navy-card);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    padding: 40px;
    width: 100%;
    max-width: 380px;
}
.login-card h1 {
    font-size: 20px;
    margin-bottom: 4px;
}
.login-card .subtitle {
    color: var(--grey-light);
    font-size: 13px;
    margin-bottom: 20px;
}
.login-error {
    background: #fed7d7;
    color: #9b2c2c;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}
.login-submit {
    width: 100%;
    margin-top: 6px;
    padding: 10px 16px;
}

/* ─── Header actions (logout) ────────────────────────────────────── */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
}
.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--grey-light);
}
.btn-logout {
    background: transparent;
    color: var(--grey-light);
    border: 1px solid var(--grey-dark);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.btn-logout:hover {
    background: var(--navy-mid);
    color: var(--ink);
}

/* ─── Users / History modal tables ───────────────────────────────── */
.users-table, .history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 12px;
}
.users-table th, .history-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--rust);
    color: var(--grey-light);
}
.users-table td, .history-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--rule);
    vertical-align: top;
}
.btn-small-delete {
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
}
.btn-small-delete:hover { background: #c53030; }
.btn-small-revert {
    background: var(--steel);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
}
.btn-small-revert:hover { background: var(--navy-deep); }
.add-user-form, .change-password-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--grey-dark);
}
.add-user-form .field-group, .change-password-form .field-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 140px;
}

/* Status (draft/published) select */
.status-select {
    padding: 8px 12px;
    border: 1px solid var(--grey-dark);
    border-radius: 6px;
    background: var(--navy-mid);
    font-size: 14px;
    width: 100%;
}
.status-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
}
.status-badge.draft {
    background: #fefcbf;
    color: #744210;
}
.status-badge.published {
    background: #c6f6d5;
    color: #276749;
}

/* Image upload button (Quill toolbar custom control feedback) */
.btn-image-upload {
    margin-top: 6px;
    background: var(--navy-mid);
    color: var(--grey-light);
    border: 1px solid var(--grey-dark);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.btn-image-upload:hover { background: var(--grey-dark); }

/* ─── Preview modal ───────────────────────────────────────────────── */
.preview-modal-content {
    max-width: 960px;
    background: var(--navy-card);
    border: 1px solid var(--grey-dark);
    padding: 0 0 30px;
}
.preview-modal-content h2 {
    color: var(--ink);
    border-bottom-color: var(--rust);
    padding: 30px 30px 10px;
    margin: 0;
}
.preview-modal-content > p {
    color: var(--grey-mid);
    padding: 0 30px;
}
.preview-modal-content .modal-close {
    color: var(--grey-mid);
    margin: 14px 14px 0 0;
}
.preview-modal-content .modal-close:hover {
    color: var(--ink);
}

/* Preview body — mirrors the website's blog-detail-text CSS (light card, dark hero) */
.preview-body p  { margin-bottom: 18px; }
.preview-body h2 {
    font-family: Georgia, serif;
    font-size: 22px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.2;
    margin: 36px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--rule-amber);
}
.preview-body h3 {
    font-family: Georgia, serif;
    font-size: 19px;
    font-weight: 600;
    color: var(--ink);
    margin: 28px 0 10px;
}
.preview-body > h2:first-child,
.preview-body > h3:first-child { margin-top: 0; }
.preview-body ul,
.preview-body ol { padding-left: 24px; margin-bottom: 18px; }
.preview-body li { margin-bottom: 6px; line-height: 1.7; }
.preview-body li::marker { color: var(--rust); }
.preview-body blockquote {
    border-left: 3px solid var(--rust);
    padding: 12px 20px;
    margin: 24px 0;
    background: var(--navy-deep);
    color: #B0C4D8;
    font-style: italic;
}
.preview-body strong { color: var(--ink); font-weight: 600; }
.preview-body a { color: var(--rust); }
.preview-body hr {
    border: 0;
    border-top: 1px solid rgba(110,142,168,0.16);
    margin: 28px 0;
}
.preview-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 14px;
}
.preview-body th {
    background: var(--navy-card);
    padding: 8px 12px;
    border: 1px solid rgba(110,142,168,0.2);
    color: var(--rust);
    text-align: left;
}
.preview-body td {
    padding: 8px 12px;
    border: 1px solid rgba(110,142,168,0.2);
    color: var(--grey-light);
}