* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: #eef2f7;
    color: #1f2937;
}

a {
    color: inherit;
    text-decoration: none;
}

small,
.muted {
    display: block;
    color: #6b7280;
}

code {
    background: #111827;
    color: #f9fafb;
    padding: 2px 6px;
    border-radius: 6px;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 290px;
    background: linear-gradient(180deg, #0f172a, #152b4e);
    color: #e5eefc;
    padding: 28px 20px;
    position: sticky;
    top: 0;
    align-self: flex-start;
    min-height: 100vh;
}

.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    padding-bottom: 20px;
    margin-bottom: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand h1 {
    font-size: 20px;
    margin: 0 0 4px;
}

.brand small {
    color: rgba(229, 238, 252, 0.7);
}

.brand-icon,
.stat-icon,
.nav-icon,
.btn-icon,
.login-brand-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
}

.nav-icon,
.btn-icon {
    width: 18px;
    height: 18px;
    background: transparent;
    border-radius: 0;
}

.brand-icon svg,
.nav-icon svg,
.stat-icon svg,
.btn-icon svg,
.login-brand-icon svg {
    width: 22px;
    height: 22px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    color: #c7d2fe;
    transition: background 0.2s ease, transform 0.2s ease;
}

.nav-link.active,
.nav-link:hover {
    background: rgba(59, 130, 246, 0.18);
    color: #ffffff;
    transform: translateX(2px);
}

.main-content {
    flex: 1;
    padding: 24px;
}

