/* ============================================
   Base Sync - Modern Design System
   ============================================ */

:root {
    /* Primary Colors */
    --primary: #3370ff;
    --primary-dark: #2860e0;
    --primary-light: #e8f0ff;
    --primary-hover: #2455cc;

    /* Semantic Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    /* Neutral Colors */
    --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;

    /* Background & Surface */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f9fafb;
    --surface-elevated: #ffffff;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-tertiary: #6b7280;
    --text-disabled: #9ca3af;

    /* Border */
    --border-light: #e5e7eb;
    --border: #d1d5db;
    --border-focus: #3370ff;

    /* Shadow */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Typography */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Spacing */
    --header-height: 72px;
}

/* ============================================
   Neo Brutalist Refresh
   ============================================ */

:root {
    --ink: #111111;
    --paper: #fffdf3;
    --acid: #1f2937;
    --blue: #3b82f6;
    --pink: #ff4fa3;
    --orange: #ff9f1c;
    --green: #18c964;
    --red: #ff3b30;
    --muted: #f1efe3;
    --surface: #ffffff;
    --bg: var(--paper);
    --text-primary: var(--ink);
    --text-secondary: #2f2f2f;
    --text-tertiary: #5e5e5e;
    --border: var(--ink);
    --border-light: var(--ink);
    --primary: var(--acid);
    --primary-hover: #c7ef1e;
    --primary-light: #f0ff8a;
    --danger: var(--red);
    --success: var(--green);
    --warning: var(--orange);
    --shadow-hard: 4px 4px 0 var(--ink);
    --shadow-hard-sm: 2px 2px 0 var(--ink);
    --radius: 8px;
}

body {
    background:
        linear-gradient(90deg, rgba(17, 17, 17, 0.045) 1px, transparent 1px),
        linear-gradient(rgba(17, 17, 17, 0.045) 1px, transparent 1px),
        var(--paper);
    background-size: 28px 28px;
    color: var(--ink);
}

.top-nav {
    background: var(--surface);
    border-bottom: 3px solid var(--ink);
    box-shadow: 0 3px 0 var(--ink);
}

.logo-icon svg rect {
    fill: var(--acid);
    stroke: var(--ink);
    stroke-width: 2px;
}

.logo-icon svg path {
    stroke: var(--ink);
}

.logo-text {
    color: var(--ink);
    letter-spacing: 0;
}

.nav-link {
    border: 2px solid transparent;
    border-radius: var(--radius);
    color: var(--ink);
}

.nav-link:hover {
    background: var(--muted);
    border-color: var(--ink);
}

.nav-link.active {
    background: var(--acid);
    border-color: var(--ink);
    box-shadow: var(--shadow-hard-sm);
    color: var(--ink);
}

.page-header {
    background: var(--surface);
    border: 3px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
    padding: 24px;
}

.page-header h1 {
    letter-spacing: 0;
}

.btn {
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard-sm);
    color: var(--ink);
    transform: none;
}

.btn:hover:not(:disabled) {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--ink);
}

.btn:active:not(:disabled) {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 var(--ink);
}

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

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

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
}

.btn-danger {
    background: var(--red);
    color: #ffffff;
}

.task-card,
.settings-card,
.log-item,
.modal-content {
    background: var(--surface);
    border: 3px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
}

.task-card {
    position: relative;
    overflow: visible;
}

.task-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 10px;
    background: var(--muted);
    border-right: 3px solid var(--ink);
    border-radius: 5px 0 0 5px;
}

.task-card.running::before {
    background: var(--blue);
}

.task-card:has(.task-status-badge.success)::before {
    background: var(--green);
}

.task-card:has(.task-status-badge.failed)::before {
    background: var(--red);
}

.task-info-section {
    padding-left: 18px;
}

.task-id,
.task-status-badge,
.view-tag,
.config-item,
.log-status-badge,
.logs-count {
    border: 2px solid var(--ink);
    border-radius: 999px;
    box-shadow: var(--shadow-hard-sm);
}

.task-id {
    background: var(--ink);
    color: #ffffff;
}

.task-status-badge {
    background: var(--muted);
    color: var(--ink);
}

.task-status-badge.success,
.log-status-badge.success,
.log-status.success {
    background: var(--green);
    color: var(--ink);
}

