* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.navbar {
    background: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--gray-600);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-100);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-danger {
    background: #dc2626;
    color: white;
    border: none;
}

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

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-secondary:disabled {
    background: var(--gray-100);
    color: var(--gray-400);
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 2rem;
}

.login-card {
    max-width: 400px;
    margin: 4rem auto;
    text-align: center;
}

.logo {
    color: var(--primary);
    margin-bottom: 1rem;
}

.login-card h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--gray-500);
    margin-bottom: 2rem;
}

.login-form {
    text-align: left;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-form .btn {
    width: 100%;
    margin-top: 0.5rem;
}

.upload-section {
    max-width: 600px;
    margin: 2rem auto;
    text-align: center;
}

.upload-section h1 {
    margin-bottom: 0.5rem;
}

.upload-section > p {
    color: var(--gray-500);
    margin-bottom: 2rem;
}

.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: 1rem;
    padding: 3rem 2rem;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    margin-bottom: 1.5rem;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.02);
}

.upload-area.has-file {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.02);
}

.upload-icon {
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.125rem;
    color: var(--gray-700);
    margin-bottom: 0.25rem;
}

.upload-subtext {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.file-name {
    margin-top: 1rem;
    font-weight: 500;
    color: var(--success);
}

.sign-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 64px);
}

.document-viewer {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.document-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.document-header h2 {
    font-size: 1rem;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#pageInfo {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.pdf-container {
    flex: 1;
    overflow: auto;
    padding: 1rem;
    background: var(--gray-100);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.pdf-wrapper {
    position: relative;
    display: inline-block;
}

#pdfPage {
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: block;
}

#fieldOverlays {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.field-overlay {
    position: absolute;
    border: 2px dashed;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-border 2s infinite;
}

.field-overlay-signature {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
}

