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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

main {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-height: 600px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 30px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.section-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #2d3748;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #edf2f7;
    transform: translateY(-1px);
}

.loading {
    text-align: center;
    padding: 60px 30px;
    font-size: 16px;
    color: #718096;
}

.error {
    background: #fed7d7;
    color: #c53030;
    padding: 16px 30px;
    margin: 20px 30px;
    border-radius: 8px;
    border-left: 4px solid #fc8181;
}

.hidden {
    display: none;
}

.contracts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    padding: 30px;
}

.contract-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    transition: all 0.2s ease;
}

.contract-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e0;
}

.contract-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.contract-index {
    font-weight: 600;
    color: #4a5568;
    font-size: 14px;
}

.contract-status {
    background: #c6f6d5;
    color: #276749;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.contract-address {
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

.contract-address strong {
    display: block;
    margin-bottom: 8px;
    color: #2d3748;
}

.contract-address code {
    background: #edf2f7;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    word-break: break-all;
    display: block;
    border: 1px solid #e2e8f0;
}

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

.no-contracts {
    text-align: center;
    padding: 60px 30px;
    font-size: 16px;
    color: #718096;
}

.details-card {
    padding: 30px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.detail-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-item label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 12px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item code {
    background: #edf2f7;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    word-break: break-all;
    display: block;
    border: 1px solid #e2e8f0;
}

.detail-item .address {
    font-weight: 600;
    color: #2d3748;
}

.detail-item a {
    color: #667eea;
    text-decoration: none;
    word-break: break-all;
}

.detail-item a:hover {
    text-decoration: underline;
}

.status {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    text-transform: capitalize;
}

.status.active {
    background: #c6f6d5;
    color: #276749;
}

.status.inactive {
    background: #fed7d7;
    color: #c53030;
}

.metadata {
    background: #2d3748;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

footer {
    text-align: center;
    margin-top: 40px;
    color: rgba(255, 255, 255, 0.8);
}

footer code {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.info-box {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #4299e1;
    padding: 16px;
    border-radius: 6px;
    line-height: 1.5;
}

.info-box p {
    margin-bottom: 8px;
}

.info-box p:last-child {
    margin-bottom: 0;
}

/* View Navigation */
.view-nav {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 0 20px;
}

.nav-btn {
    padding: 12px 20px;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #4a5568;
}

.nav-btn:hover {
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

.nav-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.sync-btn {
    margin-left: auto;
}

/* Table Styles */
.table-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-input {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    min-width: 250px;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.table-container {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 20px;
}

#contracts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#contracts-table th {
    background: #f8fafc;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
}

#contracts-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

#contracts-table tr:hover {
    background: #f8fafc;
}

.address-cell code {
    font-size: 11px;
    background: #edf2f7;
    padding: 4px 6px;
    border-radius: 4px;
    word-break: break-all;
    display: block;
    max-width: 120px;
}

.url-cell {
    max-width: 150px;
}

.url-cell a {
    color: #667eea;
    text-decoration: none;
    word-break: break-all;
    display: block;
    font-size: 12px;
}

.url-cell a:hover {
    text-decoration: underline;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: capitalize;
}

.status-active {
    background: #c6f6d5;
    color: #276749;
}

.status-expired {
    background: #fed7d7;
    color: #c53030;
}

.status-inactive {
    background: #e2e8f0;
    color: #718096;
}

.number-cell {
    text-align: center;
    font-weight: 500;
}

.date-cell {
    font-size: 11px;
    color: #718096;
    min-width: 120px;
}

.no-data {
    text-align: center;
    color: #718096;
    font-style: italic;
    padding: 40px;
}

/* Stats Bar */
.stats-bar {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.stats-content {
    font-size: 14px;
    color: #4a5568;
}

.stat-item {
    font-weight: 500;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .contracts-grid {
        grid-template-columns: 1fr;
        padding: 20px;
        gap: 15px;
    }

    .details-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .details-card {
        padding: 20px;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

/* Ensure modal is hidden by default */
.modal-overlay.hidden {
    display: none !important;
}

.modal {
    background: white;
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-content {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.modal-content .detail-item {
    margin-bottom: 16px;
}

.modal-content .details-grid {
    gap: 16px;
}

/* Make address cells clickable in table */
.address-cell code {
    cursor: pointer;
    transition: all 0.2s;
}

.address-cell code:hover {
    background: #667eea;
    color: white;
    transform: scale(1.02);
}

/* Documentation Styles */
.docs-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.docs-container h1,
.docs-container h2,
.docs-container h3 {
    color: #2d3748;
    margin-top: 2em;
    margin-bottom: 0.5em;
}

.docs-container h1 {
    font-size: 2.5em;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-top: 0;
}

.docs-container h2 {
    font-size: 1.8em;
    border-bottom: 3px solid #667eea;
    padding-bottom: 0.3em;
}

.docs-container h3 {
    font-size: 1.4em;
    color: #667eea;
}

.docs-container p {
    line-height: 1.6;
    margin-bottom: 1em;
    color: #4a5568;
}

.docs-container ul,
.docs-container ol {
    line-height: 1.6;
    margin-bottom: 1em;
    padding-left: 2em;
    color: #4a5568;
}

.docs-container li {
    margin-bottom: 0.5em;
}

.docs-container code {
    background: #f7fafc;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    border: 1px solid #e2e8f0;
}

.docs-container pre {
    background: #1a1e3a;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
    border-left: 4px solid #667eea;
}

.docs-container pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
}

.docs-container .diagram {
    background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin: 2em 0;
    text-align: center;
    position: relative;
}

.docs-container .diagram::before {
    content: "📊";
    position: absolute;
    top: -12px;
    left: 20px;
    background: white;
    padding: 0 8px;
    font-size: 20px;
}

.docs-container .diagram-title {
    font-weight: bold;
    font-size: 1.2em;
    color: #2d3748;
    margin-bottom: 15px;
}

.docs-container .flow-chart {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.docs-container .flow-box {
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 15px;
    min-width: 150px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex: 1;
    max-width: 200px;
}

.docs-container .flow-arrow {
    font-size: 24px;
    color: #667eea;
    font-weight: bold;
}

.docs-container .api-endpoint {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 0.5em 0;
    font-family: monospace;
    color: #2f855a;
}

.docs-container .warning {
    background: #fef5e7;
    border: 1px solid #f6d55c;
    border-left: 4px solid #f6d55c;
    border-radius: 6px;
    padding: 15px;
    margin: 1em 0;
}

.docs-container .info {
    background: #e3f2fd;
    border: 1px solid #64b5f6;
    border-left: 4px solid #64b5f6;
    border-radius: 6px;
    padding: 15px;
    margin: 1em 0;
}

.docs-container .success {
    background: #e8f5e8;
    border: 1px solid #4caf50;
    border-left: 4px solid #4caf50;
    border-radius: 6px;
    padding: 15px;
    margin: 1em 0;
}

@media (max-width: 768px) {
    .docs-container {
        padding: 15px;
    }

    .docs-container .flow-chart {
        flex-direction: column;
    }

    .docs-container .flow-arrow {
        transform: rotate(90deg);
    }
}