:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --bg-hover: #242424;
    --bg-input: #0f0f0f;
    
    --text-primary: #e4e4e4;
    --text-secondary: #999;
    --text-muted: #666;
    
    --border: #2a2a2a;
    --border-focus: #444;
    
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f97316;
    
    --radius: 6px;
    --shadow: 0 0 20px rgba(0,0,0,0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

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

/* header */
.header {
    background: var(--bg-card);
    padding: 16px 24px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
}

.header-user {
    font-weight: 500;
    color: var(--text-primary);
}

/* cards */
.card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* forms */
input, textarea, select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--border-focus);
}

textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

/* buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

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

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

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* grid */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

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

/* contract list */
.contract-item {
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.contract-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-focus);
}

.contract-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.contract-parties {
    font-weight: 500;
    color: var(--text-primary);
}

.contract-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* status badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-draft {
    background: rgba(249, 115, 22, 0.2);
    color: var(--warning);
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge-active {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-completed {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent);
    border: 1px solid rgba(59, 130, 246, 0.3);
}
/* result badges */
.result-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}

.result-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.result-fail {
    background: rgba(244, 63, 94, 0.15);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, 0.25);
}

.result-terminated {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(236, 72, 153, 0.15));
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); }
    50% { box-shadow: 0 0 12px 2px rgba(168, 85, 247, 0.3); }
}

.result-mixed {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15) 50%, rgba(244, 63, 94, 0.15) 50%);
    color: var(--text-secondary);
    border: 1px solid var(--border-focus);
}

/* contract completion indicators */
.contract-item.completed {
    position: relative;
    overflow: hidden;
}

.contract-item.completed::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
}

.contract-item.completed.success::before {
    background: #10b981;
}

.contract-item.completed.fail::before {
    background: #f43f5e;
}

.contract-item.completed.terminated::before {
    background: linear-gradient(180deg, #a855f7, #ec4899);
}

.contract-item.completed.mixed::before {
    background: linear-gradient(180deg, #10b981 50%, #f43f5e 50%);
}

/* conditions */
.conditions-box {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.conditions-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.conditions-text {
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* comments */
.comments-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.comment {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.comment-author {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.comment-text {
    color: var(--text-primary);
}

.comment-input-group {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.comment-input-group input {
    flex: 1;
}

/* agreement indicators */
.agreement-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.agreement-status.agreed {
    color: var(--success);
}

/* utilities */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

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

.text-small {
    font-size: 12px;
}

/* animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* login page specific */
.auth-container {
    max-width: 400px;
    margin: 100px auto;
}

.auth-card {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.auth-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 24px;
    text-align: center;
}

.form-group {
    margin-bottom: 16px;
}

.result-box {
    margin-top: 16px;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 13px;
    word-break: break-all;
    font-family: 'SF Mono', monospace;
}

.result-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.result-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

/* modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.2s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 10;
}

.modal-body {
    padding: 24px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* collapsible form */
.collapsible {
    margin-bottom: 20px;
}

.collapsible-trigger {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.collapsible-trigger:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.collapsible-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.collapsible.active .collapsible-content {
    display: block;
}

.collapsible.active .collapsible-trigger {
    display: none;
}

/* filters bar */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.filter-chip:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.filter-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* search box */
.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box input {
    padding-left: 36px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* responsive */
@media (max-width: 640px) {
    .modal-content {
        max-width: 100%;
        margin: 10px;
    }
    
    .filters-bar {
        flex-direction: column;
    }
    
    .search-box {
        width: 100%;
    }
}

/* history timeline */
.history-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.history-timeline {
    position: relative;
    padding-left: 24px;
}

.history-timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border);
}

.history-item {
    position: relative;
    padding-bottom: 20px;
}

.history-item::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-focus);
}

.history-item.current::before {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.history-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.history-version {
    padding: 2px 6px;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.history-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.history-changes {
    margin-top: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.history-diff {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.history-diff-box {
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    font-size: 13px;
}

.history-diff-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.history-toggle {
    cursor: pointer;
    font-size: 12px;
    color: var(--accent);
    margin-top: 4px;
}

.history-toggle:hover {
    text-decoration: underline;
}

/* tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}