/* ===== DESIGN SYSTEM (match tinbot-update Tailwind palette) ===== */
        :root {
            --slate-50: #f8fafc;
            --slate-100: #f1f5f9;
            --slate-200: #e2e8f0;
            --slate-300: #cbd5e1;
            --slate-400: #94a3b8;
            --slate-500: #64748b;
            --slate-600: #475569;
            --slate-700: #334155;
            --slate-800: #1e293b;
            --slate-900: #0f172a;
            --blue-50: #eff6ff;
            --blue-100: #dbeafe;
            --blue-200: #bfdbfe;
            --blue-500: #3b82f6;
            --blue-600: #2563eb;
            --blue-700: #1d4ed8;
            --emerald-50: #ecfdf5;
            --emerald-200: #a7f3d0;
            --emerald-500: #10b981;
            --emerald-600: #059669;
            --emerald-800: #065f46;
            --red-50: #fef2f2;
            --red-200: #fecaca;
            --red-500: #ef4444;
            --red-600: #dc2626;
            --red-700: #b91c1c;
            --red-800: #991b1b;
            --amber-50: #fffbeb;
            --amber-200: #fde68a;
            --amber-500: #f59e0b;
            --amber-800: #92400e;
            --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
            --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
        }

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

        ::-webkit-scrollbar { width: 8px; height: 8px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 10px; }
        ::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background: var(--slate-50);
            color: var(--slate-900);
        }

        /* ===== LAYOUT (match Layout.tsx) ===== */
        .header {
            height: 64px;
            background: white;
            border-bottom: 1px solid var(--slate-200);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 32px;
            box-shadow: var(--shadow-sm);
        }

        .header h1 {
            font-size: 20px;
            font-weight: 800;
            color: var(--blue-600);
        }

        .header .badge {
            font-size: 13px;
            font-weight: 500;
            color: var(--slate-500);
            background: var(--slate-100);
            padding: 4px 12px;
            border-radius: 20px;
        }

        .main {
            padding: 32px;
            max-width: 100%;
        }

        /* ===== TABLE SECTION (match MasterSources.tsx) ===== */
        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            margin-bottom: 24px;
        }

        .section-header h2 {
            font-size: 24px;
            font-weight: 700;
            color: var(--slate-800);
            letter-spacing: -0.025em;
        }

        .section-header p {
            font-size: 14px;
            color: var(--slate-500);
            margin-top: 4px;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 10px 20px;
            border-radius: 12px;
            font-weight: 700;
            font-size: 14px;
            cursor: pointer;
            border: 1px solid transparent;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .btn:active {
            transform: scale(0.97);
        }

        .btn-primary {
            background: linear-gradient(180deg, var(--blue-500) 0%, var(--blue-600) 100%);
            color: white;
            box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.1);
            border: 1px solid rgba(0,0,0,0.1);
        }

        .btn-primary:hover {
            background: linear-gradient(180deg, var(--blue-600) 0%, var(--blue-700) 100%);
            box-shadow: 0 4px 12px rgba(37,99,235,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
            transform: translateY(-1px);
        }

        .btn-danger {
            background: var(--red-600);
            color: white;
            box-shadow: 0 4px 14px -3px rgba(239, 68, 68, 0.4);
        }

        .btn-danger:hover {
            background: var(--red-700);
        }

        .btn-ghost {
            background: transparent;
            color: var(--slate-500);
            padding: 6px;
            border-radius: 8px;
        }

        .btn-ghost:hover {
            background: var(--slate-100);
            color: var(--blue-600);
        }

        .btn-cancel {
            background: transparent;
            color: var(--slate-500);
            font-weight: 700;
            padding: 10px 24px;
            border-radius: 12px;
        }

        .btn-cancel:hover {
            background: var(--slate-100);
        }

        .btn-sync {
            min-width: 136px;
            height: 36px;
            position: relative;
            overflow: hidden;
        }

        .btn-sync.processing {
            background: var(--blue-50);
            color: var(--blue-600);
            border: 1px solid var(--blue-200);
            cursor: default;
        }

        .btn-sync.processing .progress-bar {
            position: absolute;
            inset: 0;
            background: rgba(147, 197, 253, 0.3);
            animation: video-buffer 2s infinite ease-in-out;
        }

        @keyframes video-buffer {
            0% {
                transform: scaleX(0);
                transform-origin: left;
            }

            50% {
                transform: scaleX(1);
                transform-origin: left;
            }

            50.1% {
                transform: scaleX(1);
                transform-origin: right;
            }

            100% {
                transform: scaleX(0);
                transform-origin: right;
            }
        }

        .btn-stop {
            height: 36px;
            padding: 0 12px;
            border-radius: 8px;
            background: var(--red-50);
            color: var(--red-600);
            border: 1px solid var(--red-200);
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.15s;
        }

        .btn-stop:hover {
            background: rgba(254, 202, 202, 0.5);
        }

        .table-wrap {
            background: white;
            border-radius: 12px;
            box-shadow: var(--shadow-sm);
            border: 1px solid var(--slate-200);
            overflow: hidden;
        }

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

        thead {
            background: var(--slate-50);
        }

        th {
            padding: 16px 24px;
            text-align: left;
            font-size: 11px;
            font-weight: 700;
            color: var(--slate-500);
            text-transform: uppercase;
            letter-spacing: 0.1em;
            white-space: nowrap;
        }

        td {
            padding: 16px 24px;
            font-size: 14px;
            vertical-align: middle;
        }

        tbody tr {
            border-top: 1px solid var(--slate-100);
            transition: all 0.2s ease;
        }

        tbody tr:hover {
            background: var(--slate-50);
        }
        
        tbody tr:hover td .owner-code {
            color: var(--blue-600);
            transition: color 0.15s;
        }

        tbody tr.expanded {
            background: var(--slate-50);
        }

        .owner-code {
            font-weight: 700;
            font-size: 16px;
            color: var(--slate-900);
        }

        .owner-name {
            font-size: 12px;
            color: var(--slate-400);
            font-weight: 500;
        }

        .btn-sheet {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 14px;
            border-radius: 20px;
            font-size: 13px;
            font-weight: 600;
            color: var(--blue-600);
            background: var(--blue-50);
            border: 1px solid var(--blue-200);
            text-decoration: none;
            transition: all 0.15s;
        }

        .btn-sheet:hover {
            background: var(--blue-100);
            color: var(--blue-700);
        }

        /* Status badges (match MasterSources.tsx status logic) */
        .status {
            display: flex;
            align-items: center;
            gap: 4px;
            font-size: 10px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.1em;
        }

        .status.success {
            color: var(--emerald-500);
        }

        .status.failed {
            color: var(--red-500);
        }

        .status.running {
            color: var(--blue-500);
            animation: pulse 2s infinite;
        }

        .status.queued {
            color: var(--amber-500);
        }

        @keyframes pulse {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.5;
            }
        }

        .run-date {
            font-weight: 700;
            color: var(--slate-700);
            font-variant-numeric: tabular-nums;
        }

        .run-stats {
            font-size: 12px;
            color: var(--slate-500);
            margin-top: 2px;
        }

        .actions {
            display: flex;
            align-items: center;
            gap: 12px;
            justify-content: flex-end;
        }

        .actions .divider {
            width: 1px;
            height: 24px;
            background: var(--slate-200);
        }

        .expand-btn {
            color: var(--slate-400);
            cursor: pointer;
            background: none;
            border: 1px solid transparent;
            padding: 4px;
            border-radius: 6px;
            transition: all 0.15s;
            display: flex;
            align-items: center;
        }

        .expand-btn:hover {
            color: var(--slate-800);
            background: white;
            border-color: var(--slate-200);
        }

        /* ===== EXPANDED ROW (run detail) ===== */
        .detail-row td {
            padding: 16px;
        }

        .detail-panel {
            background: #f8fafc;
            border-radius: 16px;
            box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
            border: 1px solid var(--slate-200);
            min-height: 200px;
            padding: 24px;
        }

        .detail-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
            gap: 16px;
            margin-bottom: 20px;
        }

        .stat-card {
            text-align: center;
            padding: 16px 12px;
            border-radius: 14px;
            background: white;
            border: 1px solid var(--slate-200);
            box-shadow: 0 2px 4px rgba(0,0,0,0.02);
            transition: transform 0.2s, box-shadow 0.2s;
            position: relative;
            overflow: hidden;
        }
        
        .stat-card::before {
            content: '';
            position: absolute;
            top: 0; left: 0; right: 0; height: 3px;
            background: var(--slate-200);
        }
        .stat-card.green::before { background: var(--emerald-400); }
        .stat-card.red::before { background: var(--red-400); }
        .stat-card.blue::before { background: var(--blue-400); }
        .stat-card.amber::before { background: var(--amber-400); }

        .stat-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(0,0,0,0.06);
        }

        .stat-value {
            font-size: 28px;
            font-weight: 800;
            color: var(--slate-800);
        }

        .stat-label {
            font-size: 11px;
            font-weight: 600;
            color: var(--slate-500);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-top: 4px;
        }

        .stat-card.green .stat-value {
            color: var(--emerald-600);
        }

        .stat-card.red .stat-value {
            color: var(--red-500);
        }

        .stat-card.blue .stat-value {
            color: var(--blue-600);
        }

        .stat-card.amber .stat-value {
            color: var(--amber-500);
        }

        .tabs-list {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            margin-top: 12px;
        }

        .tab-chip {
            font-size: 12px;
            font-weight: 600;
            padding: 4px 10px;
            border-radius: 6px;
            background: var(--blue-50);
            color: var(--blue-600);
        }

        .tab-chip.junk {
            background: var(--slate-100);
            color: var(--slate-500);
            text-decoration: line-through;
            opacity: 0.8;
        }

        .loading-spinner {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 200px;
            gap: 16px;
            color: var(--slate-500);
        }

        .spinner {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            border: 4px solid var(--blue-50);
            border-top-color: var(--blue-500);
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        .empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 80px;
            color: var(--slate-400);
            font-weight: 500;
        }

        /* ===== MODAL (match MasterSources.tsx modal) ===== */
        .modal-backdrop {
            position: fixed;
            inset: 0;
            background: rgba(15, 23, 42, 0.6);
            backdrop-filter: blur(4px);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 16px;
            z-index: 50;
        }

        .modal {
            background: white;
            border-radius: 16px;
            box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
            width: 100%;
            max-width: 448px;
            padding: 32px;
            border: 1px solid var(--slate-200);
            animation: slideUp 0.2s ease-out;
        }

        @keyframes slideUp {
            from {
                transform: translateY(10px);
                opacity: 0;
            }

            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        .modal h3 {
            font-size: 20px;
            font-weight: 700;
            color: var(--slate-800);
        }

        .modal .close-btn {
            background: none;
            border: none;
            color: var(--slate-400);
            cursor: pointer;
            font-size: 24px;
            transition: color 0.15s;
        }

        .modal .close-btn:hover {
            color: var(--slate-600);
        }

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

        .form-label {
            display: block;
            font-size: 11px;
            font-weight: 700;
            color: var(--slate-500);
            text-transform: uppercase;
            letter-spacing: 0.1em;
            margin-bottom: 8px;
        }

        .form-input {
            width: 100%;
            background: var(--slate-50);
            border: 1px solid var(--slate-200);
            border-radius: 12px;
            padding: 12px 16px;
            font-size: 14px;
            outline: none;
            transition: all 0.15s;
            font-family: inherit;
        }

        .form-input:focus {
            box-shadow: 0 0 0 2px var(--blue-500);
            border-color: transparent;
        }

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

        .form-actions {
            display: flex;
            justify-content: flex-end;
            gap: 12px;
            padding-top: 16px;
        }

        /* ===== TOAST (match MasterSources.tsx toast) ===== */
        .toast {
            position: fixed;
            top: 24px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 100;
            animation: slideDown 0.3s ease-out;
            pointer-events: none;
        }

        .toast-inner {
            box-shadow: 0 8px 30px rgb(0 0 0 / 0.12);
            border-radius: 16px;
            padding: 14px 24px;
            display: flex;
            align-items: center;
            gap: 12px;
            backdrop-filter: blur(12px);
            font-weight: 600;
            font-size: 14px;
        }

        .toast.success .toast-inner {
            background: rgba(236, 253, 245, 0.9);
            border: 1px solid rgba(167, 243, 208, 0.5);
            color: var(--emerald-800);
        }

        .toast.error .toast-inner {
            background: rgba(254, 242, 242, 0.9);
            border: 1px solid rgba(254, 202, 202, 0.5);
            color: var(--red-800);
        }

        .toast.warning .toast-inner {
            background: rgba(255, 251, 235, 0.9);
            border: 1px solid rgba(253, 230, 138, 0.5);
            color: var(--amber-800);
        }

        @keyframes slideDown {
            from {
                transform: translateX(-50%) translateY(-20px);
                opacity: 0;
            }

            to {
                transform: translateX(-50%) translateY(0);
                opacity: 1;
            }
        }

        /* ===== DELETE CONFIRM MODAL ===== */
        .confirm-icon {
            width: 64px;
            height: 64px;
            border-radius: 50%;
            background: var(--red-50);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .confirm-actions {
            display: flex;
            width: 100%;
            gap: 12px;
            padding-top: 16px;
        }

        .confirm-actions .btn {
            flex: 1;
            justify-content: center;
            padding: 12px;
        }

        /* ===== SYNC ALL BAR ===== */
        .sync-all-bar {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        /* ===== HEALTH ALERT BANNER ===== */
        .health-banner {
            display: none;
            background: var(--red-50);
            border: 1px solid var(--red-200);
            border-radius: 12px;
            padding: 14px 24px;
            margin: 0 32px 0;
            color: var(--red-800);
            font-size: 14px;
            font-weight: 600;
            animation: slideDown 0.3s ease-out;
        }

        .health-banner.visible {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .health-banner .health-icon {
            font-size: 20px;
        }

        .health-banner .health-details {
            font-weight: 400;
            color: var(--red-700);
            margin-left: 4px;
        }

        /* Trạng thái chỉnh sửa chủ nhà (modifiedTime) */
        .modified-status {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 12px;
        }

        .modified-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            flex-shrink: 0;
        }

        .modified-dot.has-changes {
            background: var(--red-500);
            box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
            animation: pulse 2s infinite;
        }

        .modified-dot.no-changes {
            background: var(--slate-300);
        }

        .modified-dot.unknown {
            background: var(--amber-500);
        }

        .modified-time {
            font-weight: 600;
            color: var(--slate-700);
            font-variant-numeric: tabular-nums;
        }

        .modified-label {
            font-size: 10px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .modified-label.new {
            color: var(--red-500);
        }

        .modified-label.synced {
            color: var(--slate-400);
        }

        /* SVG Icons inline */
        .icon {
            width: 16px;
            height: 16px;
            display: inline-block;
            vertical-align: middle;
        }

        .icon-lg {
            width: 20px;
            height: 20px;
        }

        .icon-xl {
            width: 40px;
            height: 40px;
        }