.topbar {
    background: #ffffff;
    border-radius: 24px;
    padding: 22px 26px;
    margin-bottom: 22px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.topbar h2 {
    margin: 0 0 6px;
    font-size: 26px;
}

.topbar p {
    margin: 0;
    color: #6b7280;
}

.topbar-user,
.profile-hero {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-weight: 700;
}

.avatar.large {
    width: 74px;
    height: 74px;
    font-size: 24px;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.page-content {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.card {
    background: #ffffff;
    border-radius: 24px;
    padding: 22px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.bordered-card {
    border: 1px solid #e5e7eb;
}

.card-header,
.section-heading,
.header-actions,
.textarea-head,
.participant-toolbar,
.form-actions,
.filter-actions,
.actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.card-header h3,
.section-heading h4 {
    margin: 0 0 6px;
}

.card-header p,
.section-heading p {
    margin: 0;
    color: #6b7280;
}

.content-grid {
    display: grid;
    gap: 22px;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
}

.stat-card {
    padding: 18px;
    border-radius: 22px;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.stat-card p,
.stat-card h3 {
    margin: 0;
}

.stat-card h3 {
    font-size: 30px;
    margin-top: 6px;
}

.accent-blue { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.accent-green { background: linear-gradient(135deg, #16a34a, #22c55e); }
.accent-amber { background: linear-gradient(135deg, #d97706, #f59e0b); }
.accent-red { background: linear-gradient(135deg, #dc2626, #ef4444); }
.accent-navy { background: linear-gradient(135deg, #1d4ed8, #1e3a8a); }

.timeline {
    display: grid;
    gap: 14px;
}

.timeline-item {
    padding: 16px;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.timeline-item p {
    margin: 8px 0 0;
    color: #475569;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width,
.profile-hero.full-width {
    grid-column: 1 / -1;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    background: #ffffff;
}

textarea {
    resize: vertical;
}

.editor-area {
    font-family: Consolas, monospace;
    line-height: 1.5;
}

.tinymce-shell {
    border-radius: 22px;
    overflow: hidden;
    background: #edf3f9;
    border: 1px solid #dbe4f0;
}

.tinymce-shell .tox.tox-tinymce {
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.tinymce-shell .tox .tox-editor-header {
    background: linear-gradient(180deg, #ffffff, #f5f7fb);
    box-shadow: inset 0 -1px 0 #dbe4f0;
}

.tinymce-shell .tox .tox-menubar,
.tinymce-shell .tox .tox-toolbar-overlord,
.tinymce-shell .tox .tox-toolbar,
.tinymce-shell .tox .tox-toolbar__primary,
.tinymce-shell .tox .tox-toolbar__overflow {
    background: transparent;
}

.tinymce-shell .tox .tox-edit-area::before {
    border: 0;
}

.tinymce-shell .tox .tox-statusbar {
    border-top: 1px solid #dbe4f0;
    background: #f8fafc;
}

.tinymce-shell .tox .tox-edit-area__iframe {
    background: #dde6f1;
}

.tinymce-shell .tox:not(.tox-tinymce-inline) .tox-editor-header,
.tinymce-shell .tox:not(.tox-tinymce-inline) .tox-statusbar {
    padding-left: 8px;
    padding-right: 8px;
}

.tinymce-shell .tox .tox-mbtn,
.tinymce-shell .tox .tox-tbtn,
.tinymce-shell .tox .tox-tbtn svg,
.tinymce-shell .tox .tox-statusbar__path-item,
.tinymce-shell .tox .tox-statusbar__wordcount {
    color: #0f172a;
}

.tinymce-shell .tox .tox-tbtn:hover,
.tinymce-shell .tox .tox-mbtn:hover {
    background: #eff6ff;
}

.tinymce-shell .tox .tox-tbtn--enabled,
.tinymce-shell .tox .tox-mbtn--active {
    background: #dbeafe !important;
    color: #1d4ed8 !important;
}

.tinymce-shell .tox .tox-sidebar-wrap {
    background: #dde6f1;
}

.tinymce-shell .tox .tox-edit-area {
    padding: 16px 0 22px;
}

.word-editor {
    border: 1px solid #dbe4f0;
    border-radius: 22px;
    overflow: hidden;
    background: #eef4fb;
}

.word-ribbon {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border-bottom: 1px solid #dbe4f0;
}

.ribbon-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 12px;
    border-right: 1px solid #e5e7eb;
}

.ribbon-group:last-child {
    border-right: 0;
    padding-right: 0;
}

.ribbon-btn,
.chip-btn {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    border-radius: 10px;
    padding: 8px 11px;
    font-size: 13px;
    cursor: pointer;
}

.ribbon-btn:hover,
.chip-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

.ribbon-btn-accent {
    background: #0f766e;
    color: #ffffff;
    border-color: #0f766e;
}

.word-chipbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
    background: #f8fbff;
    border-bottom: 1px solid #dbe4f0;
}

.word-stage,
.word-preview-stage {
    padding: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.25), rgba(203, 213, 225, 0.12)),
        #dde6f1;
}

.word-ruler {
    max-width: 820px;
    height: 28px;
    margin: 0 auto 12px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background:
        repeating-linear-gradient(
            to right,
            #f8fafc 0,
            #f8fafc 19px,
            #94a3b8 19px,
            #94a3b8 20px
        );
}

.word-sheet,
.word-preview-sheet {
    max-width: 820px;
    min-height: 1120px;
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.14);
    padding: 2.4cm 2.2cm;
}

.word-editor-surface,
.word-preview-sheet {
    font-family: "Times New Roman", Times, serif;
    font-size: 12pt;
    line-height: 1.7;
    color: #000000;
}

.word-editor-surface {
    min-height: calc(1120px - 4.8cm);
    outline: none;
}

.word-editor-surface:focus {
    box-shadow: inset 0 0 0 2px #bfdbfe;
    border-radius: 6px;
}

.word-editor-surface p,
.word-preview-sheet p {
    margin: 0 0 12px;
}

.word-editor-surface h1,
.word-editor-surface h2,
.word-editor-surface h3,
.word-preview-sheet h1,
.word-preview-sheet h2,
.word-preview-sheet h3 {
    font-family: "Times New Roman", Times, serif;
    color: #000000;
}

.word-editor-surface table,
.word-preview-sheet table {
    width: 100%;
    border-collapse: collapse;
}

.word-editor-surface td,
.word-editor-surface th,
.word-preview-sheet td,
.word-preview-sheet th {
    vertical-align: top;
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 11px 16px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-primary { background: #2563eb; color: #ffffff; }
.btn-secondary { background: #0f766e; color: #ffffff; }
.btn-light { background: #f3f4f6; color: #111827; }
.btn-danger { background: #dc2626; color: #ffffff; }

.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.form-group.compact label {
    font-size: 13px;
}

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

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

.table th,
.table td {
    padding: 14px 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}

.table th {
    color: #475569;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.empty-state,
.empty-panel {
    text-align: center;
    padding: 28px;
    color: #6b7280;
}

.inline-form {
    display: inline-flex;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-warning { background: #fef3c7; color: #92400e; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-secondary { background: #e5e7eb; color: #374151; }

.alert {
    border-radius: 18px;
    padding: 14px 18px;
    margin-bottom: 20px;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }

.participant-list {
    display: grid;
    gap: 16px;
}

.participant-row {
    border: 1px solid #dbe4f0;
    border-radius: 20px;
    padding: 16px;
    background: #f8fbff;
}

.participant-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.signature-pad {
    width: 100%;
    max-width: 100%;
    border: 1px dashed #93c5fd;
    border-radius: 16px;
    background: #ffffff;
    margin-top: 12px;
    touch-action: none;
}

.signature-preview,
.image-inline-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.signature-preview img,
.image-inline-preview img,
.signature-thumb {
    max-height: 70px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: #ffffff;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.photo-card {
    background: #f8fafc;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.photo-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.checkbox-inline {
    display: flex;
    gap: 8px;
    padding: 12px;
    align-items: center;
    font-size: 13px;
}

.checkbox-inline input {
    width: auto;
}

.info-grid,
.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.info-card,
.doc-card {
    padding: 16px;
    background: #f8fafc;
    border-radius: 18px;
    border: 1px solid #e5e7eb;
}

.info-card span,
.doc-card p {
    color: #6b7280;
}

.info-card strong,
.doc-card h5 {
    display: block;
    margin-top: 8px;
}

.detail-grid {
    margin-top: 18px;
}

.detail-section {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 18px;
}

.detail-section h4 {
    margin-top: 0;
}

.rich-box,
.document-preview {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 16px;
    line-height: 1.7;
}

.document-preview.word-preview-sheet {
    border-radius: 0;
    padding: 2.4cm 2.2cm;
    line-height: 1.7;
}

.card-section {
    margin-top: 22px;
}

.placeholder-box {
    background: #eff6ff;
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 18px;
}

.placeholder-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.placeholder-list span {
    padding: 8px 10px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #bfdbfe;
    font-size: 13px;
}

.login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-shell {
    width: 100%;
    max-width: 920px;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 28px;
    align-items: center;
}

.login-brand {
    color: #ffffff;
    display: flex;
    gap: 18px;
    align-items: center;
}

.login-brand h1,
.login-brand p,
.login-card h2 {
    margin: 0;
}

.login-card {
    background: #ffffff;
    border-radius: 24px;
    padding: 28px;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
}

.login-card form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.login-note {
    margin-top: 18px;
    font-size: 14px;
    color: #475569;
}

.help-text {
    color: #6b7280;
    font-size: 13px;
}

@media (max-width: 1024px) {
    .content-grid.two-column,
    .form-grid,
    .participant-grid,
    .login-shell {
        grid-template-columns: 1fr;
    }

    .word-sheet,
    .word-preview-sheet {
        padding: 24px 18px;
        min-height: 720px;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
        position: static;
    }

    .app-shell {
        flex-direction: column;
    }

    .main-content {
        padding: 18px;
    }

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

@media print {
    .sidebar,
    .topbar,
    .btn,
    .filter-bar,
    .word-ribbon,
    .word-chipbar,
    .word-ruler {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 0;
        padding: 0;
    }

    .word-stage,
    .word-preview-stage {
        background: #ffffff;
        padding: 0;
    }

    .word-sheet,
    .word-preview-sheet {
        max-width: none;
        min-height: auto;
        border: 0;
        box-shadow: none;
        padding: 1.8cm 2cm;
    }
}
