/* toolbar */

.documents-title {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
    color: #111827;
}

.documents-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.documents-search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 280px;
    height: 40px;
    padding: 0 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.documents-search svg {
    width: 16px;
    height: 16px;
    color: #9ca3af;
}

.documents-search input {
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    font-size: 14px;
    color: #111827;
    outline: 0;
}

.documents-search input::placeholder {
    color: #9ca3af;
}

.documents-tabs {
    display: flex;
    gap: 8px;
}

.documents-tabs a {
    display: flex;
    align-items: center;
    height: 40px;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 13px;
}

.documents-tabs a:hover,
.documents-new-button:hover {
    text-decoration: none;
}

.documents-tabs .active {
    background: #fff;
    border: 1.5px solid #249447;
    font-weight: 600;
    color: #249447;
}

.documents-tabs .pending  { background: #fef3c7; color: #d97706; }
.documents-tabs .signed   { background: #d1fae5; color: #059669; }
.documents-tabs .error    { background: #fee2e2; color: #991b1b; }

.documents-tabs .pending.active,
.documents-tabs .signed.active,
.documents-tabs .error.active {
    border: 1.5px solid currentColor;
    font-weight: 600;
}

.documents-filter-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.documents-filter-submit svg {
    width: 16px;
    height: 16px;
}

.documents-toolbar-spacer {
    flex: 1;
}

.documents-new-button {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    background: #249447;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.documents-new-button svg {
    width: 16px;
    height: 16px;
}

/* table */

.documents-card {
    overflow: hidden;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.documents-table-wrap {
    overflow-x: auto;
}

.documents-table {
    width: 100%;
    min-width: 960px;
    border-collapse: collapse;
}

.documents-table th,
.documents-table td {
    padding: 0 24px;
    border-bottom: 1px solid #f3f4f6;
    text-align: left;
}

.documents-table th {
    height: 44px;
    background: #f9fafb;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
}

.documents-table td {
    height: 64px;
    font-size: 13px;
    color: #6b7280;
}

.documents-table th:first-child,
.documents-table td:first-child { width: 34%; }

.documents-table th:nth-child(2),
.documents-table td:nth-child(2) { width: 22%; }

.documents-table th:nth-child(3),
.documents-table td:nth-child(3) { width: 110px; text-align: center; }

.documents-table th:last-child,
.documents-table td:last-child { width: 60px; text-align: center; }

.documents-table td > strong {
    display: block;
    margin-bottom: 2px;
    font-size: 13px;
    font-weight: 500;
    color: #111827;
}

.documents-table td > span {
    display: block;
    font-size: 12px;
    color: #9ca3af;
}

.signer-cell {
    display: flex !important;
    align-items: center;
    gap: 6px;
    font-size: 13px !important;
    color: #374151 !important;
}

.signer-cell em {
    font-size: 12px;
    font-style: normal;
    color: #6b7280;
}

.signer-avatar {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #dbeafe;
    border-radius: 50%;
    font-size: 11px !important;
    font-weight: 600;
    color: #2563eb !important;
}

.documents-muted {
    color: #9ca3af !important;
}

.documents-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 10px;
    white-space: nowrap;
}

.documents-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.documents-badge.pending,
.documents-badge.draft     { background: #fef3c7; color: #d97706; }
.documents-badge.pending::before,
.documents-badge.draft::before { background: #d97706; }

.documents-badge.signed    { background: #d1fae5; color: #059669; }
.documents-badge.signed::before   { background: #249447; }

.documents-badge.error     { background: #fee2e2; color: #991b1b; }
.documents-badge.error::before    { background: #ef4444; }

.documents-action {
    display: inline-flex;
    color: #9ca3af;
}

.documents-action svg {
    width: 18px;
    height: 18px;
}

/* new document */

.new-document-title {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
    color: #111827;
}

.new-document-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    gap: 24px;
}

.new-document-main {
    display: grid;
    gap: 20px;
    min-width: 0;
}

.new-document-card,
.new-document-summary {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.new-document-card {
    display: grid;
    gap: 20px;
    padding: 24px;
}

.new-document-section-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.new-document-section-title span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #249447;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.new-document-section-title h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.new-document-field {
    display: grid;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.new-document-field > input {
    height: 48px;
    padding: 0 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #111827;
}

.new-document-field > input::placeholder,
.signer-row input::placeholder {
    color: #9ca3af;
}

.new-document-field small {
    font-size: 12px;
    font-weight: 400;
    color: #9ca3af;
}

/* upload */

.upload-dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 160px;
    border: 1.5px solid #249447;
    border-radius: 10px;
    text-align: center;
    color: #6b7280;
    cursor: pointer;
}

.upload-dropzone svg {
    width: 32px;
    height: 32px;
    color: #249447;
}

.upload-dropzone strong {
    font-size: 14px;
    font-weight: 400;
    color: #6b7280;
}

.upload-dropzone em {
    font-size: 13px;
    font-style: normal;
    font-weight: 400;
    color: #249447;
}

.upload-dropzone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-dropzone.has-files {
    background: #eaf7ee;
}

.selected-files {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.selected-files li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 400;
    color: #374151;
}

.selected-files button {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: #fff;
    border: 1px solid #ef4444;
    border-radius: 6px;
    color: #991b1b;
}

.selected-files button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.upload-error {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: #991b1b;
}

/* signers */

.signers-table {
    display: grid;
    gap: 8px;
    overflow-x: auto;
}

.signers-header,
.signer-row {
    display: grid;
    align-items: center;
    grid-template-columns: 32px minmax(180px, 1fr) minmax(220px, 1.2fr) minmax(150px, .8fr);
    gap: 10px;
    min-width: 720px;
    padding: 0 12px;
}

.signers-header {
    height: 36px;
    background: #f9fafb;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
}

.signer-row {
    height: 44px;
    margin: 0;
    border: 0;
}

.signer-number {
    font-size: 13px;
    color: #6b7280;
}

.signer-row label {
    display: block;
    font-weight: 400;
}

.signer-row input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    color: #111827;
}

.add-signer-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    color: #249447;
    justify-self: start;
}

.add-signer-button svg {
    width: 16px;
    height: 16px;
}

/* summary */

.new-document-summary {
    position: sticky;
    top: 24px;
    overflow: hidden;
}

.new-document-summary header {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 24px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 0 24px;
    border-bottom: 1px solid #f3f4f6;
}

.summary-item svg {
    width: 20px;
    height: 20px;
    color: #9ca3af;
}

.summary-item div {
    display: grid;
    gap: 2px;
}

.summary-item span {
    font-size: 12px;
    color: #9ca3af;
}

.summary-item strong {
    font-size: 13px;
    font-weight: 500;
    color: #111827;
}

.summary-actions {
    display: grid;
    gap: 10px;
    padding: 16px;
}

.summary-actions button,
.summary-draft {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    padding: 0;
    border-radius: 8px;
    font-size: 14px;
}

.summary-draft {
    background: #fff;
    border: 1.5px solid #249447;
    font-weight: 500;
    color: #249447;
}

.summary-draft:hover {
    text-decoration: none;
}

.summary-actions button {
    background: #249447;
    font-weight: 600;
    color: #fff;
}

.summary-actions button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* detail */

.document-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.plain-detail-header {
    margin: 0;
    padding: 0;
}

.document-detail-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.document-detail-title h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #111827;
}

.detail-badge,
.detail-signer-status {
    display: inline-flex;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.detail-badge.progress,
.detail-signer-status { background: #dbeafe; color: #2563eb; }

.detail-badge.signed   { background: #d1fae5; color: #059669; }
.detail-badge.draft    { background: #fef3c7; color: #d97706; }
.detail-badge.error    { background: #fee2e2; color: #991b1b; }

.document-detail-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 12px;
}

.detail-action:hover {
    text-decoration: none;
}

.detail-action svg {
    width: 15px;
    height: 15px;
}

.secondary-action {
    background: #fff;
    border: 1px solid #e5e7eb;
    font-weight: 400;
    color: #374151;
}

.primary-action {
    background: #249447;
    font-weight: 600;
    color: #fff;
}

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

.detail-stats article {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 88px;
    padding: 0 20px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.detail-stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #eaf7ee;
    border-radius: 8px;
    color: #249447;
}

.detail-stat-icon svg {
    width: 20px;
    height: 20px;
}

.detail-stats div {
    display: grid;
    gap: 4px;
}

.detail-stats span,
.detail-stats em {
    font-size: 12px;
    font-style: normal;
    color: #9ca3af;
}

.detail-stats strong {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    gap: 16px;
}

.detail-main-column,
.detail-side-column {
    display: grid;
    align-items: start;
    gap: 16px;
}

.detail-info-card,
.detail-signers-card,
.detail-actions-card {
    overflow: hidden;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.detail-info-card > header,
.detail-signers-card > header,
.detail-actions-card > header {
    display: flex;
    align-items: center;
    height: 52px;
    padding: 0 20px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.detail-actions-card {
    display: grid;
    gap: 10px;
    padding: 16px;
}

.detail-actions-card > header {
    height: auto;
    padding: 0;
    border-bottom: 0;
}

.detail-actions-card .detail-action {
    width: 100%;
    justify-content: center;
}

.detail-definition-list {
    margin: 0;
}

.detail-definition-list div {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    align-items: center;
    min-height: 44px;
    padding: 0 20px;
    border-bottom: 1px solid #f3f4f6;
}

.detail-definition-list dt {
    font-size: 13px;
    color: #9ca3af;
}

.detail-definition-list dd {
    margin: 0;
    font-size: 13px;
    overflow-wrap: anywhere;
    color: #111827;
}

.detail-file-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 32px;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 0 20px;
    border-bottom: 1px solid #f3f4f6;
}

.detail-file-row > svg {
    width: 18px;
    height: 18px;
    color: #e53935;
}

.detail-file-row div {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.detail-file-row strong {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
    font-weight: 500;
    color: #111827;
}

.detail-file-row span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
    color: #9ca3af;
}

.detail-file-row button {
    padding: 0;
    background: transparent;
    color: #249447;
}

.detail-file-row button svg {
    width: 18px;
    height: 18px;
}

.detail-timeline {
    display: grid;
    gap: 12px;
    padding: 16px 20px 24px;
}

.detail-timeline h2 {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.detail-timeline div {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
}

.detail-timeline div > span {
    width: 10px;
    height: 10px;
    margin-top: 4px;
    background: #249447;
    border-radius: 50%;
}

.detail-timeline p {
    display: grid;
    gap: 2px;
    margin: 0;
}

.detail-timeline strong {
    font-size: 13px;
    font-weight: 500;
    color: #111827;
}

.detail-timeline small {
    font-size: 12px;
    color: #9ca3af;
}

.detail-signers-head {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr) 80px;
    align-items: center;
    min-height: 36px;
    padding: 0 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
    font-weight: 500;
    color: #9ca3af;
}

.detail-signer-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 68px;
    padding: 0 20px;
    border-bottom: 1px solid #f3f4f6;
}

.detail-signer-order {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #eaf7ee;
    border: 1.5px solid #249447;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    color: #249447;
}

.detail-signer-row div {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.detail-signer-row strong {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
    font-weight: 500;
    color: #111827;
}

.detail-signer-row small {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 11px;
    color: #9ca3af;
}

.detail-signer-row a {
    font-size: 11px;
    color: #249447;
}

.detail-signer-status {
    padding: 4px 10px;
    background: #fef3c7;
    color: #d97706;
}

.detail-empty {
    margin: 0;
    padding: 20px;
    font-size: 13px;
    color: #6b7280;
}

/* responsive */

@media (max-width: 980px) {
    .documents-toolbar {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .documents-search {
        flex: 1 1 260px;
    }

    .documents-toolbar-spacer {
        display: none;
    }

    .new-document-form {
        grid-template-columns: 1fr;
    }

    .new-document-summary {
        position: static;
    }

    .document-detail-header,
    .document-detail-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .document-detail-title {
        flex-direction: column;
        align-items: flex-start;
    }

    .detail-action {
        width: 100%;
        justify-content: center;
    }

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

@media (max-width: 760px) {
    .signer-row {
        grid-template-columns: 1fr;
    }

    .documents-toolbar {
        display: grid;
    }

    .documents-search,
    .documents-new-button {
        width: 100%;
    }

    .documents-tabs {
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .new-document-card {
        padding: 20px;
    }

    .upload-dropzone {
        height: 140px;
    }

    .detail-definition-list div {
        grid-template-columns: 1fr;
        align-items: start;
        gap: 4px;
        padding: 12px 20px;
    }

    .detail-signers-head {
        display: none;
    }

    .detail-signer-row {
        grid-template-columns: 32px minmax(0, 1fr) auto;
        padding: 12px 16px;
    }

    .detail-signer-status,
    .detail-signer-row .detail-badge {
        grid-column: 3;
    }
}
