:root {
    --bg: #f4efe7;
    --surface: #fffdf9;
    --surface-strong: #102542;
    --text: #1c1f23;
    --muted: #6d7278;
    --border: rgba(16, 37, 66, 0.12);
    --primary: #c04b32;
    --primary-dark: #9d3924;
    --success: #2f7d4a;
    --warning: #d18a1d;
    --danger: #b43838;
    --shadow: 0 18px 45px rgba(16, 37, 66, 0.12);
}

body {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    background:
        radial-gradient(circle at top left, rgba(192, 75, 50, 0.16), transparent 28%),
        linear-gradient(180deg, #f8f4ee 0%, var(--bg) 100%);
    color: var(--text);
}

a {
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 300px 1fr;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 2rem;
    background: linear-gradient(180deg, #183a5c 0%, #102542 100%);
    color: #fff;
}

.brand {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.brand-subtitle {
    margin-top: 0.75rem;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.6;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.85rem 1rem;
    border-radius: 1rem;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.12);
    transform: translateX(4px);
}

.sidebar-footer {
    padding-top: 1rem;
}

.user-card {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-radius: 1rem;
    background-color: rgba(255, 255, 255, 0.1);
}

.user-name {
    font-weight: 700;
}

.user-role {
    color: rgba(255, 255, 255, 0.72);
}

.content {
    padding: 2rem;
}

.hero-card,
.panel-card,
.info-card,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    box-shadow: var(--shadow);
}

.hero-card {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 2rem;
    padding: 2rem;
    margin-bottom: 2rem;
}

.auth-panel,
.panel-card,
.info-card {
    padding: 1.5rem;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background-color: rgba(192, 75, 50, 0.12);
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-heading h1 {
    margin: 0.5rem 0 0;
    font-size: clamp(1.8rem, 2vw, 2.6rem);
    letter-spacing: -0.05em;
}

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

.stat-card {
    padding: 1.25rem 1.5rem;
}

.stat-card span {
    display: block;
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin-top: 0.6rem;
    font-size: 2rem;
    letter-spacing: -0.05em;
}

.stat-card.neutral strong {
    color: var(--surface-strong);
}

.stat-card.warning strong {
    color: var(--warning);
}

.stat-card.success strong {
    color: var(--success);
}

.stat-card.danger strong {
    color: var(--danger);
}

.panel-title {
    margin-bottom: 1rem;
}

.panel-title h2 {
    margin: 0;
    font-size: 1.1rem;
}

.progress-item + .progress-item {
    margin-top: 1.25rem;
}

.progress {
    height: 0.85rem;
    border-radius: 999px;
    background-color: #e8ded2;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary) 0%, #e07d49 100%);
}

.table-link {
    color: var(--surface-strong);
    font-weight: 700;
}

.status-badge {
    background-color: rgba(47, 125, 74, 0.12);
    color: var(--success);
    border: 1px solid rgba(47, 125, 74, 0.22);
    padding: 0.65rem 1rem;
}

.timeline-list {
    display: grid;
    gap: 1rem;
}

.timeline-item {
    padding-left: 1rem;
    border-left: 3px solid rgba(192, 75, 50, 0.22);
}

.timeline-item span {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0.25rem 0 0.5rem;
}

.footer-note {
    margin-top: 2rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.form-check {
    padding: 0.85rem 1rem;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: rgba(16, 37, 66, 0.02);
}

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

.table td:first-child,
.table th:first-child {
    white-space: normal;
}

.project-link-box {
    padding: 1rem;
    border: 1px dashed var(--border);
    border-radius: 1rem;
    background: rgba(16, 37, 66, 0.03);
}

.status-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    display: inline-block;
    border: 1px solid rgba(16, 37, 66, 0.14);
    flex: 0 0 auto;
}

.help-actions {
    display: grid;
    gap: 0.5rem;
}

.guide-modal {
    border: 1px solid var(--border);
    border-radius: 1.5rem;
}

.guide-modal .modal-header,
.guide-modal .modal-body {
    padding: 1.5rem;
}

.guide-modal .modal-header {
    border-bottom: 1px solid var(--border);
}

.guide-section + .guide-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(16, 37, 66, 0.08);
}

.guide-section h3 {
    margin-bottom: 0.55rem;
    font-size: 1.05rem;
}

.guide-section p {
    margin-bottom: 0.55rem;
    color: var(--text);
}

.guide-steps {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.75rem;
}

.guide-step {
    padding: 0.8rem 1rem;
    border-radius: 1rem;
    background: rgba(192, 75, 50, 0.08);
    border: 1px solid rgba(192, 75, 50, 0.14);
    font-weight: 500;
}

.task-description {
    line-height: 1.8;
    font-size: 1.02rem;
}

.rich-content p:last-child {
    margin-bottom: 0;
}

.rich-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border-radius: 1rem;
}

