:root {
    --app-bg: #f3f6fb;
    --app-card: #ffffff;
    --app-border: rgba(15, 23, 42, 0.08);
    --app-primary: #315efb;
    --app-primary-soft: rgba(49, 94, 251, 0.08);
    --app-text: #0f172a;
    --app-muted: #64748b;
}

body {
    min-height: 100vh;
    background: linear-gradient(180deg, #eef4ff 0%, var(--app-bg) 35%, #f8fafc 100%);
    color: var(--app-text);
}

.app-main {
    min-height: calc(100vh - 10rem);
    position: relative;
    z-index: 1;
}

.app-shell {
    width: min(1320px, calc(100% - 2rem));
    margin: 0 auto;
}

.app-navbar {
    position: sticky;
    top: 0;
    z-index: 1100;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.app-navbar .app-shell,
.app-navbar .navbar-collapse,
.user-menu-dropdown {
    position: relative;
}

.app-navbar .navbar-collapse {
    z-index: 1101;
}

.navbar .nav-link {
    color: rgba(255, 255, 255, 0.82);
}

.navbar .nav-link:hover,
.navbar .nav-link:focus {
    color: #ffffff;
}

.brand-title {
    letter-spacing: 0.01em;
}

.user-menu-dropdown {
    margin-left: 0.35rem;
}

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.45rem 0.85rem 0.45rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(49, 94, 251, 0.95) 0%, rgba(37, 99, 235, 0.78) 100%);
    color: #fff;
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
}

.user-menu-trigger:hover,
.user-menu-trigger:focus,
.user-menu-trigger.show {
    color: #fff;
    border-color: rgba(191, 219, 254, 0.42);
    background: linear-gradient(135deg, rgba(59, 130, 246, 1) 0%, rgba(37, 99, 235, 0.88) 100%);
}

.user-menu-avatar {
    width: 2.2rem;
    height: 2.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    font-weight: 700;
}

.user-menu-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.user-menu-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.78;
}

.user-menu-panel {
    min-width: 14rem;
    border-radius: 1rem;
    padding-bottom: 0.45rem;
    z-index: 1110;
}

.user-menu-panel .dropdown-item {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

.news-content {
    white-space: normal;
    line-height: 1.65;
    font-size: 1rem;
}

.news-textarea {
    min-height: 16rem;
    font-family: inherit;
    line-height: 1.6;
}

.news-editor-shell {
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0.95rem;
    overflow: hidden;
    background: #fff;
}

.news-toolbar {
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: #f8fafc;
}

.news-editor {
    min-height: 16rem;
}

.news-editor .ql-editor {
    min-height: 16rem;
    font-size: 1rem;
    line-height: 1.7;
}

.news-content h1,
.news-content h2,
.news-content h3,
.news-content h4 {
    color: var(--app-text);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.news-content p,
.news-content ul,
.news-content ol,
.news-content blockquote {
    margin-bottom: 0.75rem;
}

.news-content blockquote {
    border-left: 4px solid rgba(49, 94, 251, 0.28);
    padding-left: 1rem;
    color: var(--app-muted);
}

.news-content a {
    color: var(--app-primary);
}

.app-card {
    border: 1px solid var(--app-border);
    border-radius: 1.15rem;
    background: var(--app-card);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
}

.news-card,
.settings-priority-card {
    border-color: rgba(49, 94, 251, 0.14);
    box-shadow: 0 18px 42px rgba(49, 94, 251, 0.10);
}

.account-card,
.settings-intro-card {
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--app-primary);
}

.stat-chip {
    max-width: 100%;
    border-radius: 0.9rem;
    background: #f8fafc;
    border: 1px solid var(--app-border);
    padding: 0.85rem 1rem;
}

.stat-chip-label {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--app-muted);
    margin-bottom: 0.35rem;
}

.table-responsive {
    border-radius: 1rem;
    -webkit-overflow-scrolling: touch;
}

.preview-list-shell {
    max-height: 40rem;
    overflow: auto;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.92) 0%, rgba(255, 255, 255, 0.96) 100%);
}

.job-table-shell {
    max-height: 30rem;
}

.dashboard-files-shell {
    max-height: 34rem;
}