.task-status-badge.failed,
.log-status-badge.failed,
.log-status.failed {
    background: var(--red);
    color: #ffffff;
}

.task-status-badge.running,
.log-status-badge.running,
.log-status.running {
    background: var(--blue);
    color: #ffffff;
}

.log-status-badge.partial,
.log-status.partial {
    background: var(--orange);
    color: var(--ink);
}

.task-name {
    letter-spacing: 0;
}

.table-info {
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-hard-sm);
}

.table-info.source .table-label {
    background: var(--blue);
    color: #ffffff;
}

.table-info.target .table-label {
    background: var(--pink);
    color: #ffffff;
}

.table-label {
    display: inline-flex;
    border: 2px solid var(--ink);
    border-radius: 999px;
    padding: 4px 10px;
}

.table-arrow,
.log-flow-arrow {
    border: 2px solid var(--ink);
    background: var(--acid);
    color: var(--ink);
    box-shadow: var(--shadow-hard-sm);
}

.config-item {
    background: var(--muted);
    padding: 10px 12px;
}

.task-logs-section {
    border-left: 3px solid var(--ink);
    background: #fff8d7;
}

.log-entry,
.log-entry-realtime {
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-hard-sm);
}

.progress-bar {
    border: 3px solid var(--ink);
    border-radius: var(--radius);
    background: var(--surface);
}

.progress-fill {
    background: var(--acid);
}

.form-input,
.form-select,
.form-textarea {
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard-sm);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: 3px solid var(--acid);
    border-color: var(--ink);
}

@media (max-width: 768px) {
    .top-nav {
        height: auto;
        min-height: var(--header-height);
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px 16px;
    }

    .nav-menu {
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
    }

    .page {
        padding: 18px;
    }

.task-logs-section {
        border-left: 0;
        border-top: 3px solid var(--ink);
    }
}

/* ============================================
   Simplified task cards
   ============================================ */

.task-card,
.task-card:hover {
    border: 2px solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    background: var(--surface);
}

.task-info-section {
    padding: 22px 24px;
    border-right: 1px solid var(--border-light);
}

.task-header {
    margin-bottom: 16px;
}

.task-title-row {
    margin-bottom: 8px;
}

.task-id,
.task-status-badge {
    box-shadow: none;
    border: 1px solid var(--ink);
}

.task-status-badge.never {
    background: var(--muted);
    color: var(--ink);
}

.task-detail-list {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.task-detail-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 12px;
    align-items: baseline;
}

.detail-label {
    font-size: 12px;
    color: var(--text-tertiary);
}

.detail-value {
    min-width: 0;
    font-size: 13px;
    color: var(--text-secondary);
    overflow: visible;
    text-overflow: initial;
    white-space: normal;
    word-break: break-word;
}

a.detail-value:hover {
    color: var(--ink);
    text-decoration: underline;
}

.task-tables,
.task-config,
.table-info,
.table-link,
.table-arrow,
.view-tag,
.config-item {
    box-shadow: none;
}

.task-logs-section {
    background: #fffdf3;
    border-left: 1px solid var(--border-light);
}

.logs-count,
.log-entry,
.log-entry-realtime {
    box-shadow: none;
    border: 1px solid var(--border-light);
}

.log-entry,
.log-entry-realtime {
    background: #ffffff;
}

@media (max-width: 1024px) {
    .task-card {
        grid-template-columns: 1fr;
    }

    .task-info-section {
        border-right: 0;
    }

    .task-logs-section {
        border-left: 0;
        border-top: 1px solid var(--border-light);
    }
}

/* ============================================
   Minimal cleanup overrides
   ============================================ */

.page-header {
    display: none;
}

.page {
    padding-top: 24px;
}

.nav-brand {
    color: inherit;
}

.task-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
}