.rich-content table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
}

.rich-content table td,
.rich-content table th {
    border: 1px solid rgba(16, 37, 66, 0.14);
    padding: 0.7rem;
}

.attachment-gallery {
    display: grid;
    gap: 1rem;
}

.attachment-preview-link {
    display: block;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: rgba(16, 37, 66, 0.02);
    color: var(--text);
}

.attachment-preview-image {
    display: block;
    width: 100%;
    max-height: 520px;
    object-fit: contain;
    border-radius: 0.9rem;
    background: #f3f3f3;
}

.attachment-preview-caption {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
}

.attachment-preview-card {
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: rgba(16, 37, 66, 0.02);
    overflow: hidden;
}

.attachment-preview-card .attachment-preview-link {
    border: 0;
    border-radius: 0;
    background: transparent;
}

.attachment-preview-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem 1rem;
}

.status-update-form {
    padding: 1rem;
    border: 1px solid rgba(192, 75, 50, 0.14);
    border-radius: 1rem;
    background: rgba(192, 75, 50, 0.05);
}

.completion-note-box {
    padding: 0.9rem;
    border-radius: 1rem;
    background: rgba(16, 37, 66, 0.04);
    border: 1px solid rgba(16, 37, 66, 0.08);
}

.task-editor-panel {
    padding: 1.75rem;
}

.task-editor-form .form-label {
    font-weight: 600;
}

.task-editor-submit {
    min-height: 46px;
    margin-top: 0.1rem;
}

.task-editor-panel .tox.tox-tinymce {
    border: 1px solid rgba(16, 37, 66, 0.12);
    border-radius: 1.25rem;
    overflow: hidden;
    background: #fffdfb;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.task-editor-panel .tox .tox-editor-header {
    border-bottom: 1px solid rgba(16, 37, 66, 0.08);
    background: linear-gradient(180deg, #fffdf9 0%, #f6efe6 100%);
}

.task-editor-panel .tox .tox-toolbar-overlord,
.task-editor-panel .tox .tox-toolbar__primary,
.task-editor-panel .tox .tox-toolbar__overflow {
    background: transparent;
}

.task-editor-panel .tox .tox-toolbar__group {
    padding: 0 0.35rem;
}

.task-editor-panel .tox .tox-edit-area__iframe {
    background: #fffdfb;
}

.task-editor-panel .tox .tox-statusbar {
    border-top: 1px solid rgba(16, 37, 66, 0.08);
    background: #fffaf4;
}

.task-editor-panel .tox.tox-tinymce--fullscreen {
    border-radius: 0;
}

.task-editor-hints {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.task-editor-hints span {
    padding: 0.7rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(16, 37, 66, 0.1);
    background: rgba(16, 37, 66, 0.03);
    color: var(--muted);
    font-size: 0.92rem;
}

.writing-assistant-card {
    padding: 1.2rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(16, 37, 66, 0.1);
    background: linear-gradient(180deg, rgba(16, 37, 66, 0.03) 0%, rgba(192, 75, 50, 0.04) 100%);
}

.writing-assistant-header h3 {
    margin: 0.6rem 0 0.35rem;
    font-size: 1.15rem;
}

.writing-assistant-header p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.writing-assistant-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.writing-assistant-status {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    background: rgba(255, 253, 249, 0.9);
    border: 1px solid rgba(16, 37, 66, 0.08);
    color: var(--muted);
}

.writing-assistant-result {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid rgba(16, 37, 66, 0.1);
    background: #fffdf9;
}

.writing-assistant-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.writing-assistant-preview {
    max-height: 360px;
    overflow: auto;
    padding-right: 0.25rem;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

@media (max-width: 991.98px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding: 1.5rem;
    }

    .hero-card {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .content {
        padding: 1rem;
    }

    .page-heading {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .task-editor-panel {
        padding: 1rem;
    }

    .task-editor-panel .tox.tox-tinymce {
        min-height: 520px;
    }

    .task-editor-hints {
        flex-direction: column;
    }

    .writing-assistant-actions,
    .writing-assistant-result-header {
        flex-direction: column;
        align-items: stretch;
    }
}