.file-card-list {
    display: grid;
    gap: 0.85rem;
    padding: 0.25rem;
}

.file-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.05rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.94);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.file-card:hover {
    transform: translateY(-1px);
    border-color: rgba(49, 94, 251, 0.22);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

.file-card-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.file-card-title {
    font-weight: 600;
}

.file-card-title code {
    overflow-wrap: anywhere;
}

.file-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    font-size: 0.92rem;
    color: var(--app-muted);
}

.file-card-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.preview-list-shell .table {
    margin-bottom: 0;
    table-layout: fixed;
}

.preview-list-shell thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.08);
}

.preview-list-shell::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.preview-list-shell::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.4);
    border-radius: 999px;
    border: 3px solid rgba(255, 255, 255, 0.9);
}

.preview-list-shell::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, 0.5);
    border-radius: 999px;
}

.entry-comment-line {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.entry-comment-text {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-selector-badges {
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.preview-list-shell .table th:nth-child(1),
.preview-list-shell .table td:nth-child(1) {
    width: 7.5rem;
}

.preview-list-shell .table th:nth-child(2),
.preview-list-shell .table td:nth-child(2) {
    width: 8.5rem;
}

.table > :not(caption) > * > * {
    background-color: transparent;
}

.table thead th {
    color: var(--app-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table tbody tr {
    border-color: rgba(15, 23, 42, 0.06);
}

.table tbody tr:hover {
    background: rgba(49, 94, 251, 0.03);
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.editor-textarea,
.log-pane {
    min-height: 26rem;
    font-family: "SFMono-Regular", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.92rem;
}

.selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.selector-option {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    border: 1px solid var(--app-border);
    border-radius: 0.9rem;
    background: #f8fafc;
    padding: 0.8rem 0.9rem;
}

.selector-option span {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.selector-option small {
    color: var(--app-muted);
}

.selector-catalog-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--app-border);
    border-radius: 0.9rem;
    background: #f8fafc;
}

.settings-subsection-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--app-border);
    border-radius: 1rem;
    background: #f8fafc;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.settings-subsection-link:hover {
    transform: translateY(-1px);
    border-color: rgba(49, 94, 251, 0.22);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

.settings-subsection-link span {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.settings-subsection-link small {
    color: var(--app-muted);
}

.settings-accordion .accordion-item {
    overflow: hidden;
}

.settings-accordion-button {
    align-items: flex-start;
    gap: 1rem;
    border-radius: 1.15rem !important;
    background: transparent;
    box-shadow: none !important;
    padding: 1.25rem 1.35rem;
}

.settings-accordion-button:not(.collapsed) {
    color: inherit;
    background: rgba(248, 250, 252, 0.86);
}

.settings-accordion-button::after {
    margin-top: 0.2rem;
}

.settings-accordion .accordion-body {
    padding: 0 1.35rem 1.35rem;
}

.app-footer {
    border-top: 1px solid var(--app-border);
    background: rgba(255, 255, 255, 0.55);
}

.app-footer-link {
    color: var(--app-primary);
    text-decoration: none;
    font-weight: 600;
}

.app-footer-link:hover {
    text-decoration: underline;
}

.log-pane {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 0.9rem;
    padding: 1rem;
    overflow: auto;
    white-space: pre-wrap;
}

.log-pane-compact {
    min-height: 18rem;
    max-height: 24rem;
}

.log-pane-debug {
    min-height: 14rem;
    max-height: 22rem;
}

.job-progress-shell {
    width: 100%;
    height: 0.9rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
    overflow: hidden;
}

.job-progress-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.35s ease, background-color 0.25s ease;
}

.job-progress-bar.is-running {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.job-progress-bar.is-finished {
    background: linear-gradient(90deg, #10b981 0%, #22c55e 100%);
}

.debug-log-toggle {
    border: 1px solid var(--app-border);
    border-radius: 0.95rem;
    background: #f8fafc;
    padding: 1rem;
}

.debug-log-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}

.debug-log-summary::-webkit-details-marker {
    display: none;
}

.debug-log-toggle[open] .debug-log-summary {
    margin-bottom: 0.25rem;
}

.form-check-input:checked {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

code {
    color: #0b3edc;
}

.btn {
    border-radius: 0.8rem;
    min-height: 44px;
}

.btn.btn-sm {
    min-height: 36px;
}

.form-control,
.form-select {
    border-radius: 0.85rem;
    border-color: rgba(15, 23, 42, 0.12);
    min-height: 44px;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(49, 94, 251, 0.45);
    box-shadow: 0 0 0 0.25rem rgba(49, 94, 251, 0.12);
}

@media (max-width: 991px) {
    .app-shell {
        width: min(100%, calc(100% - 1rem));
    }

    .app-main {
        min-height: calc(100vh - 8rem);
    }

    .app-navbar .navbar-collapse {
        margin-top: 0.85rem;
        padding: 0.85rem;
        border: 1px solid rgba(148, 163, 184, 0.18);
        border-radius: 1rem;
        background: rgba(15, 23, 42, 0.96);
        box-shadow: 0 16px 30px rgba(15, 23, 42, 0.22);
    }

    .navbar-nav {
        gap: 0.45rem;
    }

    .navbar .nav-link {
        padding: 0.8rem 0.95rem;
        border-radius: 0.85rem;
        background: rgba(255, 255, 255, 0.05);
    }

    .user-menu-dropdown {
        width: 100%;
        margin-left: 0;
    }

    .user-menu-trigger {
        width: 100%;
        justify-content: flex-start;
        margin-top: 0.25rem;
    }

    .user-menu-panel {
        width: 100%;
        min-width: 0;
        margin-top: 0.5rem;
    }

    .app-card {
        border-radius: 1rem;
    }

    .app-card .card-body {
        padding: 1rem;
    }

    .settings-intro-card .stat-chip {
        width: 100%;
    }

    .settings-accordion-button {
        padding: 1rem 1rem;
    }

    .settings-accordion .accordion-body {
        padding: 0 1rem 1rem;
    }

    .table.table-mobile thead {
        display: none;
    }

    .table.table-mobile,
    .table.table-mobile tbody,
    .table.table-mobile tr,
    .table.table-mobile td {
        display: block;
        width: 100%;
    }

    .table.table-mobile tbody {
        display: grid;
        gap: 0.85rem;
    }

    .table.table-mobile tr {
        border: 1px solid var(--app-border);
        border-radius: 1rem;
        background: #f8fafc;
        padding: 0.25rem;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
    }

    .table.table-mobile td {
        border: 0;
        padding: 0.55rem 0.75rem;
        text-align: left !important;
    }

    .table.table-mobile td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.2rem;
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--app-muted);
    }

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

    .table-actions .btn,
    .table-actions form {
        flex: 1 1 calc(50% - 0.25rem);
    }

    .table-actions .btn,
    .table-actions form .btn {
        width: 100%;
    }

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

    .file-card-actions {
        width: 100%;
        justify-content: stretch;
    }

    .file-card-actions .btn,
    .file-card-actions form,
    .file-card-actions form .btn {
        width: 100%;
    }

    .log-pane-compact {
        min-height: 14rem;
        max-height: 18rem;
        font-size: 0.84rem;
    }

    .preview-list-shell {
        max-height: none;
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .preview-list-shell .table {
        table-layout: auto;
    }

    .preview-list-shell thead th {
        position: static;
        box-shadow: none;
    }

    .entry-comment-line {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .entry-comment-text {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }

    .entry-selector-badges {
        margin-top: 0.1rem;
    }

    .log-pane-debug {
        min-height: 12rem;
        max-height: 16rem;
        font-size: 0.82rem;
    }

    .debug-log-summary {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 575px) {
    .app-shell {
        width: min(100%, calc(100% - 0.75rem));
    }

    .brand-title {
        font-size: 0.95rem;
    }

    h1.h3,
    h1.h4,
    .h4 {
        font-size: 1.15rem;
    }

    .eyebrow {
        font-size: 0.68rem;
        letter-spacing: 0.12em;
    }

    .job-progress-shell {
        height: 0.8rem;
    }

    .table-actions .btn,
    .table-actions form {
        flex-basis: 100%;
    }
}
