* {
    box-sizing: border-box;
}

:root {
    --bg: #f3f5f7;
    --card: #ffffff;
    --text: #1f2933;
    --muted: #677685;
    --border: #d8e0e7;
    --primary: #1f5fa8;
    --primary-dark: #174b85;
    --danger: #b42318;
    --success-bg: #ecfdf3;
    --success-text: #027a48;
    --error-bg: #fef3f2;
    --error-text: #b42318;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 22px 28px;
    background: #17212b;
    color: white;
}

.topbar h1,
.topbar p {
    margin: 0;
}

.topbar p {
    margin-top: 3px;
    color: rgba(255, 255, 255, .75);
}

.logout-link {
    color: white;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 8px;
    padding: 9px 12px;
}

.container {
    width: min(1600px, calc(100% - 32px));
    margin: 24px auto 50px;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(420px, .8fr);
    gap: 22px;
    align-items: start;
}

.card {
    margin-bottom: 22px;
    padding: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 3px 12px rgba(15, 23, 42, .05);
}

.card h2 {
    margin: 0 0 16px;
    font-size: 20px;
}

label {
    display: block;
    margin-bottom: 14px;
    font-weight: 700;
}

input,
textarea,
button,
.button {
    font: inherit;
}

input[type="text"],
input[type="date"],
input[type="search"],
input[type="password"],
input[type="file"],
textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
}

textarea {
    resize: vertical;
}

button,
.button {
    display: inline-block;
    padding: 10px 14px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    text-decoration: none;
}

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

.button.secondary {
    background: #e8edf2;
    color: var(--text);
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.section-head h2,
.section-head p {
    margin: 0;
}

.section-head p,
.hint,
small {
    color: var(--muted);
}

.search-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.search-form input {
    width: 250px;
    margin: 0;
}

.table-wrap {
    overflow-x: auto;
}

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

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

th {
    background: #f8fafc;
    white-space: nowrap;
}

.date-cell {
    white-space: nowrap;
}

.excerpt-cell {
    min-width: 260px;
}

.row-actions {
    min-width: 110px;
}

.row-actions a,
.link-danger {
    display: block;
    margin-bottom: 5px;
    border: 0;
    padding: 0;
    background: none;
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

.link-danger {
    color: var(--danger);
}

.row-actions form {
    margin: 0;
}

.preview-column {
    position: sticky;
    top: 18px;
}

.preview-card iframe {
    width: 100%;
    height: 780px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f6f7f9;
}

.preview-info {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.preview-excerpt {
    margin-bottom: 14px;
    padding: 12px;
    background: #f7f9fb;
    border-left: 4px solid var(--primary);
    border-radius: 6px;
}

.empty-preview {
    padding: 40px 20px;
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.flash {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 8px;
}

.flash.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.flash.error {
    background: var(--error-bg);
    color: var(--error-text);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-box {
    width: min(430px, 100%);
    padding: 28px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .12);
}

.login-box h1 {
    margin-top: 0;
}

.login-box button {
    width: 100%;
}

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

    .preview-column {
        position: static;
    }

    .preview-card iframe {
        height: 650px;
    }
}

@media (max-width: 700px) {
    .section-head {
        display: block;
    }

    .search-form {
        margin-top: 14px;
    }

    .search-form input {
        width: 100%;
    }

    .topbar {
        align-items: flex-start;
    }
}
