:root {
    --bg: #f2efe8;
    --panel: rgba(255, 252, 245, 0.88);
    --panel-border: rgba(48, 34, 21, 0.14);
    --panel-strong: rgba(255, 250, 242, 0.96);
    --text: #221811;
    --muted: #6d5848;
    --accent: #b64827;
    --accent-dark: #8d3115;
    --success: #2e6b4d;
    --success-dark: #214f39;
    --danger: #a12c2f;
    --danger-dark: #7f1f21;
    --shadow: 0 22px 60px rgba(58, 34, 18, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Trebuchet MS", Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(201, 123, 70, 0.28), transparent 32%),
        radial-gradient(circle at bottom right, rgba(93, 135, 101, 0.26), transparent 30%),
        linear-gradient(135deg, #f8f4ec 0%, #ede7db 48%, #e7ddcf 100%);
}

h1,
h2,
h3 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
}

p {
    margin: 0;
}

label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.92rem;
    font-weight: 700;
}

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

input,
textarea,
select {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(34, 24, 17, 0.14);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgba(182, 72, 39, 0.36);
    background: rgba(255, 255, 255, 0.98);
    box-shadow:
        0 0 0 4px rgba(182, 72, 39, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

textarea {
    resize: vertical;
}

button {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.7;
    cursor: wait;
    transform: none;
}

.page-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.stack {
    display: grid;
    gap: 1rem;
}

.eyebrow {
    margin-bottom: 0.6rem;
    color: var(--accent-dark);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.78rem;
    font-weight: 700;
}

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

.error-banner {
    padding: 0.85rem 1rem;
    border-radius: 16px;
    color: #8f1f21;
    background: rgba(194, 48, 51, 0.1);
}

.success-banner {
    padding: 0.85rem 1rem;
    border-radius: 16px;
    color: var(--success-dark);
    background: rgba(46, 107, 77, 0.12);
}

.primary-button,
.toggle-button {
    padding: 0.9rem 1.15rem;
    color: #fff7ef;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
}

.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.05rem;
    color: var(--text);
    background: rgba(34, 24, 17, 0.06);
    text-decoration: none;
}

.menu-button {
    color: #fff7ef;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    box-shadow: 0 12px 24px rgba(141, 49, 21, 0.18);
}

.menu-button:hover {
    background: linear-gradient(135deg, #c35633 0%, #972f12 100%);
}

.login-layout {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 1.5rem;
    align-items: stretch;
    min-height: calc(100vh - 5rem);
}

.hero-card,
.login-layout .panel,
.dashboard-layout .panel {
    padding: 2rem;
}

.hero-card {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 480px;
    border-radius: 32px;
    color: #fff7ef;
    background:
        linear-gradient(135deg, rgba(29, 23, 18, 0.18), rgba(29, 23, 18, 0.52)),
        linear-gradient(140deg, #7a341d 0%, #b64827 45%, #d08b46 100%);
    box-shadow: var(--shadow);
}

.hero-card h1 {
    font-size: clamp(2.4rem, 5vw, 4.4rem);
}

.hero-copy {
    max-width: 34rem;
    margin-top: 1rem;
    font-size: 1.05rem;
    line-height: 1.6;
}

.dashboard-layout {
    display: grid;
    gap: 1.5rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    background:
        linear-gradient(135deg, rgba(255, 249, 240, 0.95), rgba(248, 239, 224, 0.82));
    box-shadow:
        var(--shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.board-grid {
    display: grid;
    grid-template-columns: 1.5fr 0.9fr;
    gap: 1.5rem;
}

.section-heading {
    display: grid;
    gap: 0.4rem;
}

.section-heading h2 {
    font-size: 1.55rem;
}

.section-date {
    color: var(--muted);
    font-size: 0.88em;
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
    padding: 0.9rem;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(255, 255, 255, 0.22));
    box-shadow:
        inset 0 0 0 1px rgba(34, 24, 17, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.deal-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.85rem;
}

.deal-table th {
    padding: 0 1rem 0.7rem;
    text-align: left;
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.deal-table td {
    padding: 1rem;
    vertical-align: middle;
    border-top: 1px solid rgba(34, 24, 17, 0.08);
    border-bottom: 1px solid rgba(34, 24, 17, 0.08);
    box-shadow: none;
}

.deal-table td:first-child {
    border-left: 1px solid rgba(34, 24, 17, 0.1);
    border-radius: 20px 0 0 20px;
    font-weight: 700;
}

.deal-table td:last-child {
    border-right: 1px solid rgba(34, 24, 17, 0.1);
    border-radius: 0 20px 20px 0;
}

.deal-table tbody tr {
    transition: transform 0.16s ease, filter 0.16s ease;
}

.deal-table tbody tr:hover {
    transform: translateY(-2px);
    filter: none;
}

.deal-cell-open {
    background: #f7dede;
    border-top-color: rgba(161, 44, 47, 0.2);
    border-bottom-color: rgba(161, 44, 47, 0.2);
}

.deal-cell-done {
    background: #dff0e4;
    border-top-color: rgba(46, 107, 77, 0.2);
    border-bottom-color: rgba(46, 107, 77, 0.2);
}

.deal-cell-open:first-child {
    border-left-color: rgba(161, 44, 47, 0.2);
    box-shadow:
        inset 8px 0 0 0 rgba(161, 44, 47, 0.9),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.deal-cell-done:first-child {
    border-left-color: rgba(46, 107, 77, 0.2);
    box-shadow:
        inset 8px 0 0 0 rgba(46, 107, 77, 0.92),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.deal-cell-open:last-child {
    border-right-color: rgba(161, 44, 47, 0.2);
}

.deal-cell-done:last-child {
    border-right-color: rgba(46, 107, 77, 0.2);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
}

.status-pill.open {
    color: var(--danger-dark);
    background: rgba(194, 48, 51, 0.16);
    border: 1px solid rgba(161, 44, 47, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.status-pill.done {
    color: var(--success-dark);
    background: rgba(46, 107, 77, 0.18);
    border: 1px solid rgba(46, 107, 77, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.toggle-button {
    min-width: 154px;
    box-shadow: 0 12px 24px rgba(41, 27, 17, 0.14);
}

.toggle-done {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
}

.toggle-open {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
}

.article-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.35));
    box-shadow:
        inset 0 0 0 1px rgba(34, 24, 17, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.article-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.books-grid {
    grid-template-columns: 1.3fr 1fr;
}

.books-filters {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
}

.books-filter-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.author-search-form {
    display: grid;
    gap: 0.75rem;
}

.two-column-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.author-list {
    display: grid;
    gap: 0.7rem;
    max-height: 220px;
    overflow-y: auto;
    padding: 1rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.48);
    border: 1px solid rgba(34, 24, 17, 0.08);
}

.author-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    font-weight: 600;
}

.author-option input {
    width: auto;
}

.section-divider {
    height: 1px;
    background: rgba(34, 24, 17, 0.1);
    margin: 0.5rem 0;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 0.2rem;
}

.pagination-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ghost-button.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.article-label {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.article-link {
    color: var(--accent-dark);
    font-weight: 700;
    line-height: 1.6;
    word-break: break-word;
}

.empty-state {
    display: grid;
    gap: 0.5rem;
    padding: 1.65rem;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 251, 244, 0.64));
    border: 1px dashed rgba(34, 24, 17, 0.16);
    color: var(--muted);
}

.board-grid > .panel,
.board-grid > aside.panel {
    background:
        linear-gradient(180deg, var(--panel-strong), rgba(251, 246, 238, 0.86));
}

.board-grid > aside.panel {
    position: relative;
    overflow: hidden;
}

.board-grid > aside.panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 120px;
    background:
        radial-gradient(circle at top right, rgba(182, 72, 39, 0.12), transparent 54%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent);
    pointer-events: none;
}

.board-grid > aside.panel > * {
    position: relative;
}

.board-grid form.stack {
    gap: 1.1rem;
}

.primary-button {
    box-shadow: 0 14px 26px rgba(141, 49, 21, 0.22);
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.menu-card {
    display: grid;
    gap: 0.8rem;
    padding: 1.75rem;
    color: inherit;
    text-decoration: none;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.menu-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 24px 48px rgba(58, 34, 18, 0.16);
    border-color: rgba(182, 72, 39, 0.24);
}

.menu-card-label {
    color: var(--accent-dark);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.76rem;
    font-weight: 700;
}

.menu-card-link {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(182, 72, 39, 0.1);
    color: var(--accent-dark);
    font-weight: 700;
}

.is-hidden {
    display: none !important;
}

.dialogs-page {
    --dialog-bg-1: #e7f0ff;
    --dialog-bg-2: #d7e7ff;
    --dialog-panel: #f8fbff;
    --dialog-panel-border: rgba(24, 72, 152, 0.24);
    --dialog-text: #0f2146;
    --dialog-muted: #4d668e;
    --dialog-accent: #1661cc;
    --dialog-accent-dark: #0f4eab;
    --dialog-shadow: 0 18px 38px rgba(18, 65, 134, 0.16);
}

.dialogs-page .panel {
    border-radius: 8px;
    background: var(--dialog-panel);
    border-color: var(--dialog-panel-border);
    box-shadow: var(--dialog-shadow);
}

.dialogs-page .topbar {
    background:
        linear-gradient(135deg, rgba(232, 242, 255, 0.96), rgba(210, 229, 255, 0.85));
}

.dialogs-page .dialogs-grid {
    grid-template-columns: 0.95fr 1.05fr;
}

.dialogs-page h1,
.dialogs-page h2,
.dialogs-page h3 {
    color: var(--dialog-text);
}

.dialogs-page .subtle-copy {
    color: var(--dialog-muted);
}

.dialogs-page input,
.dialogs-page textarea,
.dialogs-page select,
.dialogs-page button,
.dialogs-page .ghost-button,
.dialogs-page .menu-card-link {
    border-radius: 2px;
}

.dialogs-page input,
.dialogs-page textarea,
.dialogs-page select {
    border: 1px solid rgba(23, 80, 170, 0.28);
    background: linear-gradient(180deg, #ffffff, #f3f8ff);
    box-shadow: none;
}

.dialogs-page input:focus,
.dialogs-page textarea:focus,
.dialogs-page select:focus {
    border-color: rgba(22, 97, 204, 0.8);
    box-shadow: 0 0 0 3px rgba(22, 97, 204, 0.16);
}

.dialogs-page .dialog-toggle-button,
.dialogs-page .dialog-primary-button {
    background: linear-gradient(135deg, var(--dialog-accent), var(--dialog-accent-dark));
    color: #f4f9ff;
    border-radius: 2px;
    box-shadow: 0 10px 18px rgba(12, 66, 151, 0.25);
}

.dialogs-page .dialog-toggle-button {
    padding: 0.75rem 1rem;
    border: 0;
}

.dialogs-page .ghost-button {
    background: rgba(22, 97, 204, 0.08);
    color: var(--dialog-text);
}

.dialogs-page .menu-button {
    color: #f4f9ff;
    background: linear-gradient(135deg, var(--dialog-accent), var(--dialog-accent-dark));
}

.dialogs-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.dialogs-page .dialogs-create-form {
    padding: 1rem;
    border: 1px solid rgba(22, 97, 204, 0.2);
    background: linear-gradient(180deg, rgba(236, 245, 255, 0.92), rgba(228, 240, 255, 0.88));
}

.dialogs-page .dialog-list {
    display: grid;
    gap: 0.7rem;
}

.dialogs-page .dialog-list-item {
    display: grid;
    gap: 0.45rem;
    text-decoration: none;
    color: var(--dialog-text);
    padding: 0.85rem;
    border: 1px solid rgba(23, 80, 170, 0.22);
    background: linear-gradient(180deg, #fbfdff, #eef4ff);
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.dialogs-page .dialog-list-item:hover {
    transform: translateY(-1px);
    border-color: rgba(22, 97, 204, 0.52);
    box-shadow: 0 8px 18px rgba(22, 97, 204, 0.16);
}

.dialogs-page .dialog-list-item.is-active {
    border-color: rgba(22, 97, 204, 0.86);
    box-shadow:
        inset 4px 0 0 rgba(22, 97, 204, 1),
        0 10px 20px rgba(22, 97, 204, 0.2);
}

.dialogs-page .dialog-list-top {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: baseline;
}

.dialogs-page .dialog-list-bottom p {
    margin: 0;
}

.dialogs-page .dialog-messages-list {
    display: grid;
    gap: 0.75rem;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.dialogs-page .dialog-message-item {
    border: 1px solid rgba(23, 80, 170, 0.2);
    background: linear-gradient(180deg, #ffffff, #f1f7ff);
    padding: 0.85rem;
}

.dialogs-page .dialog-message-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.45rem;
}

.dialogs-page .dialog-message-item p {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.45;
}

.dialogs-page .dialogs-empty {
    border-radius: 2px;
    border-color: rgba(22, 97, 204, 0.22);
    background: linear-gradient(180deg, rgba(245, 250, 255, 0.95), rgba(231, 242, 255, 0.78));
    color: var(--dialog-muted);
}

.dialogs-page .dialogs-empty-center {
    min-height: 280px;
    place-content: center;
}

@media (max-width: 920px) {
    .login-layout,
    .board-grid {
        grid-template-columns: 1fr;
    }

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

    .topbar-actions {
        width: 100%;
    }

    .article-card {
        flex-direction: column;
        align-items: stretch;
    }

    .two-column-grid {
        grid-template-columns: 1fr;
    }

    .books-filters {
        grid-template-columns: 1fr;
    }

    .books-filter-actions {
        justify-content: stretch;
    }

    .pagination-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .article-actions {
        justify-content: stretch;
    }

    .dialogs-page .dialogs-grid {
        grid-template-columns: 1fr;
    }

    .dialogs-header-row {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .page-shell {
        width: min(100% - 1rem, 1180px);
        padding-top: 0.75rem;
    }

    .hero-card,
    .login-layout .panel,
    .dashboard-layout .panel {
        padding: 1.25rem;
        border-radius: 24px;
    }

    .deal-table th,
    .deal-table td {
        white-space: nowrap;
    }

    .toggle-button {
        width: 100%;
    }
}