.task-id,
.task-status-badge,
.logs-count {
    border: 0;
    box-shadow: none;
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.task-id {
    color: var(--text-tertiary);
}

.task-status-badge {
    color: var(--text-secondary);
}

.task-status-badge.success,
.task-status-badge.failed,
.task-status-badge.running,
.task-status-badge.never {
    background: transparent;
    color: var(--text-secondary);
}

.logs-count {
    font-size: 12px;
    color: var(--text-tertiary);
}

.task-card,
.task-card:hover {
    border: 1px solid var(--border-light);
    box-shadow: none;
}

.task-logs-section {
    background: #fafafa;
}

/* ============================================
   Final dark + plain overrides
   ============================================ */

:root {
    --ink: #0f172a;
    --paper: #f6f7f9;
    --surface: #ffffff;
    --muted: #eef1f5;
    --acid: #1f2937;
    --primary: #1f2937;
    --primary-hover: #111827;
    --primary-light: #e5e7eb;
    --blue: #1e3a8a;
    --pink: #7f1d1d;
    --orange: #92400e;
    --green: #166534;
    --red: #991b1b;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --border-light: #d7dce3;
    --border: #c6ccd5;
}

body {
    background: var(--paper) !important;
    color: var(--text-primary);
}

.top-nav {
    border-bottom: 1px solid var(--border-light) !important;
    box-shadow: none !important;
}

.logo-icon svg rect {
    fill: #1f2937 !important;
    stroke: #1f2937 !important;
}

.logo-icon svg path {
    stroke: #ffffff !important;
}

.btn,
.btn-primary,
.btn-secondary,
.btn-danger {
    box-shadow: none !important;
    border: 1px solid var(--border) !important;
}

.btn-primary {
    background: #1f2937 !important;
    color: #ffffff !important;
}

.btn-secondary {
    background: #ffffff !important;
    color: var(--text-secondary) !important;
}

.btn-danger {
    background: #7f1d1d !important;
    color: #ffffff !important;
}

.nav-link.active {
    background: #1f2937 !important;
    color: #ffffff !important;
    border: 0 !important;
    box-shadow: none !important;
}

.task-card,
.task-card:hover,
.settings-card,
.log-item,
.modal-content,
.empty-state {
    border: 1px solid var(--border-light) !important;
    box-shadow: none !important;
}

.task-title-row {
    display: block !important;
    margin-bottom: 8px !important;
    color: var(--text-tertiary) !important;
    font-size: 12px !important;
}

.task-id,
.task-status-badge,
.task-status-badge.success,
.task-status-badge.failed,
.task-status-badge.running,
.task-status-badge.never {
    display: inline !important;
    margin-right: 10px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--text-tertiary) !important;
    font-weight: 500 !important;
}

.status-icon {
    display: none !important;
}

.logs-count,
.log-status-badge,
.log-entry,
.log-entry-realtime {
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.logs-count {
    color: var(--text-tertiary) !important;
}

.task-logs-section {
    background: #f8fafc !important;
    border-left: 1px solid var(--border-light) !important;
}

.log-entry-realtime {
    padding: 4px 0 !important;
    border-bottom: 1px solid #edf0f4 !important;
}

.log-entry-realtime.error .log-entry-message {
    color: #991b1b !important;
    font-weight: 600;
}

.log-entry-realtime.success .log-entry-message {
    color: #166534 !important;
}

.progress-fill {
    background: #1f2937 !important;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ============================================
   Layout
   ============================================ */

.app {
    min-height: 100vh;
}

/* Top Navigation */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.auth-status {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

/* Main Content */
.main-content {
    padding-top: var(--header-height);
    min-height: 100vh;
}

.page {
    display: none;
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.page.active {
    display: block;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.page-desc {
    font-size: 16px;
    color: var(--text-tertiary);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--border);
    color: var(--text-primary);
}

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
}

/* ============================================
   Task Cards - Two Column Layout
   ============================================ */

.task-list {
    display: grid;
    gap: 24px;
}

.task-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: all 0.2s;
    display: grid;
    grid-template-columns: 1fr 360px;
    overflow: hidden;
}

.task-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border);
}

.task-card.running {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Left Section - Task Info */
.task-info-section {
    padding: 24px;
    border-right: 1px solid var(--border-light);
}

.task-header {
    margin-bottom: 20px;
}

.task-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.task-id {
    font-size: 12px;
    font-family: 'SF Mono', monospace;
    color: var(--text-tertiary);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.task-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.task-status-badge.success {
    background: var(--success-light);
    color: var(--success);
}

.task-status-badge.failed {
    background: var(--danger-light);
    color: var(--danger);
}

.task-status-badge.never {
    background: var(--gray-100);
    color: var(--text-tertiary);
}

.status-icon {
    font-size: 10px;
}

.task-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.task-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* Task Tables */
.task-tables {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--surface) 100%);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    margin-bottom: 20px;
}

