:root {
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    color: #1f2937;
    background: #f4f7fb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

.container {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
}

.header {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.header-content {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.header strong {
    display: block;
    font-size: 1.2rem;
}

.subtitle {
    color: #6b7280;
    font-size: 0.85rem;
}

nav {
    display: flex;
    gap: 18px;
}

.main-nav {
    align-items: center;
    flex-wrap: wrap;
}

.session-user {
    color: #6b7280;
    font-size: 0.85rem;
}

.logout-form {
    margin: 0;
}

.logout-form button {
    padding: 7px 11px;
    background: #475569;
}

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

.login-card {
    width: min(100%, 420px);
    padding: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 18px 45px rgb(15 23 42 / 10%);
}

.login-brand strong,
.login-brand span {
    display: block;
}

.login-card h1 {
    margin: 28px 0 8px;
}

.login-intro {
    margin: 0 0 24px;
    color: #6b7280;
}

.login-form {
    display: grid;
    gap: 18px;
}

.login-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font: inherit;
}

.login-error {
    margin-bottom: 18px;
    padding: 12px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    background: #fef2f2;
    color: #991b1b;
}

nav a {
    color: #374151;
    text-decoration: none;
    font-weight: 600;
}

nav a:hover {
    color: #111827;
}

.hero {
    padding: 72px 0 42px;
}

.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e0ecff;
    color: #1d4ed8;
    font-size: 0.85rem;
    font-weight: 700;
}

.hero h1 {
    margin: 18px 0 12px;
    font-size: clamp(2rem, 5vw, 3.4rem);
}

.hero p {
    max-width: 720px;
    margin: 0;
    color: #6b7280;
    font-size: 1.1rem;
    line-height: 1.7;
}

.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding-bottom: 60px;
}

.card {
    padding: 24px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgb(15 23 42 / 6%);
}

.card h2 {
    margin-top: 0;
}

.card p {
    min-height: 96px;
    color: #6b7280;
    line-height: 1.6;
}

.button,
button {
    display: inline-block;
    padding: 11px 16px;
    border: 0;
    border-radius: 10px;
    background: #2563eb;
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}

button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

@media (max-width: 800px) {
    .header-content {
        align-items: flex-start;
        flex-direction: column;
        padding: 18px 0;
    }

    .cards {
        grid-template-columns: 1fr;
    }

    .card p {
        min-height: auto;
    }


}

.upload-card {
    max-width: 720px;
    margin-bottom: 60px;
}

.upload-card form {
    display: grid;
    gap: 16px;
}

.upload-card label {
    font-weight: 700;
}

.upload-card input[type="file"] {
    width: 100%;
    padding: 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
}

.form-help {
    margin: 0;
    color: #6b7280;
    font-size: 0.9rem;
}

.message {
    margin-bottom: 20px;
    padding: 14px;
    border: 1px solid #86efac;
    border-radius: 10px;
    background: #f0fdf4;
    color: #166534;
}

.form-group {
    display: grid;
    gap: 8px;
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #ffffff;
    color: #111827;
    font: inherit;
}

.form-group textarea {
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: 2px solid #bfdbfe;
    border-color: #2563eb;
}

.documents-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.documents-card {
    margin-bottom: 60px;
    padding: 0;
    overflow: hidden;
}

.table-wrapper {
    width: 100%;
}

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

.documents-table th,
.documents-table td {
    padding: 14px 16px;
    text-align: left;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

.documents-table th {
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    color: #374151;
    font-size: 0.9rem;
}

.document-row:hover,
.document-row:hover + .document-actions-row,
.document-actions-row:hover {
    background: #f9fafb;
}

.document-row td {
    padding-top: 18px;
    padding-bottom: 12px;
    font-weight: 500;
}

.document-title,
.document-filename,
.document-category {
    display: block;
}

.document-title {
    color: #1f2937;
    font-size: 0.95rem;
}

.document-filename {
    margin-top: 3px;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 400;
}

.document-category {
    margin-top: 7px;
}

.documents-table button {
    padding: 8px 12px;
    font-size: 0.875rem;
}

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

.document-actions-row td {
    padding-top: 10px;
    padding-bottom: 18px;
    border-bottom: 1px solid #dbe3ee;
    background: #f8fafc;
}

.document-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.secondary-button {
    background: #475569;
    color: #ffffff;
}

.secondary-button:hover {
    background: #334155;
}

.danger-button {
    background: #dc2626;
    color: #ffffff;
}

.danger-button:hover {
    background: #b91c1c;
}

.empty-state {
    padding: 40px 24px;
    color: #6b7280;
    text-align: center;
}

.status-badge {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-uploaded {
    background: #e0ecff;
    color: #1d4ed8;
}

.status-processing {
    background: #fef3c7;
    color: #92400e;
}

.status-extracted {
    background: #ede9fe;
    color: #6d28d9;
}

.status-chunked {
    background: #cffafe;
    color: #0e7490;
}

.status-indexed {
    background: #dcfce7;
    color: #166534;
}

.status-indexing,
.status-partially_indexed {
    background: #fef3c7;
    color: #92400e;
}

.status-indexing_error,
.status-error,
.status-unknown {
    background: #fee2e2;
    color: #991b1b;
}

.chunk-count {
    display: block;
    margin-top: 6px;
    color: #64748b;
    font-size: 0.75rem;
}

@media (max-width: 800px) {
    nav {
        flex-wrap: wrap;
    }

    .hero {
        padding-top: 48px;
    }

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

    .documents-actions .button {
        width: 100%;
        text-align: center;
    }

    .documents-card {
        border-radius: 12px;
    }

    .documents-table th,
    .documents-table td {
        padding-right: 10px;
        padding-left: 10px;
    }

    .documents-table th {
        font-size: 0.78rem;
    }

    .document-row td {
        font-size: 0.875rem;
    }
}

@media (max-width: 520px) {
    .container {
        width: min(100% - 20px, 1100px);
    }

    .documents-table th,
    .document-row td {
        padding-right: 6px;
        padding-left: 6px;
    }

    .documents-table th {
        font-size: 0.68rem;
    }

    .document-row td {
        font-size: 0.78rem;
    }

    .document-actions-row td {
        padding: 10px 8px 16px;
    }

    .document-actions {
        gap: 8px;
    }

    .document-actions .inline-form {
        flex: 1 1 140px;
    }

    .document-actions button {
        width: 100%;
    }
}