.field-overlay-text {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.field-overlay-date {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.field-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

.field-overlay-signature .field-label {
    background: #2563eb;
    color: white;
}

.field-overlay-text .field-label {
    background: #10b981;
    color: white;
}

.field-overlay-date .field-label {
    background: #f59e0b;
    color: white;
}

@keyframes pulse-border {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.field-has-value {
    border-style: solid !important;
    border-width: 3px !important;
    border-color: #3b82f6 !important;
    background: rgba(59, 130, 246, 0.15) !important;
    animation: pulse-available 1.5s infinite !important;
    cursor: pointer !important;
}

.field-has-value .field-label {
    background: #3b82f6 !important;
}

.field-has-value::after {
    content: 'Click';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    color: white;
    font-weight: bold;
    background: #3b82f6;
    padding: 1px 4px;
    border-radius: 3px;
}

@keyframes pulse-available {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% { 
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0);
    }
}

.field-filled {
    border-style: solid !important;
    border-color: #10b981 !important;
    background: rgba(16, 185, 129, 0.2) !important;
    animation: none !important;
}

.field-filled .field-label {
    background: #10b981 !important;
    font-size: 11px !important;
    text-transform: none !important;
}

.field-filled::after {
    display: none;
}

.field-overlay.draggable {
    cursor: grab;
    pointer-events: auto;
    user-select: none;
}

.field-overlay.draggable:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.field-overlay.dragging {
    cursor: grabbing;
    opacity: 0.8;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.field-delete {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.field-overlay:hover .field-delete {
    display: flex;
}

.field-delete:hover {
    background: #dc2626;
}

.field-toolbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: white;
    border-top: 1px solid var(--gray-200);
}

.toolbox-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
}

.toolbox-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.toolbox-btn-name {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.toolbox-btn-name:hover {
    background: rgba(16, 185, 129, 0.2);
}

.toolbox-btn-signature {
    background: rgba(37, 99, 235, 0.1);
    color: #1d4ed8;
}

.toolbox-btn-signature:hover {
    background: rgba(37, 99, 235, 0.2);
}

.toolbox-btn-date {
    background: rgba(245, 158, 11, 0.1);
    color: #b45309;
}

.toolbox-btn-date:hover {
    background: rgba(245, 158, 11, 0.2);
}

.toolbox-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.toolbox-btn-ssn {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.toolbox-btn-ssn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.toolbox-btn-phone {
    background: rgba(139, 92, 246, 0.1);
    color: #7c3aed;
}

.toolbox-btn-phone:hover {
    background: rgba(139, 92, 246, 0.2);
}

.toolbox-btn-dob {
    background: rgba(6, 182, 212, 0.1);
    color: #0891b2;
}

.toolbox-btn-dob:hover {
    background: rgba(6, 182, 212, 0.2);
}

.toolbox-btn-address {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.toolbox-btn-address:hover {
    background: rgba(34, 197, 94, 0.2);
}

.toolbox-hint {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--gray-400);
}

.template-save-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
}

.template-save-section hr {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin-bottom: 1rem;
}

.template-save-section h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.template-save-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.template-save-form input {
    flex: 1;
}

.template-save-form .btn {
    white-space: nowrap;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.help-text {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
}

.success-text {
    color: #059669;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.fields-list {
    margin-top: 1rem;
}

.fields-list h4 {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.fields-list-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.fields-list-items li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.875rem;
    color: var(--gray-600);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.template-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s;
}

.template-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.template-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    color: var(--primary);
}

.template-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.125rem;
}

.template-desc {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}

.template-meta {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.template-actions {
    display: flex;
    gap: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-500);
}

.empty-state svg {
    color: var(--gray-300);
    margin-bottom: 1rem;
}

.empty-state h2 {
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

.send-card {
    max-width: 500px;
    margin: 2rem auto;
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.send-card h1 {
    margin: 0 0 0.5rem 0;
}

.template-name {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

.signing-link-box {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.signing-link-box input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.link-note {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.send-multi-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 1000px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .send-multi-container {
        grid-template-columns: 1fr;
    }
}

.template-selection,
.recipient-form-section {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.template-selection h3,
.recipient-form-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1.125rem;
}

.template-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.template-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.template-checkbox-item:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.template-checkbox-item:has(.template-checkbox:checked) {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
}

.template-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary);
}

.template-checkbox-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.template-checkbox-name {
    font-weight: 500;
    color: var(--gray-800);
}

.template-checkbox-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.selected-count {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--gray-50);
    border-radius: 0.5rem;
    text-align: center;
}

.doc-progress {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    text-align: center;
}

.table-container {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.875rem;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-draft {
    background: var(--gray-100);
    color: var(--gray-600);
}

.status-sent {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.status-viewed {
    background: rgba(245, 158, 11, 0.1);
    color: #b45309;
}

.status-completed {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.recipient-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.recipient-name {
    font-weight: 500;
    color: var(--gray-800);
}

.recipient-email {
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.text-muted {
    color: var(--gray-400);
}

.message-card {
    max-width: 500px;
    margin: 4rem auto;
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.message-card h1 {
    margin: 1rem 0 0.5rem 0;
}

.nav-info {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0 0 0.25rem 0;
}

.page-header p {
    color: var(--gray-500);
    margin: 0;
}

.sign-panel {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    overflow-y: auto;
}

.sign-panel h2 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.signature-area {
    border: 2px solid var(--gray-300);
    border-radius: 0.5rem;
    background: var(--gray-50);
    overflow: hidden;
}

#signatureCanvas {
    width: 100%;
    height: 150px;
    display: block;
    cursor: crosshair;
}

.signature-actions {
    margin-top: 0.5rem;
    display: flex;
    justify-content: flex-end;
}

.form-actions {
    margin-top: 1.5rem;
}

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

.success-message {
    text-align: center;
    padding: 2rem 0;
}

.success-message svg {
    color: var(--success);
    margin-bottom: 1rem;
}

.success-message h3 {
    margin-bottom: 0.5rem;
}

.success-message p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

.success-message .btn {
    display: block;
    margin-bottom: 0.75rem;
}

.success-card {
    max-width: 500px;
    margin: 4rem auto;
    text-align: center;
    background: white;
    padding: 3rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.success-icon {
    color: var(--success);
    margin-bottom: 1.5rem;
}

.success-card h1 {
    margin-bottom: 0.75rem;
}

.success-card p {
    color: var(--gray-500);
    margin-bottom: 2rem;
}

.success-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (max-width: 900px) {
    .sign-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .document-viewer {
        height: 400px;
    }
}

.loading {
    opacity: 0.7;
    pointer-events: none;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