.table-info {
    flex: 1;
    min-width: 0;
}

.table-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.table-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.table-dot.source-dot {
    background: var(--primary);
}

.table-dot.target-dot {
    background: var(--success);
}

.table-link {
    display: block;
    padding: 10px 12px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    transition: all 0.2s;
}

.table-link:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.table-base {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.view-tag {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

.table-arrow {
    flex-shrink: 0;
    font-size: 20px;
    color: var(--primary);
    margin-top: 20px;
}

/* Task Config */
.task-config {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.config-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.config-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Task Times */
.task-times {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    padding: 12px 0;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.time-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.time-label {
    font-size: 11px;
    color: var(--text-tertiary);
}

.time-value {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Task Actions */
.task-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.sync-warning {
    width: 100%;
    margin: 8px 0 0 0;
    font-size: 12px;
    color: var(--danger);
    font-weight: 500;
}

/* Right Section - Logs */
.task-logs-section {
    padding: 20px;
    background: linear-gradient(180deg, var(--gray-50) 0%, var(--surface) 100%);
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.logs-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.logs-count {
    font-size: 12px;
    color: var(--text-tertiary);
}

.logs-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.logs-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 13px;
}

.log-entry {
    padding: 12px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    transition: all 0.2s;
}

.log-entry:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.log-entry.success {
    border-left: 3px solid var(--success);
}

.log-entry.failed {
    border-left: 3px solid var(--danger);
}

.log-entry.running {
    border-left: 3px solid var(--primary);
}

.log-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.log-status {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.log-status.success {
    background: var(--success-light);
    color: var(--success);
}

.log-status.failed {
    background: var(--danger-light);
    color: var(--danger);
}

.log-status.running {
    background: var(--primary-light);
    color: var(--primary);
}

.log-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
}

.log-stats span {
    color: var(--text-secondary);
}

.stat-created {
    color: var(--success) !important;
    font-weight: 600;
}

.stat-updated {
    color: var(--primary) !important;
    font-weight: 600;
}

.stat-failed {
    color: var(--danger) !important;
    font-weight: 600;
}

/* Real-time Log Entries */
.log-entry-realtime {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border-light);
    animation: slideIn 0.3s ease;
}

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

.log-entry-realtime.info {
    border-left: 3px solid var(--info);
}

.log-entry-realtime.success {
    border-left: 3px solid var(--success);
}

.log-entry-realtime.warning {
    border-left: 3px solid var(--warning);
}

.log-entry-realtime.error {
    border-left: 3px solid var(--danger);
}

.log-entry-time {
    font-family: 'SF Mono', monospace;
    font-size: 11px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.log-entry-message {
    color: var(--text-primary);
    flex: 1;
}

/* Responsive */
@media (max-width: 1024px) {
    .task-card {
        grid-template-columns: 1fr;
    }

    .task-info-section {
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }

    .task-logs-section {
        min-height: 200px;
    }
}

/* ============================================
   Modal
   ============================================ */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: modal-in 0.2s ease;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 0;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.btn-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--gray-100);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 0 24px 24px;
}

/* ============================================
   Sync Progress
   ============================================ */

.sync-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--gray-200);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, #60a5fa 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 6px;
}

.progress-percent {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.progress-info {
    text-align: center;
}

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

.progress-detail {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: var(--primary-light);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 15px;
    color: var(--text-tertiary);
    margin-bottom: 24px;
}

/* ============================================
   Logs
   ============================================ */

.log-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 900px;
}

.log-item {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    border: 1px solid var(--border-light);
    transition: all 0.2s;
}

.log-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--border);
}

.log-item.success {
    border-left: 3px solid var(--success);
}

.log-item.failed {
    border-left: 3px solid var(--danger);
}

.log-item.running {
    border-left: 3px solid var(--primary);
}

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

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

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

.log-status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.log-status-badge.success {
    background: var(--success-light);
    color: var(--success);
}

.log-status-badge.failed {
    background: var(--danger-light);
    color: var(--danger);
}

.log-status-badge.running {
    background: var(--primary-light);
    color: var(--primary);
}

.log-time {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Log Tables Flow */
.log-tables-flow {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.log-table-item {
    flex: 1;
    min-width: 0;
}

.log-table-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.log-table-base {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-table-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-flow-arrow {
    font-size: 20px;
    color: var(--primary);
    flex-shrink: 0;
}

.log-stats {
    display: flex;
    gap: 20px;
    font-size: 14px;
    flex-wrap: wrap;
}

.log-stat {
    color: var(--text-tertiary);
}

.log-stat strong {
    color: var(--text-primary);
    font-weight: 600;
}

.log-stat.stat-created strong {
    color: var(--success);
}

.log-stat.stat-updated strong {
    color: var(--primary);
}

.log-stat.stat-failed strong {
    color: var(--danger);
}

.log-error {
    margin-top: 12px;
    padding: 12px;
    background: var(--danger-light);
    color: var(--danger);
    font-size: 13px;
    border-radius: var(--radius);
    border-left: 3px solid var(--danger);
}

/* ============================================
   Settings
   ============================================ */

.settings-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-light);
    max-width: 800px;
    margin-bottom: 24px;
}

.settings-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.settings-desc {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-bottom: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
}

.setting-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.setting-item:first-child {
    padding-top: 0;
}

.setting-item label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.setting-value {
    display: flex;
    align-items: center;
    gap: 12px;
}

.setting-value code {
    font-family: 'SF Mono', monospace;
    font-size: 13px;
    background: var(--gray-100);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--success-light);
    color: var(--success);
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
}

/* Form styles for settings */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-textarea {
    padding: 10px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: 'SF Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.form-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .top-nav {
        padding: 0 16px;
    }

    .nav-menu {
        display: none;
    }

    .page {
        padding: 20px;
    }

    .task-flow {
        flex-direction: column;
        text-align: center;
    }

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

    .task-actions {
        flex-wrap: wrap;
    }

    .task-footer {
        flex-direction: column;
        gap: 8px;
    }
}

/* ============================================
   Neo Brutalist Final Overrides
   Keep this block at the end of the file.
   ============================================ */

body {
    background:
        linear-gradient(90deg, rgba(17, 17, 17, 0.045) 1px, transparent 1px),
        linear-gradient(rgba(17, 17, 17, 0.045) 1px, transparent 1px),
        var(--paper);
    background-size: 28px 28px;
}

.top-nav {
    background: var(--surface);
    border-bottom: 3px solid var(--ink);
    box-shadow: 0 3px 0 var(--ink);
}

.page-header,
.task-card,
.settings-card,
.log-item,
.modal-content,
.empty-state {
    border: 3px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
    background: var(--surface);
}

.btn,
.nav-link.active,
.task-id,
.task-status-badge,
.view-tag,
.config-item,
.log-status-badge,
.logs-count,
.table-info,
.log-entry,
.log-entry-realtime {
    border: 2px solid var(--ink);
    box-shadow: var(--shadow-hard-sm);
}

.btn {
    border-radius: var(--radius);
}

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

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
}

.btn-danger {
    background: var(--red);
    color: #ffffff;
}

.nav-link.active {
    background: var(--acid);
    color: var(--ink);
}

.task-card {
    overflow: hidden;
}

.task-card.running {
    outline: 3px solid var(--blue);
}

.task-status-badge.success,
.log-status-badge.success,
.log-status.success {
    background: var(--green);
    color: var(--ink);
}

.task-status-badge.failed,
.log-status-badge.failed,
.log-status.failed {
    background: var(--red);
    color: #ffffff;
}

.task-status-badge.running,
.log-status-badge.running,
.log-status.running {
    background: var(--blue);
    color: #ffffff;
}

.log-status-badge.partial,
.log-status.partial {
    background: var(--orange);
    color: var(--ink);
}

.table-info.source {
    border-left: 10px solid var(--blue);
}

.table-info.target {
    border-left: 10px solid var(--pink);
}

.table-arrow,
.log-flow-arrow {
    border: 2px solid var(--ink);
    background: var(--acid);
    color: var(--ink);
    box-shadow: var(--shadow-hard-sm);
}

.task-logs-section {
    background: #fff8d7;
    border-left: 3px solid var(--ink);
}

.progress-bar {
    border: 3px solid var(--ink);
    background: var(--surface);
}

.progress-fill {
    background: var(--acid);
}

.form-input,
.form-select,
.form-textarea {
    border: 2px solid var(--ink);
    box-shadow: var(--shadow-hard-sm);
}

.badge {
    border: 2px solid var(--ink);
    background: var(--green);
    color: var(--ink);
    box-shadow: var(--shadow-hard-sm);
}

@media (max-width: 768px) {
    .top-nav {
        height: auto;
        min-height: var(--header-height);
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px 16px;
    }

    .nav-menu {
        display: flex;
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
    }

    .task-logs-section {
        border-left: 0;
        border-top: 3px solid var(--ink);
    }
}

/* Final overrides: keep below all earlier theme blocks. */
:root {
    --acid: #1f2937;
    --primary: #1f2937;
    --primary-hover: #111827;
    --primary-light: #e5e7eb;
    --ink: #0f172a;
    --paper: #f6f7f9;
    --surface: #ffffff;
    --muted: #eef1f5;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --border-light: #d7dce3;
    --border: #c6ccd5;
}

body { background: var(--paper) !important; }
.page-header { display: none !important; }
.top-nav { border-bottom: 1px solid var(--border-light) !important; box-shadow: none !important; }
.logo-icon svg rect { fill: #1f2937 !important; stroke: #1f2937 !important; }
.logo-icon svg path { stroke: #ffffff !important; }
.btn { box-shadow: none !important; border: 1px solid var(--border) !important; }
.btn-primary { background: #1f2937 !important; color: #ffffff !important; }
.btn-secondary { background: #ffffff !important; color: var(--text-secondary) !important; }
.btn-danger { background: #7f1d1d !important; color: #ffffff !important; }
.nav-link.active { background: #1f2937 !important; color: #ffffff !important; border: 0 !important; box-shadow: none !important; }
.task-card, .task-card:hover, .settings-card, .log-item, .modal-content, .empty-state { border: 1px solid var(--border-light) !important; box-shadow: none !important; }
.task-title-row { display: block !important; margin-bottom: 8px !important; padding: 0 !important; border: 0 !important; box-shadow: none !important; background: transparent !important; color: var(--text-tertiary) !important; font-size: 12px !important; }
.task-id, .task-status-badge, .task-status-badge.success, .task-status-badge.failed, .task-status-badge.running, .task-status-badge.never { display: inline !important; margin-right: 10px !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; color: var(--text-tertiary) !important; font-weight: 500 !important; }
.status-icon { display: none !important; }
.logs-count, .log-status-badge, .log-entry, .log-entry-realtime { border: 0 !important; box-shadow: none !important; background: transparent !important; }
.logs-count { color: var(--text-tertiary) !important; }
.task-logs-section { background: #f8fafc !important; border-left: 1px solid var(--border-light) !important; }
.log-entry-realtime { padding: 4px 0 !important; border-bottom: 1px solid #edf0f4 !important; }
.log-entry-realtime.error .log-entry-message { color: #991b1b !important; font-weight: 600; }
.log-entry-realtime.success .log-entry-message { color: #166534 !important; }
.progress-fill { background: #1f2937 !important; }

.task-card {
    height: auto !important;
    min-height: 0 !important;
}

.task-info-section {
    min-height: 0 !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
}

.task-header {
    flex: 0 0 auto !important;
}

.task-detail-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: visible !important;
    padding-right: 0 !important;
}

.task-times {
    flex: 0 0 auto !important;
    margin: 10px 0 !important;
}

.task-actions {
    flex: 0 0 auto !important;
    padding-top: 10px !important;
    border-top: 1px solid var(--border-light) !important;
    background: var(--surface) !important;
}

.task-logs-section {
    min-height: 0 !important;
    overflow: hidden !important;
}

.logs-list {
    min-height: 0 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    padding-right: 4px;
}

@media (max-width: 768px) {
    .task-card {
        height: auto !important;
        min-height: 0 !important;
    }

    .task-info-section {
        overflow: visible !important;
    }

    .task-logs-section {
        min-height: 240px !important;
    }
}
